Hi Patrick,

Gabriel answered my question on Stack Overflow. He gave a similar solution 
too, and it was sufficient for my needs! I'm currently using 

accum :: Monad m => Producer a m () -> Proxy x' x () [a] m ()
accum prod = lift (P.toListM prod) >>= yield

I was then able to put this as an infix operator:

a >:: b = (accum a) >-> b

which lets me do what I originally wanted:

runEffect $ myProducer >:: myGroupPipe >-> myOutput

Sorry if I was a little vague with my question! Thanks for your help :)

PS. As it turns out, (>::) has a crazy type signature that apparently 
involves RankNTypes and KindSignatures, so I'm not sure if I'm doing 
something inherently evil here.

On Monday, 6 January 2014 22:48:19 UTC, Davorak wrote:
>
> @Luke Tomlin
>
> Can you give a few example cases with input and output?  That should make 
> it easier to pin down the functionality you are looking for.
>
> For instance it is not clear if you need it to be a pipe(accum :: Pipe a 
> [a] m r) or if it can be a function on a Producer a m r.
>
> accum as a function on a producer would be:
>
> accum :: Monad m => Producer a m () -> Producer [a] m ()
> accum p = (P.toListM (hoist lift p)) >>= yield
>
> warning hand simplified type signature.
>
>
> On Mon, Jan 6, 2014 at 5:13 AM, Luke Tomlin <[email protected]<javascript:>
> > wrote:
>
>> Kinda, but how can I use that in a way that continues to be pipe-like? 
>>
>> Eg. if I have 
>>
>> prod :: Producer a m ()
>>
>> accum :: Pipe a [a] m r
>> groupConsumer :: Consumer [a] m r
>>
>> can I do:
>> runEffect $ prod >-> accum >-> groupConsumer
>>
>> using toListM?
>>
>>
>> On Monday, 6 January 2014 06:52:20 UTC, Gabriel Gonzalez wrote:
>>
>>> Is `Pipes.Prelude.toListM` what you want? 
>>>
>>> Pipes.Prelude.toListM :: (Monad m) => Producer a m () -> m [a] 
>>>
>>> On 01/06/2014 06:07 AM, Luke Tomlin wrote: 
>>> > Hello, 
>>> > 
>>> > I'm a newbie to pipes, and I'm having a little trouble. 
>>> > 
>>> > I would like to accumulate all of the 'produce' from a producer into a 
>>> > list, and then yield this new list onwards. I know that my producer 
>>> > will produce a finite amount of items! 
>>> > 
>>> > Eg. something like: 
>>> > 
>>> > accum :: Pipe a [a] m r 
>>> > 
>>> > Apologies if the solution is really obvious and I'm just being dense! 
>>> > 
>>> > Thanks, 
>>> > 
>>> > Luke 
>>> > -- 
>>> > 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 [email protected]. 
>>> > To post to this group, send email to [email protected]. 
>>>
>>>  -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>>
>
>
>
> -- 
> Patrick Wheeler
> [email protected] <javascript:>
> [email protected] <javascript:>
> [email protected] <javascript:> 
>

-- 
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 [email protected].
To post to this group, send email to [email protected].

Reply via email to