@@ -249,9 +249,10 @@ module Streamly.Internal.Data.Fold.Type
249249 , ManyState
250250 , many
251251 , manyPost
252+ , chunksOf
252253 , consumeMany
253254 , consumeMany1
254− , chunksOf
255+ , appendConsumer
255256
256257 -- ** Nesting
257258 , concatMap
@@ -1303,6 +1304,10 @@ manyPost (Fold sstep sinitial sextract) (Fold cstep cinitial cextract) =
13031304chunksOf :: Monad m => Int -> Fold m a b -> Fold m b c -> Fold m a c
13041305chunksOf n split = many (take n split)
13051306
1307+------------------------------------------------------------------------------
1308+-- Consumer and Fold Combinators
1309+------------------------------------------------------------------------------
1310+
13061311-- | Like 'many' but uses a 'Consumer' for collecting.
13071312--
13081313{-# INLINE consumeMany #-}
@@ -1402,3 +1407,11 @@ consumeMany1 (Consumer sstep sinject sextract) (Fold cstep cinitial cextract) =
14021407 case cres of
14031408 Partial s -> cextract s
14041409 Done b -> return b
1410+
1411+-- | Extend a fold by appending a Consumer.
1412+--
1413+-- /Internal/
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