@@ -120,21 +120,21 @@ module Streamly.Internal.Data.Stream.Expand
121 -- * Iterate
121 -- * Iterate
122 -- | Map and flatten Trees of Streams
122 -- | Map and flatten Trees of Streams
123− , iterateUnfoldManyDFS
123+ , unfoldIterateDfs
124− , iterateUnfoldManyBFS
124+ , unfoldIterateBfs
125− , iterateUnfoldManyBFSRev
125+ , unfoldIterateBfsRev
127− , iterateConcatMapWith
127+ , concatIterateWith
128− , iterateMergeMapWith
128+ , mergeIterateWith
130− , iterateConcatMapDFS
130+ , concatIterateDfs
131− , iterateConcatMapBFS
131+ , concatIterateBfs
133 -- More experimental ops
133 -- More experimental ops
134− , iterateConcatMapBFSRev
134+ , concatIterateBfsRev
135− , iterateLeftsConcatMapWith
135+ , concatIterateLeftsWith
136− , iterateConcatScanWith
136+ , concatIterateScanWith
137− , iterateConcatScan
137+ , concatIterateScan
@@ -639,7 +639,7 @@ mergeMapWith par f m =
639 (toStreamK m)
639 (toStreamK m)
641------------------------------------------------------------------------------
641------------------------------------------------------------------------------
642−-- iterateConcatMap - Map and flatten Trees of Streams
642+-- concatIterate - Map and flatten Trees of Streams
643------------------------------------------------------------------------------
643------------------------------------------------------------------------------
645-- | Yield an input element in the output stream, map a stream generator on it
645-- | Yield an input element in the output stream, map a stream generator on it
@@ -651,23 +651,23 @@ mergeMapWith par f m =
652-- >>> f = either Dir.readEitherPaths (const Stream.nil)
652-- >>> f = either Dir.readEitherPaths (const Stream.nil)
653-- >>> input = Stream.fromPure (Left ".")
653-- >>> input = Stream.fromPure (Left ".")
654−-- >>> ls = Stream.iterateConcatMapWith Stream.append f input
654+-- >>> ls = Stream.concatIterateWith Stream.append f input
656−-- Note that 'iterateM' is a special case of 'iterateConcatMapWith':
656+-- Note that 'iterateM' is a special case of 'concatIterateWith':
658−-- >>> iterateM f = Stream.iterateConcatMapWith Stream.append (Stream.fromEffect . f) . Stream.fromEffect
658+-- >>> iterateM f = Stream.concatIterateWith Stream.append (Stream.fromEffect . f) . Stream.fromEffect
662-- /Pre-release/
662-- /Pre-release/
664−{-# INLINE iterateConcatMapWith #-}
664+{-# INLINE concatIterateWith #-}
665−iterateConcatMapWith ::
665+concatIterateWith ::
666 (Stream m a -> Stream m a -> Stream m a)
666 (Stream m a -> Stream m a -> Stream m a)
667 -> (a -> Stream m a)
667 -> (a -> Stream m a)
668 -> Stream m a
668 -> Stream m a
669 -> Stream m a
669 -> Stream m a
670−iterateConcatMapWith combine f = iterateStream
670+concatIterateWith combine f = iterateStream
@@ -683,21 +683,21 @@ iterateConcatMapWith combine f = iterateStream
684-- >>> f = either (Just . Dir.readEitherPaths) (const Nothing)
684-- >>> f = either (Just . Dir.readEitherPaths) (const Nothing)
685-- >>> input = Stream.fromPure (Left ".")
685-- >>> input = Stream.fromPure (Left ".")
686−-- >>> ls = Stream.iterateConcatMapDFS f input
686+-- >>> ls = Stream.concatIterateDfs f input
688−-- This is equivalent to using @iterateConcatMapWith Stream.append@.
688+-- This is equivalent to using @concatIterateWith Stream.append@.
690-- /Pre-release/
690-- /Pre-release/
691−{-# INLINE iterateConcatMapDFS #-}
691+{-# INLINE concatIterateDfs #-}
692−iterateConcatMapDFS :: Monad m =>
692+concatIterateDfs :: Monad m =>
693 (a -> Maybe (Stream m a))
693 (a -> Maybe (Stream m a))
694 -> Stream m a
694 -> Stream m a
695 -> Stream m a
695 -> Stream m a
696−iterateConcatMapDFS f stream =
696+concatIterateDfs f stream =
697 fromStreamD
697 fromStreamD
698− $ D.iterateConcatMapDFS (fmap toStreamD . f ) (toStreamD stream)
698+ $ D.concatIterateDfs (fmap toStreamD . f ) (toStreamD stream)
700−-- | Similar to 'iterateConcatMapDFS' except that it traverses the stream in
700+-- | Similar to 'concatIterateDfs' except that it traverses the stream in
701-- breadth first style (BFS). First, all the elements in the input stream are
701-- breadth first style (BFS). First, all the elements in the input stream are
702-- emitted, and then their traversals are emitted.
702-- emitted, and then their traversals are emitted.
@@ -705,33 +705,33 @@ iterateConcatMapDFS f stream =
706-- >>> f = either (Just . Dir.readEitherPaths) (const Nothing)
706-- >>> f = either (Just . Dir.readEitherPaths) (const Nothing)
707-- >>> input = Stream.fromPure (Left ".")
707-- >>> input = Stream.fromPure (Left ".")
708−-- >>> ls = Stream.iterateConcatMapBFS f input
708+-- >>> ls = Stream.concatIterateBfs f input
710-- /Pre-release/
710-- /Pre-release/
711−{-# INLINE iterateConcatMapBFS #-}
711+{-# INLINE concatIterateBfs #-}
712−iterateConcatMapBFS :: Monad m =>
712+concatIterateBfs :: Monad m =>
713 (a -> Maybe (Stream m a))
713 (a -> Maybe (Stream m a))
714 -> Stream m a
714 -> Stream m a
715 -> Stream m a
715 -> Stream m a
716−iterateConcatMapBFS f stream =
716+concatIterateBfs f stream =
717 fromStreamD
717 fromStreamD
718− $ D.iterateConcatMapBFS (fmap toStreamD . f ) (toStreamD stream)
718+ $ D.concatIterateBfs (fmap toStreamD . f ) (toStreamD stream)
720−-- | Same as 'iterateConcatMapBFS' except that the traversal of the last
720+-- | Same as 'concatIterateBfs' except that the traversal of the last
721-- element on a level is emitted first and then going backwards up to the first
721-- element on a level is emitted first and then going backwards up to the first
722-- element (reversed ordering). This may be slightly faster than
722-- element (reversed ordering). This may be slightly faster than
723−-- 'iterateConcatMapBFS'.
723+-- 'concatIterateBfs'.
725−{-# INLINE iterateConcatMapBFSRev #-}
725+{-# INLINE concatIterateBfsRev #-}
726−iterateConcatMapBFSRev :: Monad m =>
726+concatIterateBfsRev :: Monad m =>
727 (a -> Maybe (Stream m a))
727 (a -> Maybe (Stream m a))
728 -> Stream m a
728 -> Stream m a
729 -> Stream m a
729 -> Stream m a
730−iterateConcatMapBFSRev f stream =
730+concatIterateBfsRev f stream =
731 fromStreamD
731 fromStreamD
732− $ D.iterateConcatMapBFSRev (fmap toStreamD . f ) (toStreamD stream)
732+ $ D.concatIterateBfsRev (fmap toStreamD . f ) (toStreamD stream)
734−-- | Like 'iterateConcatMapWith' but uses the pairwise flattening combinator
734+-- | Like 'concatIterateWith' but uses the pairwise flattening combinator
735-- 'mergeMapWith' for flattening the resulting streams. This can be used for a
735-- 'mergeMapWith' for flattening the resulting streams. This can be used for a
736-- balanced traversal of a tree like structure.
736-- balanced traversal of a tree like structure.
@@ -739,19 +739,19 @@ iterateConcatMapBFSRev f stream =
740-- >>> f = either Dir.readEitherPaths (const Stream.nil)
740-- >>> f = either Dir.readEitherPaths (const Stream.nil)
741-- >>> input = Stream.fromPure (Left ".")
741-- >>> input = Stream.fromPure (Left ".")
742−-- >>> ls = Stream.iterateMergeMapWith Stream.interleave f input
742+-- >>> ls = Stream.mergeIterateWith Stream.interleave f input
746-- /Pre-release/
746-- /Pre-release/
748−{-# INLINE iterateMergeMapWith #-}
748+{-# INLINE mergeIterateWith #-}
749−iterateMergeMapWith ::
749+mergeIterateWith ::
750 (Stream m a -> Stream m a -> Stream m a)
750 (Stream m a -> Stream m a -> Stream m a)
751 -> (a -> Stream m a)
751 -> (a -> Stream m a)
752 -> Stream m a
752 -> Stream m a
753 -> Stream m a
753 -> Stream m a
754−iterateMergeMapWith combine f = iterateStream
754+mergeIterateWith combine f = iterateStream
@@ -759,34 +759,34 @@ iterateMergeMapWith combine f = iterateStream
760 generate x = x `cons` iterateStream (f x)
760 generate x = x `cons` iterateStream (f x)
762−-- | Same as @iterateConcatMapDFS@ but more efficient due to stream fusion.
762+-- | Same as @concatIterateDfs@ but more efficient due to stream fusion.
764-- Example, list a directory tree using DFS:
764-- Example, list a directory tree using DFS:
766-- >>> f = Unfold.either Dir.eitherReaderPaths Unfold.nil
766-- >>> f = Unfold.either Dir.eitherReaderPaths Unfold.nil
767-- >>> input = Stream.fromPure (Left ".")
767-- >>> input = Stream.fromPure (Left ".")
768−-- >>> ls = Stream.iterateUnfoldManyDFS f input
768+-- >>> ls = Stream.unfoldIterateDfs f input
770-- /Pre-release/
770-- /Pre-release/
771−{-# INLINE iterateUnfoldManyDFS #-}
771+{-# INLINE unfoldIterateDfs #-}
772−iterateUnfoldManyDFS :: Monad m => Unfold m a a -> Stream m a -> Stream m a
772+unfoldIterateDfs :: Monad m => Unfold m a a -> Stream m a -> Stream m a
773−iterateUnfoldManyDFS u = fromStreamD . D.iterateUnfoldManyDFS u . toStreamD
773+unfoldIterateDfs u = fromStreamD . D.unfoldIterateDfs u . toStreamD
775−-- | Like 'iterateUnfoldManyDFS' but uses breadth first style traversal.
775+-- | Like 'unfoldIterateDfs' but uses breadth first style traversal.
777-- /Pre-release/
777-- /Pre-release/
778−{-# INLINE iterateUnfoldManyBFS #-}
778+{-# INLINE unfoldIterateBfs #-}
779−iterateUnfoldManyBFS :: Monad m => Unfold m a a -> Stream m a -> Stream m a
779+unfoldIterateBfs :: Monad m => Unfold m a a -> Stream m a -> Stream m a
780−iterateUnfoldManyBFS u = fromStreamD . D.iterateUnfoldManyBFS u . toStreamD
780+unfoldIterateBfs u = fromStreamD . D.unfoldIterateBfs u . toStreamD
782−-- | Like 'iterateUnfoldManyBFS' but processes the children in reverse order,
782+-- | Like 'unfoldIterateBfs' but processes the children in reverse order,
783-- therefore, may be slightly faster.
783-- therefore, may be slightly faster.
785-- /Pre-release/
785-- /Pre-release/
786−{-# INLINE iterateUnfoldManyBFSRev #-}
786+{-# INLINE unfoldIterateBfsRev #-}
787−iterateUnfoldManyBFSRev :: Monad m => Unfold m a a -> Stream m a -> Stream m a
787+unfoldIterateBfsRev :: Monad m => Unfold m a a -> Stream m a -> Stream m a
788−iterateUnfoldManyBFSRev u =
788+unfoldIterateBfsRev u =
789− fromStreamD . D.iterateUnfoldManyBFSRev u . toStreamD
789+ fromStreamD . D.unfoldIterateBfsRev u . toStreamD
791------------------------------------------------------------------------------
791------------------------------------------------------------------------------
792-- Flattening Graphs
792-- Flattening Graphs
@@ -807,15 +807,15 @@ iterateUnfoldManyBFSRev u =
808-- /Pre-release/
808-- /Pre-release/
810−{-# INLINE iterateConcatScanWith #-}
810+{-# INLINE concatIterateScanWith #-}
811−iterateConcatScanWith
811+concatIterateScanWith
812 :: Monad m
812 :: Monad m
813 => (Stream m a -> Stream m a -> Stream m a)
813 => (Stream m a -> Stream m a -> Stream m a)
814 -> (b -> a -> m (b, Stream m a))
814 -> (b -> a -> m (b, Stream m a))
816 -> Stream m a
816 -> Stream m a
817 -> Stream m a
817 -> Stream m a
818−iterateConcatScanWith combine f initial stream =
818+concatIterateScanWith combine f initial stream =
819 concatEffect $ do
819 concatEffect $ do
820 b <- initial
820 b <- initial
821 iterateStream (b, stream)
821 iterateStream (b, stream)
@@ -835,16 +835,16 @@ iterateConcatScanWith combine f initial stream =
835-- stream and keep building a buffered list/stream, once done we can then
835-- stream and keep building a buffered list/stream, once done we can then
836-- process the buffered stream.
836-- process the buffered stream.
838−{-# INLINE iterateConcatScan #-}
838+{-# INLINE concatIterateScan #-}
839−iterateConcatScan
839+concatIterateScan
840 :: Monad m
840 :: Monad m
841 => (b -> a -> m b)
841 => (b -> a -> m b)
842 -> (b -> m (Maybe (b, Stream m a)))
842 -> (b -> m (Maybe (b, Stream m a)))
844 -> Stream m a
844 -> Stream m a
845−iterateConcatScan scanner generate initial =
845+concatIterateScan scanner generate initial =
846 fromStreamD
846 fromStreamD
847− $ D.iterateConcatScan
847+ $ D.concatIterateScan
848 scanner (fmap (fmap (fmap toStreamD)) . generate) initial
848 scanner (fmap (fmap (fmap toStreamD)) . generate) initial
850------------------------------------------------------------------------------
850------------------------------------------------------------------------------
@@ -871,23 +871,23 @@ concatMapEitherWith = undefined
871-- This API should perhaps be removed in favor of those.
871-- This API should perhaps be removed in favor of those.
873-- | In an 'Either' stream iterate on 'Left's. This is a special case of
873-- | In an 'Either' stream iterate on 'Left's. This is a special case of
874−-- 'iterateConcatMapWith':
874+-- 'concatIterateWith':
876−-- >>> iterateLeftsConcatMapWith combine f = Stream.iterateConcatMapWith combine (either f (const Stream.nil))
876+-- >>> concatIterateLeftsWith combine f = Stream.concatIterateWith combine (either f (const Stream.nil))
878-- To traverse a directory tree:
878-- To traverse a directory tree:
880-- >>> input = Stream.fromPure (Left ".")
880-- >>> input = Stream.fromPure (Left ".")
881−-- >>> ls = Stream.iterateLeftsConcatMapWith Stream.append Dir.readEither input
881+-- >>> ls = Stream.concatIterateLeftsWith Stream.append Dir.readEither input
883-- /Pre-release/
883-- /Pre-release/
885−{-# INLINE iterateLeftsConcatMapWith #-}
885+{-# INLINE concatIterateLeftsWith #-}
886−iterateLeftsConcatMapWith
886+concatIterateLeftsWith
887 :: (b ~ Either a c)
887 :: (b ~ Either a c)
888 => (Stream m b -> Stream m b -> Stream m b)
888 => (Stream m b -> Stream m b -> Stream m b)
889 -> (a -> Stream m b)
889 -> (a -> Stream m b)
890 -> Stream m b
890 -> Stream m b
891 -> Stream m b
891 -> Stream m b
892−iterateLeftsConcatMapWith combine f =
892+concatIterateLeftsWith combine f =
893− iterateConcatMapWith combine (either f (const nil))
893+ concatIterateWith combine (either f (const nil))