@@ -89,12 +89,13 @@ module Streamly.Internal.Data.Stream.IsStream.Expand
90 -- ** Append Many (Unfold)
90 -- ** Append Many (Unfold)
91 -- | Unfold and flatten streams.
91 -- | Unfold and flatten streams.
93+ , unfoldManyInterleave
94+ , unfoldManyRoundRobin
92 , concatUnfold
95 , concatUnfold
93− , concatUnfoldInterleave
94− , concatUnfoldRoundrobin
96 -- ** Interpose
97 -- ** Interpose
97− -- | Insert effects between streams. Like concatUnfold but intersperses an
98+ -- | Insert effects between streams. Like unfoldMany but intersperses an
98 -- effect between the streams. A special case of gintercalate.
99 -- effect between the streams. A special case of gintercalate.
99 , interpose
100 , interpose
100 , interposeSuffix
101 , interposeSuffix
@@ -102,7 +103,7 @@ module Streamly.Internal.Data.Stream.IsStream.Expand
103 -- ** Intercalate
104 -- ** Intercalate
104 -- | Insert Streams between Streams.
105 -- | Insert Streams between Streams.
105− -- Like concatUnfold but intersperses streams from another source between
106+ -- Like unfoldMany but intersperses streams from another source between
106 -- the streams from the first source.
107 -- the streams from the first source.
107 , intercalate
108 , intercalate
108 , intercalateSuffix
109 , intercalateSuffix
@@ -449,40 +450,45 @@ mergeAsyncByM f m1 m2 =
449 let par = Par.mkParallelD . toStreamD
450 let par = Par.mkParallelD . toStreamD
450 in D.mergeByM f (par m1) (par m2)
451 in D.mergeByM f (par m1) (par m2)
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)
452------------------------------------------------------------------------------
460------------------------------------------------------------------------------
453−-- Combine N Streams - concatUnfold
461+-- Combine N Streams - unfoldMany
454------------------------------------------------------------------------------
462------------------------------------------------------------------------------
456−-- XXX Rename to unfoldMany
458-- | Like 'concatMap' but uses an 'Unfold' for stream generation. Unlike
464-- | Like 'concatMap' but uses an 'Unfold' for stream generation. Unlike
459-- 'concatMap' this can fuse the 'Unfold' code with the inner loop and
465-- 'concatMap' this can fuse the 'Unfold' code with the inner loop and
460-- therefore provide many times better performance.
466-- therefore provide many times better performance.
462−-- @since 0.7.0
468+-- @since 0.8.0
463−{-# INLINE concatUnfold #-}
469+{-# INLINE unfoldMany #-}
464−concatUnfold ::(IsStream t, Monad m) => Unfold m a b -> t m a -> t m b
470+unfoldMany ::(IsStream t, Monad m) => Unfold m a b -> t m a -> t m b
465−concatUnfold u m = fromStreamD $ D.concatUnfold u (toStreamD m)
471+unfoldMany u m = fromStreamD $ D.unfoldMany u (toStreamD m)
467−-- | Like 'concatUnfold' but interleaves the streams in the same way as
473+-- | Like 'unfoldMany' but interleaves the streams in the same way as
468-- 'interleave' behaves instead of appending them.
474-- 'interleave' behaves instead of appending them.
470-- /Pre-release/
476-- /Pre-release/
471−{-# INLINE concatUnfoldInterleave #-}
477+{-# INLINE unfoldManyInterleave #-}
472−concatUnfoldInterleave ::(IsStream t, Monad m)
478+unfoldManyInterleave ::(IsStream t, Monad m)
473 => Unfold m a b -> t m a -> t m b
479 => Unfold m a b -> t m a -> t m b
474−concatUnfoldInterleave u m =
480+unfoldManyInterleave u m =
475− fromStreamD $ D.concatUnfoldInterleave u (toStreamD m)
481+ fromStreamD $ D.unfoldManyInterleave u (toStreamD m)
477−-- | Like 'concatUnfold' but executes the streams in the same way as
483+-- | Like 'unfoldMany' but executes the streams in the same way as
478-- 'roundrobin'.
484-- 'roundrobin'.
480-- /Pre-release/
486-- /Pre-release/
481−{-# INLINE concatUnfoldRoundrobin #-}
487+{-# INLINE unfoldManyRoundRobin #-}
482−concatUnfoldRoundrobin ::(IsStream t, Monad m)
488+unfoldManyRoundRobin ::(IsStream t, Monad m)
483 => Unfold m a b -> t m a -> t m b
489 => Unfold m a b -> t m a -> t m b
484−concatUnfoldRoundrobin u m =
490+unfoldManyRoundRobin u m =
485− fromStreamD $ D.concatUnfoldRoundrobin u (toStreamD m)
491+ fromStreamD $ D.unfoldManyRoundRobin u (toStreamD m)
487------------------------------------------------------------------------------
493------------------------------------------------------------------------------
488-- Combine N Streams - interpose
494-- Combine N Streams - interpose
@@ -521,11 +527,11 @@ interposeSuffix x unf str =
521------------------------------------------------------------------------------
527------------------------------------------------------------------------------
523-- XXX we can swap the order of arguments to gintercalate so that the
529-- 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
525-- infixed inside the second one. However, if we change the order in
531-- infixed inside the second one. However, if we change the order in
526-- "interleave" as well similarly, then that will make it a bit unintuitive.
532-- "interleave" as well similarly, then that will make it a bit unintuitive.
528−-- > concatUnfold unf str =
534+-- > unfoldMany unf str =
529-- > gintercalate unf str (UF.nilM (\_ -> return ())) (repeat ())
535-- > gintercalate unf str (UF.nilM (\_ -> return ())) (repeat ())
531-- | 'interleaveInfix' followed by unfold and concat.
537-- | 'interleaveInfix' followed by unfold and concat.
@@ -547,7 +553,7 @@ gintercalate unf1 str1 unf2 str2 =
547-- will be starting with the second stream.
553-- will be starting with the second stream.
549-- > intercalate seed unf str = gintercalate unf str unf (repeatM seed)
555-- > 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
552-- | 'intersperse' followed by unfold and concat.
558-- | 'intersperse' followed by unfold and concat.
@@ -561,7 +567,7 @@ gintercalate unf1 str1 unf2 str2 =
561intercalate :: (IsStream t, Monad m)
567intercalate :: (IsStream t, Monad m)
562 => b -> Unfold m b c -> t m b -> t m c
568 => b -> Unfold m b c -> t m b -> t m c
563intercalate seed unf str = D.fromStreamD $
569intercalate seed unf str = D.fromStreamD $
564− D.concatUnfold unf $ D.intersperse seed (toStreamD str)
570+ D.unfoldMany unf $ D.intersperse seed (toStreamD str)
566-- | 'interleaveSuffix' followed by unfold and concat.
572-- | 'interleaveSuffix' followed by unfold and concat.
@@ -576,7 +582,7 @@ gintercalateSuffix unf1 str1 unf2 str2 =
576 unf2 (D.toStreamD str2)
582 unf2 (D.toStreamD str2)
578-- > intercalateSuffix seed unf str = gintercalateSuffix unf str unf (repeatM seed)
584-- > 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
581-- | 'intersperseSuffix' followed by unfold and concat.
587-- | 'intersperseSuffix' followed by unfold and concat.
@@ -589,7 +595,7 @@ gintercalateSuffix unf1 str1 unf2 str2 =
589{-# INLINE intercalateSuffix #-}
595{-# INLINE intercalateSuffix #-}
590intercalateSuffix :: (IsStream t, Monad m)
596intercalateSuffix :: (IsStream t, Monad m)
591 => b -> Unfold m b c -> t m b -> t m c
597 => 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
593 $ D.intersperseSuffix (return seed) (D.toStreamD str)
599 $ D.intersperseSuffix (return seed) (D.toStreamD str)