@@ -217,6 +217,7 @@ module Streamly.Internal.Data.Fold.Type
218 -- * Nested Application
218 -- * Nested Application
219 , concatMap
219 , concatMap
221 , manyPost
222 , manyPost
222 , intervalsOf
223 , intervalsOf
@@ -949,6 +950,11 @@ runStep (Fold step initial extract) a = return $ Fold step initial1 extract
949-- applied to a fold input stream. groupBy et al can be written as terminating
950-- applied to a fold input stream. groupBy et al can be written as terminating
950-- folds and then we can apply "many" to use those repeatedly on a stream.
951-- folds and then we can apply "many" to use those repeatedly on a stream.
953+{-# ANN type ManyState Fuse #-}
952-- | Collect zero or more applications of a fold. @many split collect@ applies
958-- | Collect zero or more applications of a fold. @many split collect@ applies
953-- the @split@ fold repeatedly on the input stream and accumulates zero or more
959-- the @split@ fold repeatedly on the input stream and accumulates zero or more
954-- fold results using @collect@.
960-- fold results using @collect@.
@@ -977,30 +983,35 @@ many (Fold sstep sinitial sextract) (Fold cstep cinitial cextract) =
977 -- important.
983 -- important.
979 {-# INLINE handleSplitStep #-}
985 {-# INLINE handleSplitStep #-}
980− handleSplitStep cs sres =
986+ handleSplitStep branch cs sres =
981 case sres of
987 case sres of
982− Partial ss1 -> return $ Partial $ Tuple' ss1 cs
988+ Partial ss1 -> return $ Partial $ branch ss1 cs
983− Done sb -> runCollector cs sb
989+ Done sb -> runCollector ManyFirst cs sb
985 {-# INLINE handleCollectStep #-}
991 {-# INLINE handleCollectStep #-}
986− handleCollectStep cres =
992+ handleCollectStep branch cres =
987 case cres of
993 case cres of
988 Partial cs -> do
994 Partial cs -> do
989 sres <- sinitial
995 sres <- sinitial
990− handleSplitStep cs sres
996+ handleSplitStep branch cs sres
991 Done cb -> return $ Done cb
997 Done cb -> return $ Done cb
993 -- Do not inline this
999 -- Do not inline this
994− runCollector cs sb = cstep cs sb >>= handleCollectStep
1000+ runCollector branch cs sb = cstep cs sb >>= handleCollectStep branch
996− initial = cinitial >>= handleCollectStep
1002+ initial = cinitial >>= handleCollectStep ManyFirst
998− {-# INLINE step #-}
1004+ {-# INLINE step_ #-}
999− step (Tuple' ss cs) a = do
1005+ step_ ss cs a = do
1000 sres <- sstep ss a
1006 sres <- sstep ss a
1001− handleSplitStep cs sres
1007+ handleSplitStep ManyLoop cs sres
1003− extract (Tuple' ss cs) = do
1009+ {-# INLINE step #-}
1010+ step (ManyFirst ss cs) a = step_ ss cs a
1011+ step (ManyLoop ss cs) a = step_ ss cs a
1013+ extract (ManyFirst _ cs) = cextract cs
1014+ extract (ManyLoop ss cs) = do
1004 sb <- sextract ss
1015 sb <- sextract ss
1005 cres <- cstep cs sb
1016 cres <- cstep cs sb
1006 case cres of
1017 case cres of