@@ -44,7 +44,6 @@ import Control.Monad.IO.Class (MonadIO(liftIO))
44import Streamly.Internal.Control.Concurrent (MonadAsync, askRunInIO)
44import Streamly.Internal.Control.Concurrent (MonadAsync, askRunInIO)
45import Streamly.Internal.Data.Stream.Async.Channel.Operations
45import Streamly.Internal.Data.Stream.Async.Channel.Operations
46 (fromChannel, fromChannelK, toChannel, toChannelK)
46 (fromChannel, fromChannelK, toChannel, toChannelK)
47−import Streamly.Internal.Data.SVar.Type (adaptState)
49import qualified Streamly.Internal.Data.Stream as Stream
48import qualified Streamly.Internal.Data.Stream as Stream
50import qualified Streamly.Internal.Data.Stream.Async.Channel.Append as Append
49import qualified Streamly.Internal.Data.Stream.Async.Channel.Append as Append
@@ -72,6 +71,8 @@ withChannelK evaluator modifier input = K.concatEffect action
72 toChannelK chan (evaluator chan input)
71 toChannelK chan (evaluator chan input)
73 return $ fromChannelK chan
72 return $ fromChannelK chan
74+-- XXX Dedup with withChannelK
75{-# INLINE withInterleaveChannelK #-}
76{-# INLINE withInterleaveChannelK #-}
76withInterleaveChannelK :: MonadAsync m =>
77withInterleaveChannelK :: MonadAsync m =>
77 (Channel m b -> K.Stream m a -> K.Stream m b)
78 (Channel m b -> K.Stream m a -> K.Stream m b)
@@ -175,22 +176,6 @@ _appendWithChanK chan stream1 stream2 =
176-------------------------------------------------------------------------------
177-------------------------------------------------------------------------------
178−-- | @concatMapDivK useTail useHead stream@, divides the stream in head and
179−-- tail, maps a stream generator on the head and maps an action on the tail of
180−-- a stream. Returns the stream generated by the head.
181−{-# INLINE concatMapDivK #-}
182−concatMapDivK :: Monad m =>
183− (K.Stream m a -> m ())
184− -> (a -> K.Stream m b)
187−concatMapDivK useTail useHead stream =
188− K.mkStream $ \st yld sng stp -> do
189− let foldShared = K.foldStreamShared st yld sng stp
190− single a = foldShared $ useHead a
191− yieldk a r = useTail r >> single a
192− in K.foldStreamShared (adaptState st) yieldk single stp stream
194-- | A runner function takes a queuing function @q@ and a stream, it splits the
179-- | A runner function takes a queuing function @q@ and a stream, it splits the
195-- input stream, queuing the tail and using the head to generate a stream.
180-- input stream, queuing the tail and using the head to generate a stream.
196-- 'mkEnqueue' takes a runner function and generates the queuing function @q@.
181-- 'mkEnqueue' takes a runner function and generates the queuing function @q@.