@@ -120,21 +120,21 @@ module Streamly.Internal.Data.Stream.Expand
120120
121121 -- * Iterate
122122 -- | Map and flatten Trees of Streams
123− , iterateUnfoldManyDFS
124− , iterateUnfoldManyBFS
125− , iterateUnfoldManyBFSRev
123+ , unfoldIterateDfs
124+ , unfoldIterateBfs
125+ , unfoldIterateBfsRev
126126
127− , iterateConcatMapWith
128− , iterateMergeMapWith
127+ , concatIterateWith
128+ , mergeIterateWith
129129
130− , iterateConcatMapDFS
131− , iterateConcatMapBFS
130+ , concatIterateDfs
131+ , concatIterateBfs
132132
133133 -- More experimental ops
134− , iterateConcatMapBFSRev
135− , iterateLeftsConcatMapWith
136− , iterateConcatScanWith
137− , iterateConcatScan
134+ , concatIterateBfsRev
135+ , concatIterateLeftsWith
136+ , concatIterateScanWith
137+ , concatIterateScan
138138 )
139139where
140140
@@ -639,7 +639,7 @@ mergeMapWith par f m =
639639 (toStreamK m)
640640
641641------------------------------------------------------------------------------
642−-- iterateConcatMap - Map and flatten Trees of Streams
642+-- concatIterate - Map and flatten Trees of Streams
643643------------------------------------------------------------------------------
644644
645645-- | Yield an input element in the output stream, map a stream generator on it
@@ -651,23 +651,23 @@ mergeMapWith par f m =
651651--
652652-- >>> f = either Dir.readEitherPaths (const Stream.nil)
653653-- >>> input = Stream.fromPure (Left ".")
654−-- >>> ls = Stream.iterateConcatMapWith Stream.append f input
654+-- >>> ls = Stream.concatIterateWith Stream.append f input
655655--
656−-- Note that 'iterateM' is a special case of 'iterateConcatMapWith':
656+-- Note that 'iterateM' is a special case of 'concatIterateWith':
657657--
658−-- >>> iterateM f = Stream.iterateConcatMapWith Stream.append (Stream.fromEffect . f) . Stream.fromEffect
658+-- >>> iterateM f = Stream.concatIterateWith Stream.append (Stream.fromEffect . f) . Stream.fromEffect
659659--
660660-- /CPS/
661661--
662662-- /Pre-release/
663663--
664−{-# INLINE iterateConcatMapWith #-}
665−iterateConcatMapWith ::
664+{-# INLINE concatIterateWith #-}
665+concatIterateWith ::
666666 (Stream m a -> Stream m a -> Stream m a)
667667 -> (a -> Stream m a)
668668 -> Stream m a
669669 -> Stream m a
670−iterateConcatMapWith combine f = iterateStream
670+concatIterateWith combine f = iterateStream
671671
672672 where
673673
@@ -683,21 +683,21 @@ iterateConcatMapWith combine f = iterateStream
683683--
684684-- >>> f = either (Just . Dir.readEitherPaths) (const Nothing)
685685-- >>> input = Stream.fromPure (Left ".")
686−-- >>> ls = Stream.iterateConcatMapDFS f input
686+-- >>> ls = Stream.concatIterateDfs f input
687687--
688−-- This is equivalent to using @iterateConcatMapWith Stream.append@.
688+-- This is equivalent to using @concatIterateWith Stream.append@.
689689--
690690-- /Pre-release/
691−{-# INLINE iterateConcatMapDFS #-}
692−iterateConcatMapDFS :: Monad m =>
691+{-# INLINE concatIterateDfs #-}
692+concatIterateDfs :: Monad m =>
693693 (a -> Maybe (Stream m a))
694694 -> Stream m a
695695 -> Stream m a
696−iterateConcatMapDFS f stream =
696+concatIterateDfs f stream =
697697 fromStreamD
698− $ D.iterateConcatMapDFS (fmap toStreamD . f ) (toStreamD stream)
698+ $ D.concatIterateDfs (fmap toStreamD . f ) (toStreamD stream)
699699
700−-- | Similar to 'iterateConcatMapDFS' except that it traverses the stream in
700+-- | Similar to 'concatIterateDfs' except that it traverses the stream in
701701-- breadth first style (BFS). First, all the elements in the input stream are
702702-- emitted, and then their traversals are emitted.
703703--
@@ -705,33 +705,33 @@ iterateConcatMapDFS f stream =
705705--
706706-- >>> f = either (Just . Dir.readEitherPaths) (const Nothing)
707707-- >>> input = Stream.fromPure (Left ".")
708−-- >>> ls = Stream.iterateConcatMapBFS f input
708+-- >>> ls = Stream.concatIterateBfs f input
709709--
710710-- /Pre-release/
711−{-# INLINE iterateConcatMapBFS #-}
712−iterateConcatMapBFS :: Monad m =>
711+{-# INLINE concatIterateBfs #-}
712+concatIterateBfs :: Monad m =>
713713 (a -> Maybe (Stream m a))
714714 -> Stream m a
715715 -> Stream m a
716−iterateConcatMapBFS f stream =
716+concatIterateBfs f stream =
717717 fromStreamD
718− $ D.iterateConcatMapBFS (fmap toStreamD . f ) (toStreamD stream)
718+ $ D.concatIterateBfs (fmap toStreamD . f ) (toStreamD stream)
719719
720−-- | Same as 'iterateConcatMapBFS' except that the traversal of the last
720+-- | Same as 'concatIterateBfs' except that the traversal of the last
721721-- element on a level is emitted first and then going backwards up to the first
722722-- element (reversed ordering). This may be slightly faster than
723−-- 'iterateConcatMapBFS'.
723+-- 'concatIterateBfs'.
724724--
725−{-# INLINE iterateConcatMapBFSRev #-}
726−iterateConcatMapBFSRev :: Monad m =>
725+{-# INLINE concatIterateBfsRev #-}
726+concatIterateBfsRev :: Monad m =>
727727 (a -> Maybe (Stream m a))
728728 -> Stream m a
729729 -> Stream m a
730−iterateConcatMapBFSRev f stream =
730+concatIterateBfsRev f stream =
731731 fromStreamD
732− $ D.iterateConcatMapBFSRev (fmap toStreamD . f ) (toStreamD stream)
732+ $ D.concatIterateBfsRev (fmap toStreamD . f ) (toStreamD stream)
733733
734−-- | Like 'iterateConcatMapWith' but uses the pairwise flattening combinator
734+-- | Like 'concatIterateWith' but uses the pairwise flattening combinator
735735-- 'mergeMapWith' for flattening the resulting streams. This can be used for a
736736-- balanced traversal of a tree like structure.
737737--
@@ -739,19 +739,19 @@ iterateConcatMapBFSRev f stream =
739739--
740740-- >>> f = either Dir.readEitherPaths (const Stream.nil)
741741-- >>> input = Stream.fromPure (Left ".")
742−-- >>> ls = Stream.iterateMergeMapWith Stream.interleave f input
742+-- >>> ls = Stream.mergeIterateWith Stream.interleave f input
743743--
744744-- /CPS/
745745--
746746-- /Pre-release/
747747--
748−{-# INLINE iterateMergeMapWith #-}
749−iterateMergeMapWith ::
748+{-# INLINE mergeIterateWith #-}
749+mergeIterateWith ::
750750 (Stream m a -> Stream m a -> Stream m a)
751751 -> (a -> Stream m a)
752752 -> Stream m a
753753 -> Stream m a
754−iterateMergeMapWith combine f = iterateStream
754+mergeIterateWith combine f = iterateStream
755755
756756 where
757757
@@ -759,34 +759,34 @@ iterateMergeMapWith combine f = iterateStream
759759
760760 generate x = x `cons` iterateStream (f x)
761761
762−-- | Same as @iterateConcatMapDFS@ but more efficient due to stream fusion.
762+-- | Same as @concatIterateDfs@ but more efficient due to stream fusion.
763763--
764764-- Example, list a directory tree using DFS:
765765--
766766-- >>> f = Unfold.either Dir.eitherReaderPaths Unfold.nil
767767-- >>> input = Stream.fromPure (Left ".")
768−-- >>> ls = Stream.iterateUnfoldManyDFS f input
768+-- >>> ls = Stream.unfoldIterateDfs f input
769769--
770770-- /Pre-release/
771−{-# INLINE iterateUnfoldManyDFS #-}
772−iterateUnfoldManyDFS :: Monad m => Unfold m a a -> Stream m a -> Stream m a
773−iterateUnfoldManyDFS u = fromStreamD . D.iterateUnfoldManyDFS u . toStreamD
771+{-# INLINE unfoldIterateDfs #-}
772+unfoldIterateDfs :: Monad m => Unfold m a a -> Stream m a -> Stream m a
773+unfoldIterateDfs u = fromStreamD . D.unfoldIterateDfs u . toStreamD
774774
775−-- | Like 'iterateUnfoldManyDFS' but uses breadth first style traversal.
775+-- | Like 'unfoldIterateDfs' but uses breadth first style traversal.
776776--
777777-- /Pre-release/
778−{-# INLINE iterateUnfoldManyBFS #-}
779−iterateUnfoldManyBFS :: Monad m => Unfold m a a -> Stream m a -> Stream m a
780−iterateUnfoldManyBFS u = fromStreamD . D.iterateUnfoldManyBFS u . toStreamD
778+{-# INLINE unfoldIterateBfs #-}
779+unfoldIterateBfs :: Monad m => Unfold m a a -> Stream m a -> Stream m a
780+unfoldIterateBfs u = fromStreamD . D.unfoldIterateBfs u . toStreamD
781781
782−-- | Like 'iterateUnfoldManyBFS' but processes the children in reverse order,
782+-- | Like 'unfoldIterateBfs' but processes the children in reverse order,
783783-- therefore, may be slightly faster.
784784--
785785-- /Pre-release/
786−{-# INLINE iterateUnfoldManyBFSRev #-}
787−iterateUnfoldManyBFSRev :: Monad m => Unfold m a a -> Stream m a -> Stream m a
788−iterateUnfoldManyBFSRev u =
789− fromStreamD . D.iterateUnfoldManyBFSRev u . toStreamD
786+{-# INLINE unfoldIterateBfsRev #-}
787+unfoldIterateBfsRev :: Monad m => Unfold m a a -> Stream m a -> Stream m a
788+unfoldIterateBfsRev u =
789+ fromStreamD . D.unfoldIterateBfsRev u . toStreamD
790790
791791------------------------------------------------------------------------------
792792-- Flattening Graphs
@@ -807,15 +807,15 @@ iterateUnfoldManyBFSRev u =
807807--
808808-- /Pre-release/
809809--
810−{-# INLINE iterateConcatScanWith #-}
811−iterateConcatScanWith
810+{-# INLINE concatIterateScanWith #-}
811+concatIterateScanWith
812812 :: Monad m
813813 => (Stream m a -> Stream m a -> Stream m a)
814814 -> (b -> a -> m (b, Stream m a))
815815 -> m b
816816 -> Stream m a
817817 -> Stream m a
818−iterateConcatScanWith combine f initial stream =
818+concatIterateScanWith combine f initial stream =
819819 concatEffect $ do
820820 b <- initial
821821 iterateStream (b, stream)
@@ -835,16 +835,16 @@ iterateConcatScanWith combine f initial stream =
835835-- stream and keep building a buffered list/stream, once done we can then
836836-- process the buffered stream.
837837
838−{-# INLINE iterateConcatScan #-}
839−iterateConcatScan
838+{-# INLINE concatIterateScan #-}
839+concatIterateScan
840840 :: Monad m
841841 => (b -> a -> m b)
842842 -> (b -> m (Maybe (b, Stream m a)))
843843 -> b
844844 -> Stream m a
845−iterateConcatScan scanner generate initial =
845+concatIterateScan scanner generate initial =
846846 fromStreamD
847− $ D.iterateConcatScan
847+ $ D.concatIterateScan
848848 scanner (fmap (fmap (fmap toStreamD)) . generate) initial
849849
850850------------------------------------------------------------------------------
@@ -871,23 +871,23 @@ concatMapEitherWith = undefined
871871-- This API should perhaps be removed in favor of those.
872872
873873-- | In an 'Either' stream iterate on 'Left's. This is a special case of
874−-- 'iterateConcatMapWith':
874+-- 'concatIterateWith':
875875--
876−-- >>> iterateLeftsConcatMapWith combine f = Stream.iterateConcatMapWith combine (either f (const Stream.nil))
876+-- >>> concatIterateLeftsWith combine f = Stream.concatIterateWith combine (either f (const Stream.nil))
877877--
878878-- To traverse a directory tree:
879879--
880880-- >>> input = Stream.fromPure (Left ".")
881−-- >>> ls = Stream.iterateLeftsConcatMapWith Stream.append Dir.readEither input
881+-- >>> ls = Stream.concatIterateLeftsWith Stream.append Dir.readEither input
882882--
883883-- /Pre-release/
884884--
885−{-# INLINE iterateLeftsConcatMapWith #-}
886−iterateLeftsConcatMapWith
885+{-# INLINE concatIterateLeftsWith #-}
886+concatIterateLeftsWith
887887 :: (b ~ Either a c)
888888 => (Stream m b -> Stream m b -> Stream m b)
889889 -> (a -> Stream m b)
890890 -> Stream m b
891891 -> Stream m b
892−iterateLeftsConcatMapWith combine f =
893− iterateConcatMapWith combine (either f (const nil))
892+concatIterateLeftsWith combine f =
893+ concatIterateWith combine (either f (const nil))