on master help sign in
rename concatMapBy to concatMapWith

This is consistent with foldMapWith.

commitf21a5b81308a4f6fca0e208619bb3118f2ab061b authorHarendra Kumar <harendra.kumar@gmail.com> dateTue 13 Aug 2019, 15:20 (7 years ago) parent7a3a073
3 files changed+26−6
examples/FileSinkServer.hs+1−1 src/Streamly/Prelude.hs+3−3 src/Streamly/Prelude/Internal.hs+22−2
examples/FileSinkServer.hs+1−1
@@ -24,7 +24,7 @@ main = do
2424 (\src -> S.runFold (FH.write src)
2525 $ encodeChar8Unchecked
2626 $ S.concatMap A.read
27− $ S.concatMapBy parallel (flip NS.withSocketS recv)
27+ $ S.concatMapWith parallel (flip NS.withSocketS recv)
2828 $ NS.connectionsOnAllAddrs 8090)
2929
3030 where
src/Streamly/Prelude.hs+3−3
@@ -627,7 +627,7 @@ module Streamly.Prelude
627627 -- | These are variants of standard 'Foldable' fold functions that use a
628628 -- polymorphic stream sum operation (e.g. 'async' or 'wSerial') to fold a
629629 -- finite container of streams. Note that these are just special cases of
630− -- the more general 'concatMapBy' operation.
630+ -- the more general 'concatMapWith' operation.
631631 --
632632 , foldMapWith
633633 , forEachWith
@@ -657,8 +657,8 @@ module Streamly.Prelude
657657 -- > filter p m = S.concatMap (\x -> if p x then S.yield x else S.nil) m
658658 --
659659
660− -- XXX add stateful concatMapBy
661− , concatMapBy
660+ -- XXX add stateful concatMapWith
661+ , concatMapWith
662662 --, bindWith
663663 , concatMap
664664 , concatMapM
src/Streamly/Prelude/Internal.hs+22−2
@@ -232,7 +232,7 @@ module Streamly.Prelude.Internal
232232 -- ** Nested Streams
233233 , concatMapM
234234 , concatMap
235− , K.concatMapBy
235+ , concatMapWith
236236 -- , interposeBy
237237 -- , intercalate
238238
@@ -2056,11 +2056,31 @@ mergeAsyncByM f m1 m2 = K.mkStream $ \st stp sng yld -> do
20562056-- Nesting
20572057------------------------------------------------------------------------------
20582058
2059+-- | @concatMapWith merge map stream@ is a two dimensional looping combinator.
2060+-- The first argument specifies a merge or concat function that is used to
2061+-- merge the streams generated by applying the second argument i.e. the @map@
2062+-- function to each element of the input stream. The concat function could be
2063+-- 'serial', 'parallel', 'async', 'ahead' or any other zip or merge function
2064+-- and the second argument could be any stream generation function using a
2065+-- seed.
2066+--
2067+-- /Compare 'foldMapWith'/
2068+--
2069+-- @since 0.7.0
2070+{-# INLINE concatMapWith #-}
2071+concatMapWith
2072+ :: IsStream t
2073+ => (forall c. t m c -> t m c -> t m c)
2074+ -> (a -> t m b)
2075+ -> t m a
2076+ -> t m b
2077+concatMapWith = K.concatMapBy
2078+
20592079-- | Map a stream producing function on each element of the stream and then
20602080-- flatten the results into a single stream.
20612081--
20622082-- @
2063−-- concatMap = 'concatMapBy' 'Serial.serial'
2083+-- concatMap = 'concatMapWith' 'Serial.serial'
20642084-- concatMap f = 'concatMapM' (return . f)
20652085-- @
20662086--