
Hello, cafe! I have somq questions about proper conduit usage in some usecases, I can't find a good way to solve this problems 1). adding additional source to conduit processing [1] Sometimes I want to run a Source and send use it to produce output e.g. have something like:
runSource :: ResourceT m => a -> Source m b runSource = undefined
test1 :: ResourceT m => Conduit a m b test1 = Conduit push close where push = runSource close = undefined -- In my first problem I've got -- push i = case i of Left _ -> oneValue ; Right -> runSource -- but it can be solved with oneValue = sourceList [oneValue]
2). pushing data back [1] e.g. I have
test2 :: ResourceT Conduit ByteString m b test2 = Conduit push close where conduit i = let (item,lft) = parse i in -- I want to send lft back to test2 and -- process item -- in the other case I want to be able to send data back to -- previous or arbitrary level, e.g. test1 $= test2 $= test3 ^--------| (<<<=) lft
3). split stream to send it to different Sinks, e.g.
sendToAll test3 [sink1,sink2,sink3]
4). send additional data from the other place, e.g.
src $= handle $$ snk -- state -^ -- I want to send message into handle to change it's state -- It can be done with stm-conduit and Either (Left for commands -- and Right for data), but it seems its overkill
I will be apprecated, if smb has any idea how to implement it correnly, or why I shouldn't implement it at all. [1] http://stackoverflow.com/questions/9226780/how-to-add-a-new-source-inside-a-... -- Regards, Alexander V Vershilov