@@ -249,9 +249,10 @@ module Streamly.Internal.Data.Fold.Type
249 , ManyState
249 , ManyState
251 , manyPost
251 , manyPost
252 , consumeMany
253 , consumeMany
253 , consumeMany1
254 , consumeMany1
254− , chunksOf
255+ , appendConsumer
256 -- ** Nesting
257 -- ** Nesting
257 , concatMap
258 , concatMap
@@ -1303,6 +1304,10 @@ manyPost (Fold sstep sinitial sextract) (Fold cstep cinitial cextract) =
1303chunksOf :: Monad m => Int -> Fold m a b -> Fold m b c -> Fold m a c
1304chunksOf :: Monad m => Int -> Fold m a b -> Fold m b c -> Fold m a c
1304chunksOf n split = many (take n split)
1305chunksOf n split = many (take n split)
1307+------------------------------------------------------------------------------
1308+-- Consumer and Fold Combinators
1309+------------------------------------------------------------------------------
1306-- | Like 'many' but uses a 'Consumer' for collecting.
1311-- | Like 'many' but uses a 'Consumer' for collecting.
1308{-# INLINE consumeMany #-}
1313{-# INLINE consumeMany #-}
@@ -1402,3 +1407,11 @@ consumeMany1 (Consumer sstep sinject sextract) (Fold cstep cinitial cextract) =
1402 case cres of
1407 case cres of
1403 Partial s -> cextract s
1408 Partial s -> cextract s
1404 Done b -> return b
1409 Done b -> return b
1411+-- | Extend a fold by appending a Consumer.
1414+{-# INLINE appendConsumer #-}
1415+appendConsumer :: Monad m => Fold m a b -> Consumer m b a b -> Fold m a b
1416+appendConsumer f (Consumer step inject extract) =
1417+ Fold step (finish f >>= inject) extract