on master help sign in
Hold the foldWith etc. move to Prelude
75b0bacHarendra Kumar
Changelog.md−2
@@ -34,8 +34,6 @@
34
34
35* In `Streamly` module:
35* In `Streamly` module:
36 * `runStream` has been deprecated, please use `Streamly.Prelude.drain`
36 * `runStream` has been deprecated, please use `Streamly.Prelude.drain`
37− * `foldWith`, `foldMapWith`, `forEachWith` have been moved to
38− `Streamly.Prelude` module.
39
37
40* Remove deprecated module `Streamly.Time` (moved to Streamly.Internal.Data.Time)
38* Remove deprecated module `Streamly.Time` (moved to Streamly.Internal.Data.Time)
41* Remove module `Streamly.Internal` (functionality moved to the Internal hierarchy)
39* Remove module `Streamly.Internal` (functionality moved to the Internal hierarchy)
src/Streamly.hs+15
@@ -180,6 +180,16 @@ module Streamly
180 , ZipSerial
180 , ZipSerial
181 , ZipAsync
181 , ZipAsync
182
182
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+
183 -- * Re-exports
193 -- * Re-exports
184 , Semigroup (..)
194 , Semigroup (..)
185
195
@@ -202,11 +212,13 @@ module Streamly
202 , (<=>)
212 , (<=>)
203 , (<|)
213 , (<|)
204
214
215+ {-
205 -- * Deprecated/Moved
216 -- * Deprecated/Moved
206 -- | These APIs have been moved to other modules
217 -- | These APIs have been moved to other modules
207 , foldWith
218 , foldWith
208 , foldMapWith
219 , foldMapWith
209 , forEachWith
220 , forEachWith
221+ -}
210 )
222 )
211where
223where
212
224
@@ -221,6 +233,7 @@ import Streamly.Streams.StreamK hiding (serial)
221import Streamly.Streams.Zip
233import Streamly.Streams.Zip
222
234
223import qualified Streamly.Prelude as P
235import qualified Streamly.Prelude as P
236+import qualified Streamly.Internal.Prelude as IP
224import qualified Streamly.Streams.StreamK as K
237import qualified Streamly.Streams.StreamK as K
225
238
226-- XXX provide good succinct examples of pipelining, merging, splitting ect.
239-- XXX provide good succinct examples of pipelining, merging, splitting ect.
@@ -412,6 +425,7 @@ runZipStream = P.drain . K.adapt
412runZipAsync :: Monad m => ZipAsyncM m a -> m ()
425runZipAsync :: Monad m => ZipAsyncM m a -> m ()
413runZipAsync = P.drain . K.adapt
426runZipAsync = P.drain . K.adapt
414
427
428+{-
415-- | Same as "Streamly.Prelude.foldWith".
429-- | Same as "Streamly.Prelude.foldWith".
416--
430--
417{-# DEPRECATED foldWith "Please use Streamly.Prelude.foldWith instead." #-}
431{-# DEPRECATED foldWith "Please use Streamly.Prelude.foldWith instead." #-}
@@ -435,6 +449,7 @@ foldMapWith = P.foldMapWith
435forEachWith :: (IsStream t, Foldable f)
449forEachWith :: (IsStream t, Foldable f)
436 => (t m b -> t m b -> t m b) -> f a -> (a -> t m b) -> t m b
450 => (t m b -> t m b -> t m b) -> f a -> (a -> t m b) -> t m b
437forEachWith = P.forEachWith
451forEachWith = P.forEachWith
452+-}
438
453
439------------------------------------------------------------------------------
454------------------------------------------------------------------------------
440-- Documentation
455-- Documentation
src/Streamly/Benchmark/Prelude.hs+1−1
@@ -44,7 +44,7 @@ import Test.Inspection
44import qualified Streamly.Streams.StreamD as D
44import qualified Streamly.Streams.StreamD as D
45#endif
45#endif
46
46
47−import qualified Streamly as S hiding (foldMapWith, runStream)
47+import qualified Streamly as S hiding (runStream)
48import qualified Streamly.Prelude as S
48import qualified Streamly.Prelude as S
49import qualified Streamly.Internal.Prelude as Internal
49import qualified Streamly.Internal.Prelude as Internal
50import qualified Streamly.Internal.Data.Unfold as UF
50import qualified Streamly.Internal.Data.Unfold as UF
src/Streamly/Prelude.hs+2
@@ -624,6 +624,7 @@ module Streamly.Prelude
624 , zipAsyncWith
624 , zipAsyncWith
625 , zipAsyncWithM
625 , zipAsyncWithM
626
626
627+ {-
627 -- ** Folding Containers of Streams
628 -- ** Folding Containers of Streams
628 -- | These are variants of standard 'Foldable' fold functions that use a
629 -- | These are variants of standard 'Foldable' fold functions that use a
629 -- polymorphic stream sum operation (e.g. 'async' or 'wSerial') to fold a
630 -- polymorphic stream sum operation (e.g. 'async' or 'wSerial') to fold a
@@ -633,6 +634,7 @@ module Streamly.Prelude
633 , foldMapWith
634 , foldMapWith
634 , forEachWith
635 , forEachWith
635 , foldWith
636 , foldWith
637+ -}
636
638
637 -- ** Folding Streams of Streams
639 -- ** Folding Streams of Streams
638 -- | Stream operations like map and filter represent loop processing in
640 -- | Stream operations like map and filter represent loop processing in
src/Streamly/Streams/Prelude.hs+6−6
@@ -270,6 +270,8 @@ foldbWith :: IsStream t
270foldbWith f = K.foldb f K.nil
270foldbWith f = K.foldb f K.nil
271-}
271-}
272
272
273+-- /Since: 0.7.0 ("Streamly.Prelude")/
274+--
273-- | A variant of 'Data.Foldable.fold' that allows you to fold a 'Foldable'
275-- | A variant of 'Data.Foldable.fold' that allows you to fold a 'Foldable'
274-- container of streams using the specified stream sum operation.
276-- container of streams using the specified stream sum operation.
275--
277--
@@ -281,14 +283,14 @@ foldbWith f = K.foldb f K.nil
281-- foldWith f = S.foldMapWith f id
283-- foldWith f = S.foldMapWith f id
282-- @
284-- @
283--
285--
284−-- /Since: 0.7.0 ("Streamly.Prelude")/
285−--
286-- /Since: 0.1.0 ("Streamly")/
286-- /Since: 0.1.0 ("Streamly")/
287{-# INLINABLE foldWith #-}
287{-# INLINABLE foldWith #-}
288foldWith :: (IsStream t, Foldable f)
288foldWith :: (IsStream t, Foldable f)
289 => (t m a -> t m a -> t m a) -> f (t m a) -> t m a
289 => (t m a -> t m a -> t m a) -> f (t m a) -> t m a
290foldWith f = Prelude.foldr f K.nil
290foldWith f = Prelude.foldr f K.nil
291
291
292+-- /Since: 0.7.0 ("Streamly.Prelude")/
293+--
292-- | A variant of 'foldMap' that allows you to map a monadic streaming action
294-- | A variant of 'foldMap' that allows you to map a monadic streaming action
293-- on a 'Foldable' container and then fold it using the specified stream merge
295-- on a 'Foldable' container and then fold it using the specified stream merge
294-- operation.
296-- operation.
@@ -301,14 +303,14 @@ foldWith f = Prelude.foldr f K.nil
301-- foldMapWith f g xs = S.concatMapWith f g (S.fromFoldable xs)
303-- foldMapWith f g xs = S.concatMapWith f g (S.fromFoldable xs)
302-- @
304-- @
303--
305--
304−-- /Since: 0.7.0 ("Streamly.Prelude")/
305−--
306-- /Since: 0.1.0 ("Streamly")/
306-- /Since: 0.1.0 ("Streamly")/
307{-# INLINABLE foldMapWith #-}
307{-# INLINABLE foldMapWith #-}
308foldMapWith :: (IsStream t, Foldable f)
308foldMapWith :: (IsStream t, Foldable f)
309 => (t m b -> t m b -> t m b) -> (a -> t m b) -> f a -> t m b
309 => (t m b -> t m b -> t m b) -> (a -> t m b) -> f a -> t m b
310foldMapWith f g = Prelude.foldr (f . g) K.nil
310foldMapWith f g = Prelude.foldr (f . g) K.nil
311
311
312+-- /Since: 0.7.0 ("Streamly.Prelude")/
313+--
312-- | Like 'foldMapWith' but with the last two arguments reversed i.e. the
314-- | Like 'foldMapWith' but with the last two arguments reversed i.e. the
313-- monadic streaming function is the last argument.
315-- monadic streaming function is the last argument.
314--
316--
@@ -318,8 +320,6 @@ foldMapWith f g = Prelude.foldr (f . g) K.nil
318-- forEachWith = flip S.foldMapWith
320-- forEachWith = flip S.foldMapWith
319-- @
321-- @
320--
322--
321−-- /Since: 0.7.0 ("Streamly.Prelude")/
322−--
323-- /Since: 0.1.0 ("Streamly")/
323-- /Since: 0.1.0 ("Streamly")/
324{-# INLINABLE forEachWith #-}
324{-# INLINABLE forEachWith #-}
325forEachWith :: (IsStream t, Foldable f)
325forEachWith :: (IsStream t, Foldable f)
test/Main.hs+1
@@ -22,6 +22,7 @@ import Test.Hspec as H
22
22
23import Streamly
23import Streamly
24import Streamly.Prelude ((.:), nil)
24import Streamly.Prelude ((.:), nil)
25+import qualified Streamly as S
25import qualified Streamly.Prelude as S
26import qualified Streamly.Prelude as S
26import qualified Streamly.Internal.Prelude as IP
27import qualified Streamly.Internal.Prelude as IP
27
28
test/Prop.hs+1
@@ -31,6 +31,7 @@ import Test.Hspec as H
31
31
32import Streamly
32import Streamly
33import Streamly.Prelude ((.:), nil)
33import Streamly.Prelude ((.:), nil)
34+import Streamly as S
34import qualified Streamly.Prelude as S
35import qualified Streamly.Prelude as S
35import qualified Streamly.Data.Fold as FL
36import qualified Streamly.Data.Fold as FL
36
37