@@ -22,7 +22,7 @@ module Streamly.Internal.Data.Stream.Expand
2222 -- complexity (instead O(n^2) for pair wise combinators described in the
2323 -- next section. These functions can be used efficiently with
2424 -- 'concatMapWith' et. al. combinators that combine streams in a linear
25− -- fashion (contrast with 'concatPairsWith' which combines streams as a
25+ -- fashion (contrast with 'mergeMapWith' which combines streams as a
2626 -- binary tree).
2727
2828 append
@@ -30,7 +30,7 @@ module Streamly.Internal.Data.Stream.Expand
3030 -- | Like the functions in the section above these functions also combine
3131 -- two streams into a single stream but when used @n@ times linearly they
3232 -- exhibit O(n^2) complexity. They are best combined in a binary tree
33− -- fashion using 'concatPairsWith' giving a @n * log n@ complexity. Avoid
33+ -- fashion using 'mergeMapWith' giving a @n * log n@ complexity. Avoid
3434 -- using these with 'concatMapWith' when combining a large or infinite
3535 -- number of streams.
3636
@@ -104,7 +104,7 @@ module Streamly.Internal.Data.Stream.Expand
104104 -- simultaneously anyway.
105105 --
106106 -- However, in cases where the merging consumes streams in a round robin
107− -- fashion, a pair wise merging using 'concatPairsWith' would be more
107+ -- fashion, a pair wise merging using 'mergeMapWith' would be more
108108 -- efficient. These cases include operations like 'mergeBy' or 'zipWith'.
109109
110110 , concatMapWith
@@ -114,7 +114,7 @@ module Streamly.Internal.Data.Stream.Expand
114114 -- * ConcatPairsWith
115115 -- | See the notes about suitable merge functions in the 'concatMapWith'
116116 -- section.
117− , concatPairsWith
117+ , mergeMapWith
118118
119119 -- * IterateMap
120120 -- | Map and flatten Trees of Streams
@@ -165,7 +165,7 @@ infixr 6 `append2`
165165-- 'append' when combining two fusible streams. However, it slows down
166166-- quadratically with the number of streams being appended. Therefore, it is
167167-- suitable for ad-hoc append of a few streams, and should not be used with
168−-- 'concatMapWith' or 'concatPairsWith'.
168+-- 'concatMapWith' or 'mergeMapWith'.
169169--
170170-- /Fused/
171171--
@@ -360,7 +360,7 @@ mergeByM f m1 m2 = fromStreamK $ K.mergeByM f (toStreamK m1) (toStreamK m2)
360360-- | Like 'mergeByM' but much faster, works best when merging statically known
361361-- number of streams. When merging more than two streams try to merge pairs and
362362-- pair of pairs in a tree like structure.'mergeByM' works better with variable
363−-- number of streams being merged using 'concatPairsWith'.
363+-- number of streams being merged using 'mergeMapWith'.
364364--
365365-- /Internal/
366366{-# INLINE mergeByM2 #-}
@@ -400,7 +400,7 @@ mergeFstBy _f _m1 _m2 = undefined
400400unfoldMany ::Monad m => Unfold m a b -> Stream m a -> Stream m b
401401unfoldMany u m = fromStreamD $ D.unfoldMany u (toStreamD m)
402402
403−-- | This does not pair streams like concatPairsWith, instead, it goes through
403+-- | This does not pair streams like mergeMapWith, instead, it goes through
404404-- each stream one by one and yields one element from each stream. After it
405405-- goes to the last stream it reverses the traversal to come back to the first
406406-- stream yielding elements from each stream on its way back to the first
@@ -411,7 +411,7 @@ unfoldMany u m = fromStreamD $ D.unfoldMany u (toStreamD m)
411411-- >>> Stream.fold Fold.toList interleaved
412412-- [1,2,3,4,5,5,4,3,2,1]
413413--
414−-- Note that this is order of magnitude more efficient than "concatPairsWith
414+-- Note that this is order of magnitude more efficient than "mergeMapWith
415415-- wSerial" because of fusion.
416416--
417417-- /Fused/
@@ -581,24 +581,24 @@ concatSmapMWith combine f initial =
581581-- >>> s = Stream.fromList [5,1,7,9,2]
582582-- >>> generate = Stream.fromPure
583583-- >>> combine = Stream.mergeBy compare
584−-- >>> Stream.fold Fold.toList $ Stream.concatPairsWith combine generate s
584+-- >>> Stream.fold Fold.toList $ Stream.mergeMapWith combine generate s
585585-- [1,2,5,7,9]
586586--
587587-- Note that if the stream length is not a power of 2, the binary tree composed
588−-- by concatPairsWith would not be balanced, which may or may not be important
588+-- by mergeMapWith would not be balanced, which may or may not be important
589589-- depending on what you are trying to achieve.
590590--
591591-- /Caution: the stream of streams must be finite/
592592--
593593-- /Pre-release/
594594--
595−{-# INLINE concatPairsWith #-}
596−concatPairsWith ::
595+{-# INLINE mergeMapWith #-}
596+mergeMapWith ::
597597 (Stream m b -> Stream m b -> Stream m b)
598598 -> (a -> Stream m b)
599599 -> Stream m a
600600 -> Stream m b
601−concatPairsWith par f m =
601+mergeMapWith par f m =
602602 fromStreamK
603603 $ K.concatPairsWith
604604 (\s1 s2 -> toStreamK $ fromStreamK s1 `par` fromStreamK s2)