Can I make a handset that consumes the entire output of the manufacturer and transmits it as a list?

I am trying to use the Pipes library to simulate a workflow. In this workflow, I would like to accumulate all this result from the manufacturer, and then pass it on. In this case, I know that my manufacturer produces the final result.

So, if I have:

prod :: Producer am () accum :: Pipe a [a] mr groupConsumer :: Consumer [a] mr 

how do i simulate accum so i can:

 runEffect $ prod >-> accum >-> groupConsumer 

Thanks!

+6
source share
1 answer

You can use Pipes.Prelude.toListM to collect Producer into a list:

 Pipes.Prelude.toListM :: (Monad m) => Producer am () -> m [a] Pipes.Prelude.toListM prod :: (Monad m) => m [a] 

Then you just upload this list to your groupConsumer :

 runEffect $ (lift (Pipes.Prelude.toListM prod) >>= yield) >-> groupConsumer 
+6
source

All Articles