@@ -35,6 +35,7 @@ module Streamly.Internal.Data.Stream.Async
3535 , minRate
3636 , maxRate
3737 , constRate
38+ , inspectMode
3839
3940 -- * Combinators
4041 -- | Stream combinators using Async channel
@@ -55,6 +56,7 @@ module Streamly.Internal.Data.Stream.Async
5556 , interleaveWith
5657
5758 , apply
59+ , applyWith
5860 , concatList
5961 , concat
6062 , concatWith
@@ -284,10 +286,21 @@ concat = concatWith id
284286concatList :: MonadAsync m => [Stream m a] -> Stream m a
285287concatList = concat . Stream.fromList
286288
289+{-# INLINE applyWith #-}
290+{-# SPECIALIZE applyWith ::
291+ (Config -> Config) -> Stream IO (a -> b) -> Stream IO a -> Stream IO b #-}
292+applyWith :: MonadAsync m =>
293+ (Config -> Config) -> Stream m (a -> b) -> Stream m a -> Stream m b
294+applyWith modifier stream1 stream2 =
295+ concatMapWith
296+ modifier
297+ (\g -> concatMapWith modifier (pure . g) stream2)
298+ stream1
299+
287300{-# INLINE apply #-}
288301{-# SPECIALIZE apply :: Stream IO (a -> b) -> Stream IO a -> Stream IO b #-}
289302apply :: MonadAsync m => Stream m (a -> b) -> Stream m a -> Stream m b
290−apply stream1 stream2 = concatMap (\g -> concatMap (pure . g) stream2) stream1
303+apply = applyWith id
291304
292305-- |
293306-- >>> mapMWith modifier f = Async.concatMapWith modifier (Stream.fromEffect . f)