Right, everything is tailored to use with `foldl`, though I haven't 
documented this yet. 
In general everything marked with a final single quote is tailored for use 
with `mapsM` 
-- which is like `maps` but allows a monadic return type:

     maps     :: (Monad m, Functor f) => (forall x. f x -> g x) -> Stream f 
m r -> Stream g m r     -- as in pipes group

     mapsM  :: (Monad m, Functor f) =>   (forall x. f x -> m (g x)) -> 
Stream f m r -> Stream g m r


thus
    
       mapsM S.sum'  :: (Monad m, Num a) => Stream (Stream (Of a) m) m r -> 
Stream (Of a) m r

but more importantly

       mapsM (L.purely S.fold' fld)   :: Monad m =>  Fold a b -> Stream 
(Stream (Of a) m) m r -> Stream (Of b) m r

       \fld -> mapsM (L.purely S.fold' fld) . S.group  
           :: (Eq a, Monad m) =>   LB.Fold a b -> Stream (Of a) m r -> 
Stream (Of b) m r

and better yet

       \fld -> mapsM (L.impurely S.foldM' fld) . chunksOf 20   
           :: Monad m =>  L.FoldM m a b -> Stream (Of a) m r -> Stream (Of 
b) m r

and so on.

The use of the single quote, and the duplication, are a little obnoxious, 
of course. 
(The same device is used in the bytestring modules.) I was thinking of 
dropping the folds 
that just return things like `m Int` in favor of the others, which are 
`mapsM`-able, 
and fit better with the idea of the package. 

But the simple ones looked so good in ghci when I was testing examples...

It is also easy to write accumulating folds in various ways. I am trying to 
think of a way of
presenting this that is easy to take in, so one doesn't get lost in the 
rank 2 arguments and so on.

-- 
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