@@ -142,8 +142,8 @@ import Prelude hiding (filter, drop, dropWhile, take,
142import qualified Prelude
142import qualified Prelude
143import qualified System.IO as IO
143import qualified System.IO as IO
145−import qualified Streamly.Core as S
145+import qualified Streamly.CPS.Stream as C
146−import Streamly.Core (Stream(Stream))
146+import qualified Streamly.CPS.Concurrent as CC
147import Streamly.Streams
147import Streamly.Streams
149------------------------------------------------------------------------------
149------------------------------------------------------------------------------
@@ -171,7 +171,7 @@ import Streamly.Streams
171unfoldr :: IsStream t => (b -> Maybe (a, b)) -> b -> t m a
171unfoldr :: IsStream t => (b -> Maybe (a, b)) -> b -> t m a
172unfoldr step = fromStream . go
172unfoldr step = fromStream . go
174− go s = Stream $ \_ stp _ yld ->
174+ go s = C.Stream $ \_ stp _ yld ->
175 case step s of
175 case step s of
176 Nothing -> stp
176 Nothing -> stp
177 Just (a, b) -> yld a (go b)
177 Just (a, b) -> yld a (go b)
@@ -211,12 +211,12 @@ unfoldr step = fromStream . go
211unfoldrM :: (IsStream t, MonadAsync m) => (b -> m (Maybe (a, b))) -> b -> t m a
211unfoldrM :: (IsStream t, MonadAsync m) => (b -> m (Maybe (a, b))) -> b -> t m a
212unfoldrM step = go
212unfoldrM step = go
214− go s = fromStream $ Stream $ \svr stp sng yld -> do
214+ go s = fromStream $ C.Stream $ \svr stp sng yld -> do
215 mayb <- step s
215 mayb <- step s
216 case mayb of
216 case mayb of
217 Nothing -> stp
217 Nothing -> stp
218 Just (a, b) ->
218 Just (a, b) ->
219− S.runStream (toStream (return a |: go b)) svr stp sng yld
219+ C.runStream (toStream (return a |: go b)) svr stp sng yld
221-- | Construct a stream from a 'Foldable' containing pure values.
221-- | Construct a stream from a 'Foldable' containing pure values.
@@ -258,7 +258,7 @@ each = fromFoldable
259-- @since 0.2.0
259-- @since 0.2.0
260once :: (IsStream t, Monad m) => m a -> t m a
260once :: (IsStream t, Monad m) => m a -> t m a
261−once = fromStream . S.once
261+once = fromStream . C.once
263-- | Generate a stream by performing a monadic action @n@ times.
263-- | Generate a stream by performing a monadic action @n@ times.
@@ -296,7 +296,7 @@ repeatM = go
296iterate :: IsStream t => (a -> a) -> a -> t m a
296iterate :: IsStream t => (a -> a) -> a -> t m a
297iterate step = fromStream . go
297iterate step = fromStream . go
299− go s = S.cons s (go (step s))
299+ go s = C.cons s (go (step s))
301-- | Iterate a monadic function from a seed value, streaming the results
301-- | Iterate a monadic function from a seed value, streaming the results
302-- forever.
302-- forever.
@@ -320,9 +320,9 @@ iterate step = fromStream . go
320iterateM :: (IsStream t, MonadAsync m) => (a -> m a) -> a -> t m a
320iterateM :: (IsStream t, MonadAsync m) => (a -> m a) -> a -> t m a
321iterateM step = go
321iterateM step = go
323− go s = fromStream $ Stream $ \svr stp sng yld -> do
323+ go s = fromStream $ C.Stream $ \svr stp sng yld -> do
324 next <- step s
324 next <- step s
325− S.runStream (toStream (return s |: go next)) svr stp sng yld
325+ C.runStream (toStream (return s |: go next)) svr stp sng yld
327-- | Read lines from an IO Handle into a stream of Strings.
327-- | Read lines from an IO Handle into a stream of Strings.
@@ -330,7 +330,7 @@ iterateM step = go
330fromHandle :: (IsStream t, MonadIO m) => IO.Handle -> t m String
330fromHandle :: (IsStream t, MonadIO m) => IO.Handle -> t m String
331fromHandle h = fromStream go
331fromHandle h = fromStream go
333− go = Stream $ \_ stp _ yld -> do
333+ go = C.Stream $ \_ stp _ yld -> do
334 eof <- liftIO $ IO.hIsEOF h
334 eof <- liftIO $ IO.hIsEOF h
@@ -357,7 +357,7 @@ foldr step acc m = go (toStream m)
357 let stop = return acc
357 let stop = return acc
358 single a = return (step a acc)
358 single a = return (step a acc)
359 yield a r = go r >>= \b -> return (step a b)
359 yield a r = go r >>= \b -> return (step a b)
360− in (S.runStream m1) Nothing stop single yield
360+ in (C.runStream m1) Nothing stop single yield
362-- | Lazy right fold with a monadic step function. For example, to fold a
362-- | Lazy right fold with a monadic step function. For example, to fold a
363-- stream into a list:
363-- stream into a list:
@@ -376,7 +376,7 @@ foldrM step acc m = go (toStream m)
376 let stop = return acc
376 let stop = return acc
377 single a = step a acc
377 single a = step a acc
378 yield a r = go r >>= step a
378 yield a r = go r >>= step a
379− in (S.runStream m1) Nothing stop single yield
379+ in (C.runStream m1) Nothing stop single yield
381-- | Strict left scan with an extraction function. Like 'scanl'', but applies a
381-- | Strict left scan with an extraction function. Like 'scanl'', but applies a
382-- user supplied extraction function (the third argument) at each step. This is
382-- user supplied extraction function (the third argument) at each step. This is
@@ -389,12 +389,12 @@ scanx :: IsStream t => (x -> a -> x) -> x -> (x -> b) -> t m a -> t m b
389scanx step begin done m =
389scanx step begin done m =
390 cons (done begin) $ fromStream $ go (toStream m) begin
390 cons (done begin) $ fromStream $ go (toStream m) begin
392− go m1 !acc = Stream $ \_ stp sng yld ->
392+ go m1 !acc = C.Stream $ \_ stp sng yld ->
393 let single a = sng (done $ step acc a)
393 let single a = sng (done $ step acc a)
394 yield a r =
394 yield a r =
395 let s = step acc a
395 let s = step acc a
396 in yld (done s) (go r s)
396 in yld (done s) (go r s)
397− in S.runStream m1 Nothing stp single yield
397+ in C.runStream m1 Nothing stp single yield
400-- @since 0.1.1
400-- @since 0.1.1
@@ -425,19 +425,19 @@ foldx step begin done m = get $ go (toStream m) begin
425 {-# NOINLINE get #-}
425 {-# NOINLINE get #-}
427 let single = return . done
427 let single = return . done
428− in (S.runStream m1) Nothing undefined single undefined
428+ in (C.runStream m1) Nothing undefined single undefined
430 -- Note, this can be implemented by making a recursive call to "go",
430 -- Note, this can be implemented by making a recursive call to "go",
431 -- however that is more expensive because of unnecessary recursion
431 -- however that is more expensive because of unnecessary recursion
432 -- that cannot be tail call optimized. Unfolding recursion explicitly via
432 -- that cannot be tail call optimized. Unfolding recursion explicitly via
433 -- continuations is much more efficient.
433 -- continuations is much more efficient.
434− go m1 !acc = Stream $ \_ _ sng yld ->
434+ go m1 !acc = C.Stream $ \_ _ sng yld ->
435 let stop = sng acc
435 let stop = sng acc
436 single a = sng $ step acc a
436 single a = sng $ step acc a
437 yield a r =
437 yield a r =
438 let stream = go r (step acc a)
438 let stream = go r (step acc a)
439− in (S.runStream stream) Nothing undefined sng yld
439+ in (C.runStream stream) Nothing undefined sng yld
440− in (S.runStream m1) Nothing stop single yield
440+ in (C.runStream m1) Nothing stop single yield
443-- @since 0.1.0
443-- @since 0.1.0
@@ -463,7 +463,7 @@ foldxM step begin done m = go begin (toStream m)
463 let stop = acc >>= done
463 let stop = acc >>= done
464 single a = acc >>= \b -> step b a >>= done
464 single a = acc >>= \b -> step b a >>= done
465 yield a r = acc >>= \b -> go (step b a) r
465 yield a r = acc >>= \b -> go (step b a) r
466− in (S.runStream m1) Nothing stop single yield
466+ in (C.runStream m1) Nothing stop single yield
469-- @since 0.1.0
469-- @since 0.1.0
@@ -487,7 +487,7 @@ uncons m =
487 let stop = return Nothing
487 let stop = return Nothing
488 single a = return (Just (a, nil))
488 single a = return (Just (a, nil))
489 yield a r = return (Just (a, fromStream r))
489 yield a r = return (Just (a, fromStream r))
490− in (S.runStream (toStream m)) Nothing stop single yield
490+ in (C.runStream (toStream m)) Nothing stop single yield
492-- | Write a stream of Strings to an IO Handle.
492-- | Write a stream of Strings to an IO Handle.
@@ -499,7 +499,7 @@ toHandle h m = go (toStream m)
499 let stop = return ()
499 let stop = return ()
500 single a = liftIO (IO.hPutStrLn h a)
500 single a = liftIO (IO.hPutStrLn h a)
501 yield a r = liftIO (IO.hPutStrLn h a) >> go r
501 yield a r = liftIO (IO.hPutStrLn h a) >> go r
502− in (S.runStream m1) Nothing stop single yield
502+ in (C.runStream m1) Nothing stop single yield
504------------------------------------------------------------------------------
504------------------------------------------------------------------------------
505-- Special folds
505-- Special folds
@@ -519,9 +519,9 @@ toList = foldrM (\a xs -> return (a : xs)) []
519take :: IsStream t => Int -> t m a -> t m a
519take :: IsStream t => Int -> t m a -> t m a
520take n m = fromStream $ go n (toStream m)
520take n m = fromStream $ go n (toStream m)
522− go n1 m1 = Stream $ \_ stp sng yld ->
522+ go n1 m1 = C.Stream $ \_ stp sng yld ->
523 let yield a r = yld a (go (n1 - 1) r)
523 let yield a r = yld a (go (n1 - 1) r)
524− in if n1 <= 0 then stp else (S.runStream m1) Nothing stp sng yield
524+ in if n1 <= 0 then stp else (C.runStream m1) Nothing stp sng yield
526-- | Include only those elements that pass a predicate.
526-- | Include only those elements that pass a predicate.
@@ -530,12 +530,12 @@ take n m = fromStream $ go n (toStream m)
530filter :: IsStream t => (a -> Bool) -> t m a -> t m a
530filter :: IsStream t => (a -> Bool) -> t m a -> t m a
531filter p m = fromStream $ go (toStream m)
531filter p m = fromStream $ go (toStream m)
533− go m1 = Stream $ \_ stp sng yld ->
533+ go m1 = C.Stream $ \_ stp sng yld ->
534 let single a | p a = sng a
534 let single a | p a = sng a
535 | otherwise = stp
535 | otherwise = stp
536 yield a r | p a = yld a (go r)
536 yield a r | p a = yld a (go r)
537− | otherwise = (S.runStream r) Nothing stp single yield
537+ | otherwise = (C.runStream r) Nothing stp single yield
538− in (S.runStream m1) Nothing stp single yield
538+ in (C.runStream m1) Nothing stp single yield
540-- | End the stream as soon as the predicate fails on an element.
540-- | End the stream as soon as the predicate fails on an element.
@@ -544,12 +544,12 @@ filter p m = fromStream $ go (toStream m)
544takeWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
544takeWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
545takeWhile p m = fromStream $ go (toStream m)
545takeWhile p m = fromStream $ go (toStream m)
547− go m1 = Stream $ \_ stp sng yld ->
547+ go m1 = C.Stream $ \_ stp sng yld ->
548 let single a | p a = sng a
548 let single a | p a = sng a
549 | otherwise = stp
549 | otherwise = stp
550 yield a r | p a = yld a (go r)
550 yield a r | p a = yld a (go r)
551 | otherwise = stp
551 | otherwise = stp
552− in (S.runStream m1) Nothing stp single yield
552+ in (C.runStream m1) Nothing stp single yield
554-- | Discard first 'n' elements from the stream and take the rest.
554-- | Discard first 'n' elements from the stream and take the rest.
@@ -557,13 +557,13 @@ takeWhile p m = fromStream $ go (toStream m)
557drop :: IsStream t => Int -> t m a -> t m a
557drop :: IsStream t => Int -> t m a -> t m a
558drop n m = fromStream $ go n (toStream m)
558drop n m = fromStream $ go n (toStream m)
560− go n1 m1 = Stream $ \_ stp sng yld ->
560+ go n1 m1 = C.Stream $ \_ stp sng yld ->
561 let single _ = stp
561 let single _ = stp
562− yield _ r = (S.runStream $ go (n1 - 1) r) Nothing stp sng yld
562+ yield _ r = (C.runStream $ go (n1 - 1) r) Nothing stp sng yld
563 -- Somehow "<=" check performs better than a ">"
563 -- Somehow "<=" check performs better than a ">"
564 in if n1 <= 0
564 in if n1 <= 0
565− then (S.runStream m1) Nothing stp sng yld
565+ then (C.runStream m1) Nothing stp sng yld
566− else (S.runStream m1) Nothing stp single yield
566+ else (C.runStream m1) Nothing stp single yield
568-- | Drop elements in the stream as long as the predicate succeeds and then
568-- | Drop elements in the stream as long as the predicate succeeds and then
569-- take the rest of the stream.
569-- take the rest of the stream.
@@ -573,12 +573,12 @@ drop n m = fromStream $ go n (toStream m)
573dropWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
573dropWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
574dropWhile p m = fromStream $ go (toStream m)
574dropWhile p m = fromStream $ go (toStream m)
576− go m1 = Stream $ \_ stp sng yld ->
576+ go m1 = C.Stream $ \_ stp sng yld ->
577 let single a | p a = stp
577 let single a | p a = stp
578 | otherwise = sng a
578 | otherwise = sng a
579− yield a r | p a = (S.runStream r) Nothing stp single yield
579+ yield a r | p a = (C.runStream r) Nothing stp single yield
580 | otherwise = yld a r
580 | otherwise = yld a r
581− in (S.runStream m1) Nothing stp single yield
581+ in (C.runStream m1) Nothing stp single yield
583-- | Determine whether all elements of a stream satisfy a predicate.
583-- | Determine whether all elements of a stream satisfy a predicate.
@@ -591,7 +591,7 @@ all p m = go (toStream m)
591 | otherwise = return False
591 | otherwise = return False
592 yield a r | p a = go r
592 yield a r | p a = go r
593 | otherwise = return False
593 | otherwise = return False
594− in (S.runStream m1) Nothing (return True) single yield
594+ in (C.runStream m1) Nothing (return True) single yield
596-- | Determine whether any of the elements of a stream satisfy a predicate.
596-- | Determine whether any of the elements of a stream satisfy a predicate.
@@ -604,7 +604,7 @@ any p m = go (toStream m)
604 | otherwise = return False
604 | otherwise = return False
605 yield a r | p a = return True
605 yield a r | p a = return True
606 | otherwise = go r
606 | otherwise = go r
607− in (S.runStream m1) Nothing (return False) single yield
607+ in (C.runStream m1) Nothing (return False) single yield
609-- | Determine the sum of all elements of a stream of numbers
609-- | Determine the sum of all elements of a stream of numbers
@@ -626,7 +626,7 @@ head m =
626 let stop = return Nothing
626 let stop = return Nothing
627 single a = return (Just a)
627 single a = return (Just a)
628 yield a _ = return (Just a)
628 yield a _ = return (Just a)
629− in (S.runStream (toStream m)) Nothing stop single yield
629+ in (C.runStream (toStream m)) Nothing stop single yield
631-- | Extract all but the first element of the stream, if any.
631-- | Extract all but the first element of the stream, if any.
@@ -636,7 +636,7 @@ tail m =
636 let stop = return Nothing
636 let stop = return Nothing
637 single _ = return $ Just nil
637 single _ = return $ Just nil
638 yield _ r = return $ Just $ fromStream r
638 yield _ r = return $ Just $ fromStream r
639− in (S.runStream (toStream m)) Nothing stop single yield
639+ in (C.runStream (toStream m)) Nothing stop single yield
641-- | Extract the last element of the stream, if any.
641-- | Extract the last element of the stream, if any.
@@ -653,7 +653,7 @@ null m =
653 let stop = return True
653 let stop = return True
654 single _ = return False
654 single _ = return False
655 yield _ _ = return False
655 yield _ _ = return False
656− in (S.runStream (toStream m)) Nothing stop single yield
656+ in (C.runStream (toStream m)) Nothing stop single yield
658-- | Determine whether an element is present in the stream.
658-- | Determine whether an element is present in the stream.
@@ -665,7 +665,7 @@ elem e m = go (toStream m)
665 let stop = return False
665 let stop = return False
666 single a = return (a == e)
666 single a = return (a == e)
667 yield a r = if a == e then return True else go r
667 yield a r = if a == e then return True else go r
668− in (S.runStream m1) Nothing stop single yield
668+ in (C.runStream m1) Nothing stop single yield
670-- | Determine whether an element is not present in the stream.
670-- | Determine whether an element is not present in the stream.
@@ -677,7 +677,7 @@ notElem e m = go (toStream m)
677 let stop = return True
677 let stop = return True
678 single a = return (a /= e)
678 single a = return (a /= e)
679 yield a r = if a == e then return False else go r
679 yield a r = if a == e then return False else go r
680− in (S.runStream m1) Nothing stop single yield
680+ in (C.runStream m1) Nothing stop single yield
682-- | Determine the length of the stream.
682-- | Determine the length of the stream.
@@ -690,14 +690,14 @@ length = foldl (\n _ -> n + 1) 0 id
691-- @since 0.1.1
691-- @since 0.1.1
692reverse :: (IsStream t) => t m a -> t m a
692reverse :: (IsStream t) => t m a -> t m a
693−reverse m = fromStream $ go S.nil (toStream m)
693+reverse m = fromStream $ go C.nil (toStream m)
695− go rev rest = Stream $ \_ stp sng yld ->
695+ go rev rest = C.Stream $ \_ stp sng yld ->
696− let run x = S.runStream x Nothing stp sng yld
696+ let run x = C.runStream x Nothing stp sng yld
697 stop = run rev
697 stop = run rev
698− single a = run $ a `S.cons` rev
698+ single a = run $ a `C.cons` rev
699− yield a r = run $ go (a `S.cons` rev) r
699+ yield a r = run $ go (a `C.cons` rev) r
700− in S.runStream rest Nothing stop single yield
700+ in C.runStream rest Nothing stop single yield
702-- XXX replace the recursive "go" with continuation
702-- XXX replace the recursive "go" with continuation
703-- | Determine the minimum element in a stream.
703-- | Determine the minimum element in a stream.
@@ -710,7 +710,7 @@ minimum m = go Nothing (toStream m)
710 let stop = return res
710 let stop = return res
711 single a = return $ min_ a res
711 single a = return $ min_ a res
712 yield a r = go (min_ a res) r
712 yield a r = go (min_ a res) r
713− in (S.runStream m1) Nothing stop single yield
713+ in (C.runStream m1) Nothing stop single yield
715 min_ a res = case res of
715 min_ a res = case res of
716 Nothing -> Just a
716 Nothing -> Just a
@@ -727,7 +727,7 @@ maximum m = go Nothing (toStream m)
727 let stop = return res
727 let stop = return res
728 single a = return $ max_ a res
728 single a = return $ max_ a res
729 yield a r = go (max_ a res) r
729 yield a r = go (max_ a res) r
730− in (S.runStream m1) Nothing stop single yield
730+ in (C.runStream m1) Nothing stop single yield
732 max_ a res = case res of
732 max_ a res = case res of
733 Nothing -> Just a
733 Nothing -> Just a
@@ -755,10 +755,10 @@ maximum m = go Nothing (toStream m)
755mapM :: (IsStream t, MonadAsync m) => (a -> m b) -> t m a -> t m b
755mapM :: (IsStream t, MonadAsync m) => (a -> m b) -> t m a -> t m b
756mapM f m = go (toStream m)
756mapM f m = go (toStream m)
758− go m1 = fromStream $ Stream $ \svr stp sng yld ->
758+ go m1 = fromStream $ C.Stream $ \svr stp sng yld ->
759 let single a = f a >>= sng
759 let single a = f a >>= sng
760− yield a r = S.runStream (toStream (f a |: (go r))) svr stp sng yld
760+ yield a r = C.runStream (toStream (f a |: (go r))) svr stp sng yld
761− in (S.runStream m1) Nothing stp single yield
761+ in (C.runStream m1) Nothing stp single yield
763-- | Map a 'Maybe' returning function to a stream, filter out the 'Nothing'
763-- | Map a 'Maybe' returning function to a stream, filter out the 'Nothing'
764-- elements, and return a stream of values extracted from 'Just'.
764-- elements, and return a stream of values extracted from 'Just'.
@@ -768,14 +768,14 @@ mapM f m = go (toStream m)
768mapMaybe :: (IsStream t) => (a -> Maybe b) -> t m a -> t m b
768mapMaybe :: (IsStream t) => (a -> Maybe b) -> t m a -> t m b
769mapMaybe f m = go (toStream m)
769mapMaybe f m = go (toStream m)
771− go m1 = fromStream $ Stream $ \_ stp sng yld ->
771+ go m1 = fromStream $ C.Stream $ \_ stp sng yld ->
772 let single a = case f a of
772 let single a = case f a of
773 Just b -> sng b
773 Just b -> sng b
774 Nothing -> stp
774 Nothing -> stp
775 yield a r = case f a of
775 yield a r = case f a of
776 Just b -> yld b (toStream $ go r)
776 Just b -> yld b (toStream $ go r)
777− Nothing -> (S.runStream r) Nothing stp single yield
777+ Nothing -> (C.runStream r) Nothing stp single yield
778− in (S.runStream m1) Nothing stp single yield
778+ in (C.runStream m1) Nothing stp single yield
780-- | Like 'mapMaybe' but maps a monadic function.
780-- | Like 'mapMaybe' but maps a monadic function.
@@ -799,7 +799,7 @@ mapM_ f m = go (toStream m)
799 let stop = return ()
799 let stop = return ()
800 single a = void (f a)
800 single a = void (f a)
801 yield a r = f a >> go r
801 yield a r = f a >> go r
802− in (S.runStream m1) Nothing stop single yield
802+ in (C.runStream m1) Nothing stop single yield
804-- | Reduce a stream of monadic actions to a stream of the output of those
804-- | Reduce a stream of monadic actions to a stream of the output of those
805-- actions.
805-- actions.
@@ -818,10 +818,10 @@ mapM_ f m = go (toStream m)
818sequence :: (IsStream t, MonadAsync m) => t m (m a) -> t m a
818sequence :: (IsStream t, MonadAsync m) => t m (m a) -> t m a
819sequence m = go (toStream m)
819sequence m = go (toStream m)
821− go m1 = fromStream $ Stream $ \svr stp sng yld ->
821+ go m1 = fromStream $ C.Stream $ \svr stp sng yld ->
822 let single ma = ma >>= sng
822 let single ma = ma >>= sng
823− yield ma r = S.runStream (toStream $ ma |: go r) svr stp sng yld
823+ yield ma r = C.runStream (toStream $ ma |: go r) svr stp sng yld
824− in (S.runStream m1) Nothing stp single yield
824+ in (C.runStream m1) Nothing stp single yield
826------------------------------------------------------------------------------
826------------------------------------------------------------------------------
827-- Serially Zipping Streams
827-- Serially Zipping Streams
@@ -832,7 +832,7 @@ sequence m = go (toStream m)
832-- @since 0.1.0
832-- @since 0.1.0
833{-# INLINABLE zipWith #-}
833{-# INLINABLE zipWith #-}
834zipWith :: IsStream t => (a -> b -> c) -> t m a -> t m b -> t m c
834zipWith :: IsStream t => (a -> b -> c) -> t m a -> t m b -> t m c
835−zipWith f m1 m2 = fromStream $ S.zipWith f (toStream m1) (toStream m2)
835+zipWith f m1 m2 = fromStream $ C.zipWith f (toStream m1) (toStream m2)
837-- | Zip two streams serially using a monadic zipping function.
837-- | Zip two streams serially using a monadic zipping function.
@@ -840,15 +840,15 @@ zipWith f m1 m2 = fromStream $ S.zipWith f (toStream m1) (toStream m2)
840zipWithM :: IsStream t => (a -> b -> t m c) -> t m a -> t m b -> t m c
840zipWithM :: IsStream t => (a -> b -> t m c) -> t m a -> t m b -> t m c
841zipWithM f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
841zipWithM f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
843− go mx my = Stream $ \_ stp sng yld -> do
843+ go mx my = C.Stream $ \_ stp sng yld -> do
844 let merge a ra =
844 let merge a ra =
845− let run x = S.runStream x Nothing stp sng yld
845+ let run x = C.runStream x Nothing stp sng yld
846 single2 b = run $ toStream (f a b)
846 single2 b = run $ toStream (f a b)
847 yield2 b rb = run $ toStream (f a b) <> go ra rb
847 yield2 b rb = run $ toStream (f a b) <> go ra rb
848− in (S.runStream my) Nothing stp single2 yield2
848+ in (C.runStream my) Nothing stp single2 yield2
849− let single1 a = merge a S.nil
849+ let single1 a = merge a C.nil
850 yield1 a ra = merge a ra
850 yield1 a ra = merge a ra
851− (S.runStream mx) Nothing stp single1 yield1
851+ (C.runStream mx) Nothing stp single1 yield1
853------------------------------------------------------------------------------
853------------------------------------------------------------------------------
854-- Parallely Zipping Streams
854-- Parallely Zipping Streams
@@ -861,7 +861,7 @@ zipWithM f m1 m2 = fromStream $ go (toStream m1) (toStream m2)
861zipAsyncWith :: (IsStream t, MonadAsync m)
861zipAsyncWith :: (IsStream t, MonadAsync m)
862 => (a -> b -> c) -> t m a -> t m b -> t m c
862 => (a -> b -> c) -> t m a -> t m b -> t m c
863zipAsyncWith f m1 m2 =
863zipAsyncWith f m1 m2 =
864− fromStream $ S.zipAsyncWith f (toStream m1) (toStream m2)
864+ fromStream $ CC.zipAsyncWith f (toStream m1) (toStream m2)
866-- | Zip two streams asyncly (i.e. both the elements being zipped are generated
866-- | Zip two streams asyncly (i.e. both the elements being zipped are generated
867-- concurrently) using a monadic zipping function.
867-- concurrently) using a monadic zipping function.
@@ -869,7 +869,7 @@ zipAsyncWith f m1 m2 =
869-- @since 0.1.0
869-- @since 0.1.0
870zipAsyncWithM :: (IsStream t, MonadAsync m)
870zipAsyncWithM :: (IsStream t, MonadAsync m)
871 => (a -> b -> t m c) -> t m a -> t m b -> t m c
871 => (a -> b -> t m c) -> t m a -> t m b -> t m c
872−zipAsyncWithM f m1 m2 = fromStream $ Stream $ \_ stp sng yld -> do
872+zipAsyncWithM f m1 m2 = fromStream $ C.Stream $ \_ stp sng yld -> do
873 ma <- mkAsync m1
873 ma <- mkAsync m1
874 mb <- mkAsync m2
874 mb <- mkAsync m2
875− (S.runStream (toStream (zipWithM f ma mb))) Nothing stp sng yld
875+ (C.runStream (toStream (zipWithM f ma mb))) Nothing stp sng yld