on master help sign in
Hold the foldWith etc. move to Prelude
commit75b0bacc3ed89ca6cf390580a46ff4790808d1a9 authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 15 Nov 2019, 02:02 (7 years ago) parentd1c0103
7 files changed+26−9
Changelog.md−2 src/Streamly.hs+15 src/Streamly/Benchmark/Prelude.hs+1−1 src/Streamly/Prelude.hs+2 src/Streamly/Streams/Prelude.hs+6−6 test/Main.hs+1 test/Prop.hs+1
Changelog.md−2
@@ -34,8 +34,6 @@
3434
3535* In `Streamly` module:
3636 * `runStream` has been deprecated, please use `Streamly.Prelude.drain`
37− * `foldWith`, `foldMapWith`, `forEachWith` have been moved to
38− `Streamly.Prelude` module.
3937
4038* Remove deprecated module `Streamly.Time` (moved to Streamly.Internal.Data.Time)
4139* Remove module `Streamly.Internal` (functionality moved to the Internal hierarchy)
src/Streamly.hs+15
@@ -180,6 +180,16 @@ module Streamly
180180 , ZipSerial
181181 , ZipAsync
182182
183+ -- ** Folding Containers of Streams
184+ -- | These are variants of standard 'Foldable' fold functions that use a
185+ -- polymorphic stream sum operation (e.g. 'async' or 'wSerial') to fold a
186+ -- finite container of streams. Note that these are just special cases of
187+ -- the more general 'concatMapWith' operation.
188+ --
189+ , IP.foldWith
190+ , IP.foldMapWith
191+ , IP.forEachWith
192+
183193 -- * Re-exports
184194 , Semigroup (..)
185195
@@ -202,11 +212,13 @@ module Streamly
202212 , (<=>)
203213 , (<|)
204214
215+ {-
205216 -- * Deprecated/Moved
206217 -- | These APIs have been moved to other modules
207218 , foldWith
208219 , foldMapWith
209220 , forEachWith
221+ -}
210222 )
211223where
212224
@@ -221,6 +233,7 @@ import Streamly.Streams.StreamK hiding (serial)
221233import Streamly.Streams.Zip
222234
223235import qualified Streamly.Prelude as P
236+import qualified Streamly.Internal.Prelude as IP
224237import qualified Streamly.Streams.StreamK as K
225238
226239-- XXX provide good succinct examples of pipelining, merging, splitting ect.
@@ -412,6 +425,7 @@ runZipStream = P.drain . K.adapt
412425runZipAsync :: Monad m => ZipAsyncM m a -> m ()
413426runZipAsync = P.drain . K.adapt
414427
428+{-
415429-- | Same as "Streamly.Prelude.foldWith".
416430--
417431{-# DEPRECATED foldWith "Please use Streamly.Prelude.foldWith instead." #-}
@@ -435,6 +449,7 @@ foldMapWith = P.foldMapWith
435449forEachWith :: (IsStream t, Foldable f)
436450 => (t m b -> t m b -> t m b) -> f a -> (a -> t m b) -> t m b
437451forEachWith = P.forEachWith
452+-}
438453
439454------------------------------------------------------------------------------
440455-- Documentation
src/Streamly/Benchmark/Prelude.hs+1−1
@@ -44,7 +44,7 @@ import Test.Inspection
4444import qualified Streamly.Streams.StreamD as D
4545#endif
4646
47−import qualified Streamly as S hiding (foldMapWith, runStream)
47+import qualified Streamly as S hiding (runStream)
4848import qualified Streamly.Prelude as S
4949import qualified Streamly.Internal.Prelude as Internal
5050import qualified Streamly.Internal.Data.Unfold as UF
src/Streamly/Prelude.hs+2
@@ -624,6 +624,7 @@ module Streamly.Prelude
624624 , zipAsyncWith
625625 , zipAsyncWithM
626626
627+ {-
627628 -- ** Folding Containers of Streams
628629 -- | These are variants of standard 'Foldable' fold functions that use a
629630 -- polymorphic stream sum operation (e.g. 'async' or 'wSerial') to fold a
@@ -633,6 +634,7 @@ module Streamly.Prelude
633634 , foldMapWith
634635 , forEachWith
635636 , foldWith
637+ -}
636638
637639 -- ** Folding Streams of Streams
638640 -- | Stream operations like map and filter represent loop processing in
src/Streamly/Streams/Prelude.hs+6−6
@@ -270,6 +270,8 @@ foldbWith :: IsStream t
270270foldbWith f = K.foldb f K.nil
271271-}
272272
273+-- /Since: 0.7.0 ("Streamly.Prelude")/
274+--
273275-- | A variant of 'Data.Foldable.fold' that allows you to fold a 'Foldable'
274276-- container of streams using the specified stream sum operation.
275277--
@@ -281,14 +283,14 @@ foldbWith f = K.foldb f K.nil
281283-- foldWith f = S.foldMapWith f id
282284-- @
283285--
284−-- /Since: 0.7.0 ("Streamly.Prelude")/
285−--
286286-- /Since: 0.1.0 ("Streamly")/
287287{-# INLINABLE foldWith #-}
288288foldWith :: (IsStream t, Foldable f)
289289 => (t m a -> t m a -> t m a) -> f (t m a) -> t m a
290290foldWith f = Prelude.foldr f K.nil
291291
292+-- /Since: 0.7.0 ("Streamly.Prelude")/
293+--
292294-- | A variant of 'foldMap' that allows you to map a monadic streaming action
293295-- on a 'Foldable' container and then fold it using the specified stream merge
294296-- operation.
@@ -301,14 +303,14 @@ foldWith f = Prelude.foldr f K.nil
301303-- foldMapWith f g xs = S.concatMapWith f g (S.fromFoldable xs)
302304-- @
303305--
304−-- /Since: 0.7.0 ("Streamly.Prelude")/
305−--
306306-- /Since: 0.1.0 ("Streamly")/
307307{-# INLINABLE foldMapWith #-}
308308foldMapWith :: (IsStream t, Foldable f)
309309 => (t m b -> t m b -> t m b) -> (a -> t m b) -> f a -> t m b
310310foldMapWith f g = Prelude.foldr (f . g) K.nil
311311
312+-- /Since: 0.7.0 ("Streamly.Prelude")/
313+--
312314-- | Like 'foldMapWith' but with the last two arguments reversed i.e. the
313315-- monadic streaming function is the last argument.
314316--
@@ -318,8 +320,6 @@ foldMapWith f g = Prelude.foldr (f . g) K.nil
318320-- forEachWith = flip S.foldMapWith
319321-- @
320322--
321−-- /Since: 0.7.0 ("Streamly.Prelude")/
322−--
323323-- /Since: 0.1.0 ("Streamly")/
324324{-# INLINABLE forEachWith #-}
325325forEachWith :: (IsStream t, Foldable f)
test/Main.hs+1
@@ -22,6 +22,7 @@ import Test.Hspec as H
2222
2323import Streamly
2424import Streamly.Prelude ((.:), nil)
25+import qualified Streamly as S
2526import qualified Streamly.Prelude as S
2627import qualified Streamly.Internal.Prelude as IP
2728
test/Prop.hs+1
@@ -31,6 +31,7 @@ import Test.Hspec as H
3131
3232import Streamly
3333import Streamly.Prelude ((.:), nil)
34+import Streamly as S
3435import qualified Streamly.Prelude as S
3536import qualified Streamly.Data.Fold as FL
3637