@@ -139,7 +139,7 @@ import Streamly.Internal.Data.Stream.Concurrent.Channel
139-- >>> import qualified Streamly.Data.Fold as Fold
139-- >>> import qualified Streamly.Data.Fold as Fold
140-- >>> import qualified Streamly.Data.Parser as Parser
140-- >>> import qualified Streamly.Data.Parser as Parser
141-- >>> import qualified Streamly.Data.Stream as Stream
141-- >>> import qualified Streamly.Data.Stream as Stream
142−-- >>> import qualified Streamly.Internal.Data.Stream.Concurrent as Async
142+-- >>> import qualified Streamly.Internal.Data.Stream.Concurrent as Concur
143-- >>> import Prelude hiding (concatMap, concat, zipWith)
143-- >>> import Prelude hiding (concatMap, concat, zipWith)
145-- delay n = do
145-- delay n = do
@@ -185,7 +185,7 @@ evalWith modifier input = withChannel modifier input (const id)
185-- | Evaluate a stream asynchronously using a channel and serve the consumer
185-- | Evaluate a stream asynchronously using a channel and serve the consumer
186-- from the evaluation buffer.
186-- from the evaluation buffer.
188−-- >>> eval = Async.evalWith id
188+-- >>> eval = Concur.evalWith id
190{-# INLINE eval #-}
190{-# INLINE eval #-}
191eval :: MonadAsync m => Stream m a -> Stream m a
191eval :: MonadAsync m => Stream m a -> Stream m a
@@ -270,13 +270,13 @@ combineWith modifier stream1 stream2 =
270-- all streams. However, with this operation you can precisely control the
270-- all streams. However, with this operation you can precisely control the
271-- scheduling by creating arbitrary shape expression trees.
271-- scheduling by creating arbitrary shape expression trees.
273−-- >>> append2 = Async.combineWith id
273+-- >>> append2 = Concur.combineWith id
275-- The following code finishes in 4 seconds:
275-- The following code finishes in 4 seconds:
277-- >>> stream1 = Stream.fromEffect (delay 4)
277-- >>> stream1 = Stream.fromEffect (delay 4)
278-- >>> stream2 = Stream.fromEffect (delay 2)
278-- >>> stream2 = Stream.fromEffect (delay 2)
279−-- >>> Stream.fold Fold.toList $ stream1 `Async.append2` stream2
279+-- >>> Stream.fold Fold.toList $ stream1 `Concur.append2` stream2
@@ -289,7 +289,7 @@ append2 = combineWith id
289-- the left stream. This schedules all streams in a round robin fashion over
289-- the left stream. This schedules all streams in a round robin fashion over
290-- limited number of threads.
290-- limited number of threads.
292−-- >>> interleave2 = Async.combineWith (Async.interleaved True)
292+-- >>> interleave2 = Concur.combineWith (Concur.interleaved True)
294{-# INLINE interleave2 #-}
294{-# INLINE interleave2 #-}
295interleave2 :: MonadAsync m => Stream m a -> Stream m a -> Stream m a
295interleave2 :: MonadAsync m => Stream m a -> Stream m a -> Stream m a
@@ -297,7 +297,7 @@ interleave2 = combineWith (interleaved True)
298-- | Like 'append' but with 'ordered' on.
298-- | Like 'append' but with 'ordered' on.
300−-- >>> ahead2 = Async.combineWith (Async.ordered True)
300+-- >>> ahead2 = Concur.combineWith (Concur.ordered True)
302{-# INLINE ahead2 #-}
302{-# INLINE ahead2 #-}
303ahead2 :: MonadAsync m => Stream m a -> Stream m a -> Stream m a
303ahead2 :: MonadAsync m => Stream m a -> Stream m a -> Stream m a
@@ -305,7 +305,7 @@ ahead2 = combineWith (ordered True)
306-- | Like 'append2' but with 'eager' on.
306-- | Like 'append2' but with 'eager' on.
308−-- >>> parallel2 = Async.combineWith (Async.eager True)
308+-- >>> parallel2 = Concur.combineWith (Concur.eager True)
310{-# INLINE parallel2 #-}
310{-# INLINE parallel2 #-}
311parallel2 :: MonadAsync m => Stream m a -> Stream m a -> Stream m a
311parallel2 :: MonadAsync m => Stream m a -> Stream m a -> Stream m a
@@ -313,7 +313,7 @@ parallel2 = combineWith (eager True)
314-- | Like 'parallel2' but stops the output as soon as the first stream stops.
314-- | Like 'parallel2' but stops the output as soon as the first stream stops.
316−-- >>> parallelFst2 = Async.combineWith (Async.eager True . Async.stopWhen Async.FirstStops)
316+-- >>> parallelFst2 = Concur.combineWith (Concur.eager True . Concur.stopWhen Concur.FirstStops)
318-- /Pre-release/
318-- /Pre-release/
319{-# INLINE parallelFst2 #-}
319{-# INLINE parallelFst2 #-}
@@ -323,7 +323,7 @@ parallelFst2 = combineWith (eager True . stopWhen FirstStops)
323-- | Like 'parallel2' but stops the output as soon as any of the two streams
323-- | Like 'parallel2' but stops the output as soon as any of the two streams
326−-- >>> parallelMin2 = Async.combineWith (Async.eager True . Async.stopWhen Async.AnyStops)
326+-- >>> parallelMin2 = Concur.combineWith (Concur.eager True . Concur.stopWhen Concur.AnyStops)
328-- /Pre-release/
328-- /Pre-release/
329{-# INLINE parallelMin2 #-}
329{-# INLINE parallelMin2 #-}
@@ -440,9 +440,9 @@ concatMapWith modifier f stream =
440-- concurrently but earlier streams are perferred. Output from the streams are
440-- concurrently but earlier streams are perferred. Output from the streams are
441-- used as they arrive.
441-- used as they arrive.
443−-- >>> concatMap = Async.concatMapWith id
443+-- >>> concatMap = Concur.concatMapWith id
445−-- >>> f cfg xs = Stream.fold Fold.toList $ Async.concatMapWith cfg id $ Stream.fromList xs
445+-- >>> f cfg xs = Stream.fold Fold.toList $ Concur.concatMapWith cfg id $ Stream.fromList xs
447-- The following streams finish in 4 seconds:
447-- The following streams finish in 4 seconds:
@@ -458,19 +458,19 @@ concatMapWith modifier f stream =
458-- Limiting threads to 2 schedules the third stream only after one of the first
458-- Limiting threads to 2 schedules the third stream only after one of the first
459-- two has finished, releasing a thread:
459-- two has finished, releasing a thread:
461−-- >>> f (Async.maxThreads 2) [stream1, stream2, stream3]
461+-- >>> f (Concur.maxThreads 2) [stream1, stream2, stream3]
463-- [2,1,4]
463-- [2,1,4]
465-- When used with a Single thread it behaves like serial concatMap:
465-- When used with a Single thread it behaves like serial concatMap:
467−-- >>> f (Async.maxThreads 1) [stream1, stream2, stream3]
467+-- >>> f (Concur.maxThreads 1) [stream1, stream2, stream3]
469-- [4,2,1]
469-- [4,2,1]
471-- >>> stream1 = Stream.fromList [1,2,3]
471-- >>> stream1 = Stream.fromList [1,2,3]
472-- >>> stream2 = Stream.fromList [4,5,6]
472-- >>> stream2 = Stream.fromList [4,5,6]
473−-- >>> f (Async.maxThreads 1) [stream1, stream2]
473+-- >>> f (Concur.maxThreads 1) [stream1, stream2]
474-- [1,2,3,4,5,6]
474-- [1,2,3,4,5,6]
476{-# INLINE concatMap #-}
476{-# INLINE concatMap #-}
@@ -482,15 +482,15 @@ concatMap = concatMapWith id
482-- evaluate the earlier stream first, this schedules all streams in a round
482-- evaluate the earlier stream first, this schedules all streams in a round
483-- robin fashion over the available threads.
483-- robin fashion over the available threads.
485−-- >>> concatMapInterleave = Async.concatMapWith (Async.interleaved True)
485+-- >>> concatMapInterleave = Concur.concatMapWith (Concur.interleaved True)
487-- When used with a single thread it behaves like serial interleaving:
487-- When used with a single thread it behaves like serial interleaving:
489−-- >>> f cfg xs = Stream.fold Fold.toList $ Async.concatMapWith (Async.interleaved True . cfg) id $ Stream.fromList xs
489+-- >>> f cfg xs = Stream.fold Fold.toList $ Concur.concatMapWith (Concur.interleaved True . cfg) id $ Stream.fromList xs
491-- >>> stream1 = Stream.fromList [1,2,3]
491-- >>> stream1 = Stream.fromList [1,2,3]
492-- >>> stream2 = Stream.fromList [4,5,6]
492-- >>> stream2 = Stream.fromList [4,5,6]
493−-- >>> f (Async.maxThreads 1) [stream1, stream2]
493+-- >>> f (Concur.maxThreads 1) [stream1, stream2]
494-- [1,4,2,5,3,6]
494-- [1,4,2,5,3,6]
496-- /Works only on finite number of streams/
496-- /Works only on finite number of streams/
@@ -502,7 +502,7 @@ concatMapInterleave = concatMapWith (interleaved True)
502-- | Like 'concat' but we can also specify the concurrent channel's
502-- | Like 'concat' but we can also specify the concurrent channel's
503-- configuration parameters using Config modifiers.
503-- configuration parameters using Config modifiers.
505−-- >>> concatWith modifier = Async.concatMapWith modifier id
505+-- >>> concatWith modifier = Concur.concatMapWith modifier id
507{-# INLINE concatWith #-}
507{-# INLINE concatWith #-}
508concatWith :: MonadAsync m =>
508concatWith :: MonadAsync m =>
@@ -511,7 +511,7 @@ concatWith modifier = concatMapWith modifier id
512-- | Evaluate the streams in the input stream concurrently and combine them.
512-- | Evaluate the streams in the input stream concurrently and combine them.
514−-- >>> concat = Async.concatWith id
514+-- >>> concat = Concur.concatWith id
516{-# INLINE concat #-}
516{-# INLINE concat #-}
517concat :: MonadAsync m => Stream m (Stream m a) -> Stream m a
517concat :: MonadAsync m => Stream m (Stream m a) -> Stream m a
@@ -523,7 +523,7 @@ concat = concatWith id
524-- | Like 'concatWith' but works on a list of streams.
524-- | Like 'concatWith' but works on a list of streams.
526−-- >>> concatListWith modifier = Async.concatWith modifier . Stream.fromList
526+-- >>> concatListWith modifier = Concur.concatWith modifier . Stream.fromList
528{-# INLINE concatListWith #-}
528{-# INLINE concatListWith #-}
529concatListWith :: MonadAsync m => (Config -> Config) -> [Stream m a] -> Stream m a
529concatListWith :: MonadAsync m => (Config -> Config) -> [Stream m a] -> Stream m a
@@ -531,7 +531,7 @@ concatListWith modifier = concatWith modifier . Stream.fromList
532-- | Like 'concat' but works on a list of streams.
532-- | Like 'concat' but works on a list of streams.
534−-- >>> append = Async.concatListWith id
534+-- >>> append = Concur.concatListWith id
536{-# INLINE append #-}
536{-# INLINE append #-}
537append :: MonadAsync m => [Stream m a] -> Stream m a
537append :: MonadAsync m => [Stream m a] -> Stream m a
@@ -541,7 +541,7 @@ append = concatListWith id
541-- the left stream. This schedules all streams in a round robin fashion over
541-- the left stream. This schedules all streams in a round robin fashion over
542-- limited number of threads.
542-- limited number of threads.
544−-- >>> interleave = Async.concatListWith (Async.interleaved True)
544+-- >>> interleave = Concur.concatListWith (Concur.interleaved True)
546{-# INLINE interleave #-}
546{-# INLINE interleave #-}
547interleave :: MonadAsync m => [Stream m a] -> Stream m a
547interleave :: MonadAsync m => [Stream m a] -> Stream m a
@@ -549,7 +549,7 @@ interleave = concatListWith (interleaved True)
550-- | Like 'append' but with 'ordered' on.
550-- | Like 'append' but with 'ordered' on.
552−-- >>> ahead = Async.concatListWith (Async.ordered True)
552+-- >>> ahead = Concur.concatListWith (Concur.ordered True)
554{-# INLINE ahead #-}
554{-# INLINE ahead #-}
555ahead :: MonadAsync m => [Stream m a] -> Stream m a
555ahead :: MonadAsync m => [Stream m a] -> Stream m a
@@ -557,7 +557,7 @@ ahead = concatListWith (ordered True)
558-- | Like 'append' but with 'eager' on.
558-- | Like 'append' but with 'eager' on.
560−-- >>> parallel = Async.concatListWith (Async.eager True)
560+-- >>> parallel = Concur.concatListWith (Concur.eager True)
562{-# INLINE parallel #-}
562{-# INLINE parallel #-}
563parallel :: MonadAsync m => [Stream m a] -> Stream m a
563parallel :: MonadAsync m => [Stream m a] -> Stream m a
@@ -565,7 +565,7 @@ parallel = concatListWith (eager True)
566-- | Like 'parallel' but stops the output as soon as the first stream stops.
566-- | Like 'parallel' but stops the output as soon as the first stream stops.
568−-- >>> parallelFst = Async.concatListWith (Async.eager True . Async.stopWhen Async.FirstStops)
568+-- >>> parallelFst = Concur.concatListWith (Concur.eager True . Concur.stopWhen Concur.FirstStops)
570{-# INLINE parallelFst #-}
570{-# INLINE parallelFst #-}
571parallelFst :: MonadAsync m => [Stream m a] -> Stream m a
571parallelFst :: MonadAsync m => [Stream m a] -> Stream m a
@@ -574,7 +574,7 @@ parallelFst = concatListWith (eager True . stopWhen FirstStops)
574-- | Like 'parallel' but stops the output as soon as any of the two streams
574-- | Like 'parallel' but stops the output as soon as any of the two streams
577−-- >>> parallelMin = Async.concatListWith (Async.eager True . Async.stopWhen Async.AnyStops)
577+-- >>> parallelMin = Concur.concatListWith (Concur.eager True . Concur.stopWhen Concur.AnyStops)
579{-# INLINE parallelMin #-}
579{-# INLINE parallelMin #-}
580parallelMin :: MonadAsync m => [Stream m a] -> Stream m a
580parallelMin :: MonadAsync m => [Stream m a] -> Stream m a
@@ -605,7 +605,7 @@ apply = applyWith id
605-------------------------------------------------------------------------------
605-------------------------------------------------------------------------------
608−-- >>> mapMWith modifier f = Async.concatMapWith modifier (Stream.fromEffect . f)
608+-- >>> mapMWith modifier f = Concur.concatMapWith modifier (Stream.fromEffect . f)
610{-# INLINE mapMWith #-}
610{-# INLINE mapMWith #-}
611mapMWith :: MonadAsync m =>
611mapMWith :: MonadAsync m =>
@@ -613,13 +613,13 @@ mapMWith :: MonadAsync m =>
613mapMWith modifier f = concatMapWith modifier (Stream.fromEffect . f)
613mapMWith modifier f = concatMapWith modifier (Stream.fromEffect . f)
616−-- >>> mapM = Async.mapMWith id
616+-- >>> mapM = Concur.mapMWith id
617{-# INLINE mapM #-}
617{-# INLINE mapM #-}
618mapM :: MonadAsync m => (a -> m b) -> Stream m a -> Stream m b
618mapM :: MonadAsync m => (a -> m b) -> Stream m a -> Stream m b
619mapM = mapMWith id
619mapM = mapMWith id
622−-- >>> sequenceWith modifier = Async.mapMWith modifier id
622+-- >>> sequenceWith modifier = Concur.mapMWith modifier id
624{-# INLINE sequenceWith #-}
624{-# INLINE sequenceWith #-}
625sequenceWith :: MonadAsync m =>
625sequenceWith :: MonadAsync m =>
@@ -627,7 +627,7 @@ sequenceWith :: MonadAsync m =>
627sequenceWith modifier = mapMWith modifier id
627sequenceWith modifier = mapMWith modifier id
630−-- >>> sequence = Async.sequenceWith id
630+-- >>> sequence = Concur.sequenceWith id
632{-# INLINE sequence #-}
632{-# INLINE sequence #-}
633sequence :: MonadAsync m =>
633sequence :: MonadAsync m =>
@@ -635,7 +635,7 @@ sequence :: MonadAsync m =>
635sequence = sequenceWith id
635sequence = sequenceWith id
638−-- >>> zipWithM f m1 m2 = Stream.zipWithM f (Async.eval m1) (Async.eval m2)
638+-- >>> zipWithM f m1 m2 = Stream.zipWithM f (Concur.eval m1) (Concur.eval m2)
640{-# INLINE zipWithM #-}
640{-# INLINE zipWithM #-}
641zipWithM :: MonadAsync m
641zipWithM :: MonadAsync m
@@ -647,7 +647,7 @@ zipWithM f m1 m2 = Stream.zipWithM f (eval m1) (eval m2)
648-- >>> m1 = Stream.fromList [1,2,3]
648-- >>> m1 = Stream.fromList [1,2,3]
649-- >>> m2 = Stream.fromList [4,5,6]
649-- >>> m2 = Stream.fromList [4,5,6]
650−-- >>> Stream.fold Fold.toList $ Async.zipWith (,) m1 m2
650+-- >>> Stream.fold Fold.toList $ Concur.zipWith (,) m1 m2
651-- [(1,4),(2,5),(3,6)]
651-- [(1,4),(2,5),(3,6)]
653{-# INLINE zipWith #-}
653{-# INLINE zipWith #-}