[Haskell-cafe] Yet another Conduit question

Simon Marechal simon at banquise.net
Thu Jan 31 16:12:06 CET 2013


I am working with bulk sources and sinks, that is with a type like:

Source m [a]
Sink [a] m ()

The problem is that I would like to work on individual values in my
conduit. I can have this:

concat :: (Monad m) => Conduit [a] m a
concat = awaitForever (mapM_ yield)

But how can I do it the other way around ? I suppose it involves pattern
matching on the different states my conduit might me in. But is that
even possible to do it in a "non blocking" way, that is catenate data
while there is something to read (up to a certain threshold), and send
it as soon as there is nothing left to read ? Or doesn't that make any
sense in the context of Conduits (in the sense that this conduit will be
recheck for input before the upstream conduits will have a chance to
operate) ?

Another approach would be to have a map equivalent:

conduitMap :: Conduit i m o -> Conduit [i] m [o]

But I am not sure how to do this either ...



More information about the Haskell-Cafe mailing list