Hello, cafe.
Is it possible to read data from different concurrent sources,
i.e. read data from source as soon as it become avaliable, e.g.
runResourceT $ (source1 stdin $= CL.map Left)
= (source2 handle $= CL.map Right)
$= application
$$ sink
On Tue, Feb 28, 2012 at 6:04 PM, Alexander V Vershilov
alexander.vershi...@gmail.com wrote:
Hello, cafe.
Is it possible to read data from different concurrent sources,
i.e. read data from source as soon as it become avaliable, e.g.
runResourceT $ (source1 stdin $= CL.map Left)
First of all, I'd probably name that operator =, since = is Kleisli
composition in Control.Monad.
Second, you're going to need new threads for this, since you'll be reading
from two sources concurrently. This isn't as big a problem as you might
think, because Haskell threads are dirt cheap,
Finally, I've uploaded a new version of stm-conduit [1] with these
combinators included. You should cabal update and then cabal install
stm-conduit to get the latest version, and now you can vertically compose
your sources!
Regards,
- clark
[1]
Hello.
Naming operator = instead of = is a good idea.
But this functions are looks very good and will make code easier to understand.
Also I'll try using non-STM channel (as Michael adviced) because in such a task
I don't need all STM power.
Thanks for response.
--
Alexander
Tue, Feb 28,