On Wednesday, April 8, 2015 at 3:44:53 PM UTC+2, Michael Thompson wrote:
>
> I'm just wondering for clarification: are you looking for something that 
> -- if the consumers p1, p2 ... pN were in `IO` -- might look like so:
>
>
>     import Control.Concurrent.Async
>     import qualified Pipes.Prelude as P
>     import Pipes.Concurrent
>     import Pipes
>     import Control.Monad
>
>     together :: Producer x IO () -> [Consumer x IO ()] -> IO ()
>     together producer consumers = do
>         (output, input) <- spawn unbounded
>         as <- forM consumers $ \consumer ->
>               async $ do runEffect $ fromInput input  >-> consumer
>                          performGC
>         a  <- async $ do runEffect $ producer >-> toOutput output
>                          performGC
>         mapM_ wait (a:as)
>
>
In my process-streaming 
<http://hackage.haskell.org/package/process-streaming> package, I have a 
type called Siphon 
<http://hackage.haskell.org/package/process-streaming-0.7.1.0/docs/System-Process-Streaming.html#g:4>
 
that behaves a bit like this. Its Applicative instance uses 
pipes-concurrency tricks to achieve "independent passes". A simple example:

import System.Process.Streaming
> import System.Process.Streaming.Internal (runSiphon)
> import Pipes
> import qualified Pipes.Prelude as P
> import Control.Applicative 


> runSiphon (fromConsumer P.print *> fromConsumer P.print)  (yield 5 >> 
> yield 6)


 

-- 
You received this message because you are subscribed to the Google Groups 
"Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to haskell-pipes+unsubscr...@googlegroups.com.
To post to this group, send email to haskell-pipes@googlegroups.com.

Reply via email to