@@ -89,12 +89,13 @@ module Streamly.Internal.Data.Stream.IsStream.Expand
8989
9090 -- ** Append Many (Unfold)
9191 -- | Unfold and flatten streams.
92+ , unfoldMany
93+ , unfoldManyInterleave
94+ , unfoldManyRoundRobin
9295 , concatUnfold
93− , concatUnfoldInterleave
94− , concatUnfoldRoundrobin
9596
9697 -- ** Interpose
97− -- | Insert effects between streams. Like concatUnfold but intersperses an
98+ -- | Insert effects between streams. Like unfoldMany but intersperses an
9899 -- effect between the streams. A special case of gintercalate.
99100 , interpose
100101 , interposeSuffix
@@ -102,7 +103,7 @@ module Streamly.Internal.Data.Stream.IsStream.Expand
102103
103104 -- ** Intercalate
104105 -- | Insert Streams between Streams.
105− -- Like concatUnfold but intersperses streams from another source between
106+ -- Like unfoldMany but intersperses streams from another source between
106107 -- the streams from the first source.
107108 , intercalate
108109 , intercalateSuffix
@@ -449,40 +450,45 @@ mergeAsyncByM f m1 m2 =
449450 let par = Par.mkParallelD . toStreamD
450451 in D.mergeByM f (par m1) (par m2)
451452
453+
454+-- @since 0.7.0
455+{-# DEPRECATED concatUnfold "Please use unfoldMany instead." #-}
456+{-# INLINE concatUnfold #-}
457+concatUnfold ::(IsStream t, Monad m) => Unfold m a b -> t m a -> t m b
458+concatUnfold u m = fromStreamD $ D.unfoldMany u (toStreamD m)
459+
452460------------------------------------------------------------------------------
453−-- Combine N Streams - concatUnfold
461+-- Combine N Streams - unfoldMany
454462------------------------------------------------------------------------------
455463
456−-- XXX Rename to unfoldMany
457−--
458464-- | Like 'concatMap' but uses an 'Unfold' for stream generation. Unlike
459465-- 'concatMap' this can fuse the 'Unfold' code with the inner loop and
460466-- therefore provide many times better performance.
461467--
462−-- @since 0.7.0
463−{-# INLINE concatUnfold #-}
464−concatUnfold ::(IsStream t, Monad m) => Unfold m a b -> t m a -> t m b
465−concatUnfold u m = fromStreamD $ D.concatUnfold u (toStreamD m)
468+-- @since 0.8.0
469+{-# INLINE unfoldMany #-}
470+unfoldMany ::(IsStream t, Monad m) => Unfold m a b -> t m a -> t m b
471+unfoldMany u m = fromStreamD $ D.unfoldMany u (toStreamD m)
466472
467−-- | Like 'concatUnfold' but interleaves the streams in the same way as
473+-- | Like 'unfoldMany' but interleaves the streams in the same way as
468474-- 'interleave' behaves instead of appending them.
469475--
470476-- /Pre-release/
471−{-# INLINE concatUnfoldInterleave #-}
472−concatUnfoldInterleave ::(IsStream t, Monad m)
477+{-# INLINE unfoldManyInterleave #-}
478+unfoldManyInterleave ::(IsStream t, Monad m)
473479 => Unfold m a b -> t m a -> t m b
474−concatUnfoldInterleave u m =
475− fromStreamD $ D.concatUnfoldInterleave u (toStreamD m)
480+unfoldManyInterleave u m =
481+ fromStreamD $ D.unfoldManyInterleave u (toStreamD m)
476482
477−-- | Like 'concatUnfold' but executes the streams in the same way as
483+-- | Like 'unfoldMany' but executes the streams in the same way as
478484-- 'roundrobin'.
479485--
480486-- /Pre-release/
481−{-# INLINE concatUnfoldRoundrobin #-}
482−concatUnfoldRoundrobin ::(IsStream t, Monad m)
487+{-# INLINE unfoldManyRoundRobin #-}
488+unfoldManyRoundRobin ::(IsStream t, Monad m)
483489 => Unfold m a b -> t m a -> t m b
484−concatUnfoldRoundrobin u m =
485− fromStreamD $ D.concatUnfoldRoundrobin u (toStreamD m)
490+unfoldManyRoundRobin u m =
491+ fromStreamD $ D.unfoldManyRoundRobin u (toStreamD m)
486492
487493------------------------------------------------------------------------------
488494-- Combine N Streams - interpose
@@ -521,11 +527,11 @@ interposeSuffix x unf str =
521527------------------------------------------------------------------------------
522528
523529-- XXX we can swap the order of arguments to gintercalate so that the
524−-- definition of concatUnfold becomes simpler? The first stream should be
530+-- definition of unfoldMany becomes simpler? The first stream should be
525531-- infixed inside the second one. However, if we change the order in
526532-- "interleave" as well similarly, then that will make it a bit unintuitive.
527533--
528−-- > concatUnfold unf str =
534+-- > unfoldMany unf str =
529535-- > gintercalate unf str (UF.nilM (\_ -> return ())) (repeat ())
530536--
531537-- | 'interleaveInfix' followed by unfold and concat.
@@ -547,7 +553,7 @@ gintercalate unf1 str1 unf2 str2 =
547553-- will be starting with the second stream.
548554
549555-- > intercalate seed unf str = gintercalate unf str unf (repeatM seed)
550−-- > intercalate a unf str = concatUnfold unf $ intersperse a str
556+-- > intercalate a unf str = unfoldMany unf $ intersperse a str
551557--
552558-- | 'intersperse' followed by unfold and concat.
553559--
@@ -561,7 +567,7 @@ gintercalate unf1 str1 unf2 str2 =
561567intercalate :: (IsStream t, Monad m)
562568 => b -> Unfold m b c -> t m b -> t m c
563569intercalate seed unf str = D.fromStreamD $
564− D.concatUnfold unf $ D.intersperse seed (toStreamD str)
570+ D.unfoldMany unf $ D.intersperse seed (toStreamD str)
565571
566572-- | 'interleaveSuffix' followed by unfold and concat.
567573--
@@ -576,7 +582,7 @@ gintercalateSuffix unf1 str1 unf2 str2 =
576582 unf2 (D.toStreamD str2)
577583
578584-- > intercalateSuffix seed unf str = gintercalateSuffix unf str unf (repeatM seed)
579−-- > intercalateSuffix a unf str = concatUnfold unf $ intersperseSuffix a str
585+-- > intercalateSuffix a unf str = unfoldMany unf $ intersperseSuffix a str
580586--
581587-- | 'intersperseSuffix' followed by unfold and concat.
582588--
@@ -589,7 +595,7 @@ gintercalateSuffix unf1 str1 unf2 str2 =
589595{-# INLINE intercalateSuffix #-}
590596intercalateSuffix :: (IsStream t, Monad m)
591597 => b -> Unfold m b c -> t m b -> t m c
592−intercalateSuffix seed unf str = fromStreamD $ D.concatUnfold unf
598+intercalateSuffix seed unf str = fromStreamD $ D.unfoldMany unf
593599 $ D.intersperseSuffix (return seed) (D.toStreamD str)
594600
595601{-