Perhaps this combinator would be worth having somewhere common? (I haven’t
type-checked this, so there could be mistakes, but you should get the general
idea.)
accumOf :: (Monad m) => Pipe a b m r -> Pipe a [b] m r
accumOf getOne = do
(r, xs) <- runWriterP $ for getOne $ \ x -> tell [x]
yield xs
return r
On Jan 5, 2014, at 3:26 PM, Luke Tomlin <[email protected]> wrote:
> Could you elaborate? How would I use for to do this?
>
> Thanks for the quick reply!
>
> On Sunday, 5 January 2014 23:10:53 UTC, Alexander Altman wrote:
> I think you can use for for this purpose, yes?
>
> On Jan 5, 2014, at 3:07 PM, Luke Tomlin <[email protected]> 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].
> 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].
To post to this group, send email to [email protected].