on master help sign in
Name parList style combinators more explicitly
commit38c76726374bc4f6f8cfb8c1b13639b23aeebe5c authorHarendra Kumar <harendra@composewell.com> dateFri 13 Jan 2023, 12:00 (4 years ago) parent21c25f8
3 files changed+44−44
src/Streamly/Data/Stream/Concurrent.hs+1−1 src/Streamly/Internal/Data/Stream/Concurrent.hs+40−40 src/Streamly/Internal/Data/Stream/Time.hs+3−3
src/Streamly/Data/Stream/Concurrent.hs+1−1
@@ -78,7 +78,7 @@ module Streamly.Data.Stream.Concurrent
7878 -- , append
7979 -- , ahead
8080 -- , parallel
81− , parConcatList
81+ , parList
8282 -- , parallelFst
8383 -- , parallelMin
8484 -- , zipWithM
src/Streamly/Internal/Data/Stream/Concurrent.hs+40−40
@@ -73,13 +73,13 @@ module Streamly.Internal.Data.Stream.Concurrent
7373
7474 -- ** List of streams
7575 -- | Shares a single channel across many streams.
76− , parLazy
77− , parLazyOrdered
78− , parLazyInterleaved
79− , parEager
80− , parEagerFst
81− , parEagerMin
82− , parConcatList
76+ , parListLazy
77+ , parListOrdered
78+ , parListInterleaved
79+ , parListEager
80+ , parListEagerFst
81+ , parListEagerMin
82+ , parList
8383
8484 , parZipWithM
8585 , parZipWith
@@ -492,64 +492,64 @@ parConcat modifier = parConcatMap modifier id
492492
493493-- | Like 'parConcat' but works on a list of streams.
494494--
495−-- >>> parConcatList modifier = Stream.parConcat modifier . Stream.fromList
495+-- >>> parList modifier = Stream.parConcat modifier . Stream.fromList
496496--
497−{-# INLINE parConcatList #-}
498−parConcatList :: MonadAsync m => (Config -> Config) -> [Stream m a] -> Stream m a
499−parConcatList modifier = parConcat modifier . Stream.fromList
497+{-# INLINE parList #-}
498+parList :: MonadAsync m => (Config -> Config) -> [Stream m a] -> Stream m a
499+parList modifier = parConcat modifier . Stream.fromList
500500
501501-- | Like 'concat' but works on a list of streams.
502502--
503−-- >>> parLazy = Stream.parConcatList id
503+-- >>> parListLazy = Stream.parList id
504504--
505−{-# INLINE parLazy #-}
506−parLazy :: MonadAsync m => [Stream m a] -> Stream m a
507−parLazy = parConcatList id
505+{-# INLINE parListLazy #-}
506+parListLazy :: MonadAsync m => [Stream m a] -> Stream m a
507+parListLazy = parList id
508508
509−-- | Like 'parLazy' but interleaves the streams fairly instead of prioritizing
509+-- | Like 'parListLazy' but interleaves the streams fairly instead of prioritizing
510510-- the left stream. This schedules all streams in a round robin fashion over
511511-- limited number of threads.
512512--
513−-- >>> parLazyInterleaved = Stream.parConcatList (Stream.interleaved True)
513+-- >>> parListInterleaved = Stream.parList (Stream.interleaved True)
514514--
515−{-# INLINE parLazyInterleaved #-}
516−parLazyInterleaved :: MonadAsync m => [Stream m a] -> Stream m a
517−parLazyInterleaved = parConcatList (interleaved True)
515+{-# INLINE parListInterleaved #-}
516+parListInterleaved :: MonadAsync m => [Stream m a] -> Stream m a
517+parListInterleaved = parList (interleaved True)
518518
519−-- | Like 'parLazy' but with 'ordered' on.
519+-- | Like 'parListLazy' but with 'ordered' on.
520520--
521−-- >>> parLazyOrdered = Stream.parConcatList (Stream.ordered True)
521+-- >>> parListOrdered = Stream.parList (Stream.ordered True)
522522--
523−{-# INLINE parLazyOrdered #-}
524−parLazyOrdered :: MonadAsync m => [Stream m a] -> Stream m a
525−parLazyOrdered = parConcatList (ordered True)
523+{-# INLINE parListOrdered #-}
524+parListOrdered :: MonadAsync m => [Stream m a] -> Stream m a
525+parListOrdered = parList (ordered True)
526526
527−-- | Like 'parLazy' but with 'eager' on.
527+-- | Like 'parListLazy' but with 'eager' on.
528528--
529−-- >>> parEager = Stream.parConcatList (Stream.eager True)
529+-- >>> parListEager = Stream.parList (Stream.eager True)
530530--
531−{-# INLINE parEager #-}
532−parEager :: MonadAsync m => [Stream m a] -> Stream m a
533−parEager = parConcatList (eager True)
531+{-# INLINE parListEager #-}
532+parListEager :: MonadAsync m => [Stream m a] -> Stream m a
533+parListEager = parList (eager True)
534534
535−-- | Like 'parEager' but stops the output as soon as the first stream stops.
535+-- | Like 'parListEager' but stops the output as soon as the first stream stops.
536536--
537−-- >>> parEagerFst = Stream.parConcatList (Stream.eager True . Stream.stopWhen Stream.FirstStops)
537+-- >>> parListEagerFst = Stream.parList (Stream.eager True . Stream.stopWhen Stream.FirstStops)
538538--
539−{-# INLINE parEagerFst #-}
540−parEagerFst :: MonadAsync m => [Stream m a] -> Stream m a
541−parEagerFst = parConcatList (eager True . stopWhen FirstStops)
539+{-# INLINE parListEagerFst #-}
540+parListEagerFst :: MonadAsync m => [Stream m a] -> Stream m a
541+parListEagerFst = parList (eager True . stopWhen FirstStops)
542542
543−-- | Like 'parEager' but stops the output as soon as any of the two streams
543+-- | Like 'parListEager' but stops the output as soon as any of the two streams
544544-- stops.
545545--
546546-- Definition:
547547--
548−-- >>> parEagerMin = Stream.parConcatList (Stream.eager True . Stream.stopWhen Stream.AnyStops)
548+-- >>> parListEagerMin = Stream.parList (Stream.eager True . Stream.stopWhen Stream.AnyStops)
549549--
550−{-# INLINE parEagerMin #-}
551−parEagerMin :: MonadAsync m => [Stream m a] -> Stream m a
552−parEagerMin = parConcatList (eager True . stopWhen AnyStops)
550+{-# INLINE parListEagerMin #-}
551+parListEagerMin :: MonadAsync m => [Stream m a] -> Stream m a
552+parListEagerMin = parList (eager True . stopWhen AnyStops)
553553
554554-------------------------------------------------------------------------------
555555-- Applicative
src/Streamly/Internal/Data/Stream/Time.hs+3−3
@@ -98,7 +98,7 @@ import Streamly.Internal.Data.Stream.Concurrent
9898-- >>> import qualified Streamly.Data.Stream as Stream
9999-- >>> import qualified Streamly.Data.Stream.Prelude as Stream
100100-- >>> import qualified Streamly.Internal.Data.Stream as Stream (delayPost, timestamped)
101−-- >>> import qualified Streamly.Internal.Data.Stream.Concurrent as Stream (parEagerFst)
101+-- >>> import qualified Streamly.Internal.Data.Stream.Concurrent as Stream (parListEagerFst)
102102-- >>> import qualified Streamly.Internal.Data.Stream.Time as Stream
103103-- >>> import Prelude hiding (concatMap, concat)
104104-- >>> :{
@@ -154,7 +154,7 @@ ticksRate r = parEval (rate (Just r)) $ Stream.repeatM (return ())
154154--
155155-- Definition:
156156--
157−-- >>> interject n f xs = Stream.parEagerFst [xs, Stream.periodic f n]
157+-- >>> interject n f xs = Stream.parListEagerFst [xs, Stream.periodic f n]
158158--
159159-- Example:
160160--
@@ -165,7 +165,7 @@ ticksRate r = parEval (rate (Just r)) $ Stream.repeatM (return ())
165165--
166166{-# INLINE interject #-}
167167interject :: MonadAsync m => m a -> Double -> Stream m a -> Stream m a
168−interject f n xs = parEagerFst [xs, periodic f n]
168+interject f n xs = parListEagerFst [xs, periodic f n]
169169
170170-- XXX No element should be yielded if the duration is zero.
171171