on master help sign in
rename the continuation based stream to StreamK
5ee02ffHarendra Kumar
src/Streamly.hs+1−1
@@ -152,7 +152,7 @@ module Streamly
152 )
152 )
153where
153where
154
154
155−import Streamly.Streams.CPS hiding (runStream, serial)
155+import Streamly.Streams.StreamK hiding (runStream, serial)
156import Streamly.Streams.Serial
156import Streamly.Streams.Serial
157import Streamly.Streams.Async
157import Streamly.Streams.Async
158import Streamly.Streams.Ahead
158import Streamly.Streams.Ahead
src/Streamly/Prelude.hs+59−59
@@ -141,8 +141,8 @@ import Prelude hiding (filter, drop, dropWhile, take,
141import qualified Prelude
141import qualified Prelude
142import qualified System.IO as IO
142import qualified System.IO as IO
143
143
144−import Streamly.Streams.CPS
144+import Streamly.Streams.StreamK
145−import qualified Streamly.Streams.CPS as C
145+import qualified Streamly.Streams.StreamK as K
146import Streamly.Streams.Zip
146import Streamly.Streams.Zip
147import Streamly.Streams.Serial
147import Streamly.Streams.Serial
148import Streamly.SVar (MonadAsync)
148import Streamly.SVar (MonadAsync)
@@ -172,7 +172,7 @@ import Streamly.SVar (MonadAsync)
172unfoldr :: IsStream t => (b -> Maybe (a, b)) -> b -> t m a
172unfoldr :: IsStream t => (b -> Maybe (a, b)) -> b -> t m a
173unfoldr step = fromStream . go
173unfoldr step = fromStream . go
174 where
174 where
175− go s = C.Stream $ \_ stp _ yld ->
175+ go s = K.Stream $ \_ stp _ yld ->
176 case step s of
176 case step s of
177 Nothing -> stp
177 Nothing -> stp
178 Just (a, b) -> yld a (go b)
178 Just (a, b) -> yld a (go b)
@@ -212,12 +212,12 @@ unfoldr step = fromStream . go
212unfoldrM :: (IsStream t, MonadAsync m) => (b -> m (Maybe (a, b))) -> b -> t m a
212unfoldrM :: (IsStream t, MonadAsync m) => (b -> m (Maybe (a, b))) -> b -> t m a
213unfoldrM step = go
213unfoldrM step = go
214 where
214 where
215− go s = fromStream $ C.Stream $ \svr stp sng yld -> do
215+ go s = fromStream $ K.Stream $ \svr stp sng yld -> do
216 mayb <- step s
216 mayb <- step s
217 case mayb of
217 case mayb of
218 Nothing -> stp
218 Nothing -> stp
219 Just (a, b) ->
219 Just (a, b) ->
220− C.runStream (toStream (return a |: go b)) svr stp sng yld
220+ K.runStream (toStream (return a |: go b)) svr stp sng yld
221
221
222-- | Construct a stream from a 'Foldable' containing pure values.
222-- | Construct a stream from a 'Foldable' containing pure values.
223--
223--
@@ -284,7 +284,7 @@ repeatM = go
284iterate :: IsStream t => (a -> a) -> a -> t m a
284iterate :: IsStream t => (a -> a) -> a -> t m a
285iterate step = fromStream . go
285iterate step = fromStream . go
286 where
286 where
287− go s = C.cons s (go (step s))
287+ go s = K.cons s (go (step s))
288
288
289-- | Iterate a monadic function from a seed value, streaming the results
289-- | Iterate a monadic function from a seed value, streaming the results
290-- forever.
290-- forever.
@@ -308,9 +308,9 @@ iterate step = fromStream . go
308iterateM :: (IsStream t, MonadAsync m) => (a -> m a) -> a -> t m a
308iterateM :: (IsStream t, MonadAsync m) => (a -> m a) -> a -> t m a
309iterateM step = go
309iterateM step = go
310 where
310 where
311− go s = fromStream $ C.Stream $ \svr stp sng yld -> do
311+ go s = fromStream $ K.Stream $ \svr stp sng yld -> do
312 next <- step s
312 next <- step s
313− C.runStream (toStream (return s |: go next)) svr stp sng yld
313+ K.runStream (toStream (return s |: go next)) svr stp sng yld
314
314
315-- | Read lines from an IO Handle into a stream of Strings.
315-- | Read lines from an IO Handle into a stream of Strings.
316--
316--
@@ -318,7 +318,7 @@ iterateM step = go
318fromHandle :: (IsStream t, MonadIO m) => IO.Handle -> t m String
318fromHandle :: (IsStream t, MonadIO m) => IO.Handle -> t m String
319fromHandle h = fromStream go
319fromHandle h = fromStream go
320 where
320 where
321− go = C.Stream $ \_ stp _ yld -> do
321+ go = K.Stream $ \_ stp _ yld -> do
322 eof <- liftIO $ IO.hIsEOF h
322 eof <- liftIO $ IO.hIsEOF h
323 if eof
323 if eof
324 then stp
324 then stp
@@ -345,7 +345,7 @@ foldr step acc m = go (toStream m)
345 let stop = return acc
345 let stop = return acc
346 single a = return (step a acc)
346 single a = return (step a acc)
347 yield a r = go r >>= \b -> return (step a b)
347 yield a r = go r >>= \b -> return (step a b)
348− in (C.runStream m1) Nothing stop single yield
348+ in (K.runStream m1) Nothing stop single yield
349
349
350-- | Lazy right fold with a monadic step function. For example, to fold a
350-- | Lazy right fold with a monadic step function. For example, to fold a
351-- stream into a list:
351-- stream into a list:
@@ -364,7 +364,7 @@ foldrM step acc m = go (toStream m)
364 let stop = return acc
364 let stop = return acc
365 single a = step a acc
365 single a = step a acc
366 yield a r = go r >>= step a
366 yield a r = go r >>= step a
367− in (C.runStream m1) Nothing stop single yield
367+ in (K.runStream m1) Nothing stop single yield
368
368
369-- | Strict left scan with an extraction function. Like 'scanl'', but applies a
369-- | Strict left scan with an extraction function. Like 'scanl'', but applies a
370-- user supplied extraction function (the third argument) at each step. This is
370-- user supplied extraction function (the third argument) at each step. This is
@@ -377,12 +377,12 @@ scanx :: IsStream t => (x -> a -> x) -> x -> (x -> b) -> t m a -> t m b
377scanx step begin done m =
377scanx step begin done m =
378 cons (done begin) $ fromStream $ go (toStream m) begin
378 cons (done begin) $ fromStream $ go (toStream m) begin
379 where
379 where
380− go m1 !acc = C.Stream $ \_ stp sng yld ->
380+ go m1 !acc = K.Stream $ \_ stp sng yld ->
381 let single a = sng (done $ step acc a)
381 let single a = sng (done $ step acc a)
382 yield a r =
382 yield a r =
383 let s = step acc a
383 let s = step acc a
384 in yld (done s) (go r s)
384 in yld (done s) (go r s)
385− in C.runStream m1 Nothing stp single yield
385+ in K.runStream m1 Nothing stp single yield
386
386
387-- |
387-- |
388-- @since 0.1.1
388-- @since 0.1.1
@@ -413,19 +413,19 @@ foldx step begin done m = get $ go (toStream m) begin
413 {-# NOINLINE get #-}
413 {-# NOINLINE get #-}
414 get m1 =
414 get m1 =
415 let single = return . done
415 let single = return . done
416− in (C.runStream m1) Nothing undefined single undefined
416+ in (K.runStream m1) Nothing undefined single undefined
417
417
418 -- Note, this can be implemented by making a recursive call to "go",
418 -- Note, this can be implemented by making a recursive call to "go",
419 -- however that is more expensive because of unnecessary recursion
419 -- however that is more expensive because of unnecessary recursion
420 -- that cannot be tail call optimized. Unfolding recursion explicitly via
420 -- that cannot be tail call optimized. Unfolding recursion explicitly via
421 -- continuations is much more efficient.
421 -- continuations is much more efficient.
422− go m1 !acc = C.Stream $ \_ _ sng yld ->
422+ go m1 !acc = K.Stream $ \_ _ sng yld ->
423 let stop = sng acc
423 let stop = sng acc
424 single a = sng $ step acc a
424 single a = sng $ step acc a
425 yield a r =
425 yield a r =
426 let stream = go r (step acc a)
426 let stream = go r (step acc a)
427− in (C.runStream stream) Nothing undefined sng yld
427+ in (K.runStream stream) Nothing undefined sng yld
428− in (C.runStream m1) Nothing stop single yield
428+ in (K.runStream m1) Nothing stop single yield
429
429
430-- |
430-- |
431-- @since 0.1.0
431-- @since 0.1.0
@@ -451,7 +451,7 @@ foldxM step begin done m = go begin (toStream m)
451 let stop = acc >>= done
451 let stop = acc >>= done
452 single a = acc >>= \b -> step b a >>= done
452 single a = acc >>= \b -> step b a >>= done
453 yield a r = acc >>= \b -> go (step b a) r
453 yield a r = acc >>= \b -> go (step b a) r
454− in (C.runStream m1) Nothing stop single yield
454+ in (K.runStream m1) Nothing stop single yield
455
455
456-- |
456-- |
457-- @since 0.1.0
457-- @since 0.1.0
@@ -475,7 +475,7 @@ uncons m =
475 let stop = return Nothing
475 let stop = return Nothing
476 single a = return (Just (a, nil))
476 single a = return (Just (a, nil))
477 yield a r = return (Just (a, fromStream r))
477 yield a r = return (Just (a, fromStream r))
478− in (C.runStream (toStream m)) Nothing stop single yield
478+ in (K.runStream (toStream m)) Nothing stop single yield
479
479
480-- | Write a stream of Strings to an IO Handle.
480-- | Write a stream of Strings to an IO Handle.
481--
481--
@@ -487,7 +487,7 @@ toHandle h m = go (toStream m)
487 let stop = return ()
487 let stop = return ()
488 single a = liftIO (IO.hPutStrLn h a)
488 single a = liftIO (IO.hPutStrLn h a)
489 yield a r = liftIO (IO.hPutStrLn h a) >> go r
489 yield a r = liftIO (IO.hPutStrLn h a) >> go r
490− in (C.runStream m1) Nothing stop single yield
490+ in (K.runStream m1) Nothing stop single yield
491
491
492------------------------------------------------------------------------------
492------------------------------------------------------------------------------
493-- Special folds
493-- Special folds
@@ -507,9 +507,9 @@ toList = foldrM (\a xs -> return (a : xs)) []
507take :: IsStream t => Int -> t m a -> t m a
507take :: IsStream t => Int -> t m a -> t m a
508take n m = fromStream $ go n (toStream m)
508take n m = fromStream $ go n (toStream m)
509 where
509 where
510− go n1 m1 = C.Stream $ \_ stp sng yld ->
510+ go n1 m1 = K.Stream $ \_ stp sng yld ->
511 let yield a r = yld a (go (n1 - 1) r)
511 let yield a r = yld a (go (n1 - 1) r)
512− in if n1 <= 0 then stp else (C.runStream m1) Nothing stp sng yield
512+ in if n1 <= 0 then stp else (K.runStream m1) Nothing stp sng yield
513
513
514-- | Include only those elements that pass a predicate.
514-- | Include only those elements that pass a predicate.
515--
515--
@@ -518,12 +518,12 @@ take n m = fromStream $ go n (toStream m)
518filter :: IsStream t => (a -> Bool) -> t m a -> t m a
518filter :: IsStream t => (a -> Bool) -> t m a -> t m a
519filter p m = fromStream $ go (toStream m)
519filter p m = fromStream $ go (toStream m)
520 where
520 where
521− go m1 = C.Stream $ \_ stp sng yld ->
521+ go m1 = K.Stream $ \_ stp sng yld ->
522 let single a | p a = sng a
522 let single a | p a = sng a
523 | otherwise = stp
523 | otherwise = stp
524 yield a r | p a = yld a (go r)
524 yield a r | p a = yld a (go r)
525− | otherwise = (C.runStream r) Nothing stp single yield
525+ | otherwise = (K.runStream r) Nothing stp single yield
526− in (C.runStream m1) Nothing stp single yield
526+ in (K.runStream m1) Nothing stp single yield
527
527
528-- | End the stream as soon as the predicate fails on an element.
528-- | End the stream as soon as the predicate fails on an element.
529--
529--
@@ -532,12 +532,12 @@ filter p m = fromStream $ go (toStream m)
532takeWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
532takeWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
533takeWhile p m = fromStream $ go (toStream m)
533takeWhile p m = fromStream $ go (toStream m)
534 where
534 where
535− go m1 = C.Stream $ \_ stp sng yld ->
535+ go m1 = K.Stream $ \_ stp sng yld ->
536 let single a | p a = sng a
536 let single a | p a = sng a
537 | otherwise = stp
537 | otherwise = stp
538 yield a r | p a = yld a (go r)
538 yield a r | p a = yld a (go r)
539 | otherwise = stp
539 | otherwise = stp
540− in (C.runStream m1) Nothing stp single yield
540+ in (K.runStream m1) Nothing stp single yield
541
541
542-- | Discard first 'n' elements from the stream and take the rest.
542-- | Discard first 'n' elements from the stream and take the rest.
543--
543--
@@ -545,13 +545,13 @@ takeWhile p m = fromStream $ go (toStream m)
545drop :: IsStream t => Int -> t m a -> t m a
545drop :: IsStream t => Int -> t m a -> t m a
546drop n m = fromStream $ go n (toStream m)
546drop n m = fromStream $ go n (toStream m)
547 where
547 where
548− go n1 m1 = C.Stream $ \_ stp sng yld ->
548+ go n1 m1 = K.Stream $ \_ stp sng yld ->
549 let single _ = stp
549 let single _ = stp
550− yield _ r = (C.runStream $ go (n1 - 1) r) Nothing stp sng yld
550+ yield _ r = (K.runStream $ go (n1 - 1) r) Nothing stp sng yld
551 -- Somehow "<=" check performs better than a ">"
551 -- Somehow "<=" check performs better than a ">"
552 in if n1 <= 0
552 in if n1 <= 0
553− then (C.runStream m1) Nothing stp sng yld
553+ then (K.runStream m1) Nothing stp sng yld
554− else (C.runStream m1) Nothing stp single yield
554+ else (K.runStream m1) Nothing stp single yield
555
555
556-- | Drop elements in the stream as long as the predicate succeeds and then
556-- | Drop elements in the stream as long as the predicate succeeds and then
557-- take the rest of the stream.
557-- take the rest of the stream.
@@ -561,12 +561,12 @@ drop n m = fromStream $ go n (toStream m)
561dropWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
561dropWhile :: IsStream t => (a -> Bool) -> t m a -> t m a
562dropWhile p m = fromStream $ go (toStream m)
562dropWhile p m = fromStream $ go (toStream m)
563 where
563 where
564− go m1 = C.Stream $ \_ stp sng yld ->
564+ go m1 = K.Stream $ \_ stp sng yld ->
565 let single a | p a = stp
565 let single a | p a = stp
566 | otherwise = sng a
566 | otherwise = sng a
567− yield a r | p a = (C.runStream r) Nothing stp single yield
567+ yield a r | p a = (K.runStream r) Nothing stp single yield
568 | otherwise = yld a r
568 | otherwise = yld a r
569− in (C.runStream m1) Nothing stp single yield
569+ in (K.runStream m1) Nothing stp single yield
570
570
571-- | Determine whether all elements of a stream satisfy a predicate.
571-- | Determine whether all elements of a stream satisfy a predicate.
572--
572--
@@ -579,7 +579,7 @@ all p m = go (toStream m)
579 | otherwise = return False
579 | otherwise = return False
580 yield a r | p a = go r
580 yield a r | p a = go r
581 | otherwise = return False
581 | otherwise = return False
582− in (C.runStream m1) Nothing (return True) single yield
582+ in (K.runStream m1) Nothing (return True) single yield
583
583
584-- | Determine whether any of the elements of a stream satisfy a predicate.
584-- | Determine whether any of the elements of a stream satisfy a predicate.
585--
585--
@@ -592,7 +592,7 @@ any p m = go (toStream m)
592 | otherwise = return False
592 | otherwise = return False
593 yield a r | p a = return True
593 yield a r | p a = return True
594 | otherwise = go r
594 | otherwise = go r
595− in (C.runStream m1) Nothing (return False) single yield
595+ in (K.runStream m1) Nothing (return False) single yield
596
596
597-- | Determine the sum of all elements of a stream of numbers
597-- | Determine the sum of all elements of a stream of numbers
598--
598--
@@ -614,7 +614,7 @@ head m =
614 let stop = return Nothing
614 let stop = return Nothing
615 single a = return (Just a)
615 single a = return (Just a)
616 yield a _ = return (Just a)
616 yield a _ = return (Just a)
617− in (C.runStream (toStream m)) Nothing stop single yield
617+ in (K.runStream (toStream m)) Nothing stop single yield
618
618
619-- | Extract all but the first element of the stream, if any.
619-- | Extract all but the first element of the stream, if any.
620--
620--
@@ -624,7 +624,7 @@ tail m =
624 let stop = return Nothing
624 let stop = return Nothing
625 single _ = return $ Just nil
625 single _ = return $ Just nil
626 yield _ r = return $ Just $ fromStream r
626 yield _ r = return $ Just $ fromStream r
627− in (C.runStream (toStream m)) Nothing stop single yield
627+ in (K.runStream (toStream m)) Nothing stop single yield
628
628
629-- | Extract the last element of the stream, if any.
629-- | Extract the last element of the stream, if any.
630--
630--
@@ -641,7 +641,7 @@ null m =
641 let stop = return True
641 let stop = return True
642 single _ = return False
642 single _ = return False
643 yield _ _ = return False
643 yield _ _ = return False
644− in (C.runStream (toStream m)) Nothing stop single yield
644+ in (K.runStream (toStream m)) Nothing stop single yield
645
645
646-- | Determine whether an element is present in the stream.
646-- | Determine whether an element is present in the stream.
647--
647--
@@ -653,7 +653,7 @@ elem e m = go (toStream m)
653 let stop = return False
653 let stop = return False
654 single a = return (a == e)
654 single a = return (a == e)
655 yield a r = if a == e then return True else go r
655 yield a r = if a == e then return True else go r
656− in (C.runStream m1) Nothing stop single yield
656+ in (K.runStream m1) Nothing stop single yield
657
657
658-- | Determine whether an element is not present in the stream.
658-- | Determine whether an element is not present in the stream.
659--
659--
@@ -665,7 +665,7 @@ notElem e m = go (toStream m)
665 let stop = return True
665 let stop = return True
666 single a = return (a /= e)
666 single a = return (a /= e)
667 yield a r = if a == e then return False else go r
667 yield a r = if a == e then return False else go r
668− in (C.runStream m1) Nothing stop single yield
668+ in (K.runStream m1) Nothing stop single yield
669
669
670-- | Determine the length of the stream.
670-- | Determine the length of the stream.
671--
671--
@@ -678,14 +678,14 @@ length = foldl (\n _ -> n + 1) 0 id
678--
678--
679-- @since 0.1.1
679-- @since 0.1.1
680reverse :: (IsStream t) => t m a -> t m a
680reverse :: (IsStream t) => t m a -> t m a
681−reverse m = fromStream $ go C.nil (toStream m)
681+reverse m = fromStream $ go K.nil (toStream m)
682 where
682 where
683− go rev rest = C.Stream $ \_ stp sng yld ->
683+ go rev rest = K.Stream $ \_ stp sng yld ->
684− let runIt x = C.runStream x Nothing stp sng yld
684+ let runIt x = K.runStream x Nothing stp sng yld
685 stop = runIt rev
685 stop = runIt rev
686− single a = runIt $ a `C.cons` rev
686+ single a = runIt $ a `K.cons` rev
687− yield a r = runIt $ go (a `C.cons` rev) r
687+ yield a r = runIt $ go (a `K.cons` rev) r
688− in C.runStream rest Nothing stop single yield
688+ in K.runStream rest Nothing stop single yield
689
689
690-- XXX replace the recursive "go" with continuation
690-- XXX replace the recursive "go" with continuation
691-- | Determine the minimum element in a stream.
691-- | Determine the minimum element in a stream.
@@ -698,7 +698,7 @@ minimum m = go Nothing (toStream m)
698 let stop = return res
698 let stop = return res
699 single a = return $ min_ a res
699 single a = return $ min_ a res
700 yield a r = go (min_ a res) r
700 yield a r = go (min_ a res) r
701− in (C.runStream m1) Nothing stop single yield
701+ in (K.runStream m1) Nothing stop single yield
702
702
703 min_ a res = case res of
703 min_ a res = case res of
704 Nothing -> Just a
704 Nothing -> Just a
@@ -715,7 +715,7 @@ maximum m = go Nothing (toStream m)
715 let stop = return res
715 let stop = return res
716 single a = return $ max_ a res
716 single a = return $ max_ a res
717 yield a r = go (max_ a res) r
717 yield a r = go (max_ a res) r
718− in (C.runStream m1) Nothing stop single yield
718+ in (K.runStream m1) Nothing stop single yield
719
719
720 max_ a res = case res of
720 max_ a res = case res of
721 Nothing -> Just a
721 Nothing -> Just a
@@ -743,10 +743,10 @@ maximum m = go Nothing (toStream m)
743mapM :: (IsStream t, MonadAsync m) => (a -> m b) -> t m a -> t m b
743mapM :: (IsStream t, MonadAsync m) => (a -> m b) -> t m a -> t m b
744mapM f m = go (toStream m)
744mapM f m = go (toStream m)
745 where
745 where
746− go m1 = fromStream $ C.Stream $ \svr stp sng yld ->
746+ go m1 = fromStream $ K.Stream $ \svr stp sng yld ->
747 let single a = f a >>= sng
747 let single a = f a >>= sng
748− yield a r = C.runStream (toStream (f a |: (go r))) svr stp sng yld
748+ yield a r = K.runStream (toStream (f a |: (go r))) svr stp sng yld
749− in (C.runStream m1) Nothing stp single yield
749+ in (K.runStream m1) Nothing stp single yield
750
750
751-- | Map a 'Maybe' returning function to a stream, filter out the 'Nothing'
751-- | Map a 'Maybe' returning function to a stream, filter out the 'Nothing'
752-- elements, and return a stream of values extracted from 'Just'.
752-- elements, and return a stream of values extracted from 'Just'.
@@ -756,14 +756,14 @@ mapM f m = go (toStream m)
756mapMaybe :: (IsStream t) => (a -> Maybe b) -> t m a -> t m b
756mapMaybe :: (IsStream t) => (a -> Maybe b) -> t m a -> t m b
757mapMaybe f m = go (toStream m)
757mapMaybe f m = go (toStream m)
758 where
758 where
759− go m1 = fromStream $ C.Stream $ \_ stp sng yld ->
759+ go m1 = fromStream $ K.Stream $ \_ stp sng yld ->
760 let single a = case f a of
760 let single a = case f a of
761 Just b -> sng b
761 Just b -> sng b
762 Nothing -> stp
762 Nothing -> stp
763 yield a r = case f a of
763 yield a r = case f a of
764 Just b -> yld b (toStream $ go r)
764 Just b -> yld b (toStream $ go r)
765− Nothing -> (C.runStream r) Nothing stp single yield
765+ Nothing -> (K.runStream r) Nothing stp single yield
766− in (C.runStream m1) Nothing stp single yield
766+ in (K.runStream m1) Nothing stp single yield
767
767
768-- | Like 'mapMaybe' but maps a monadic function.
768-- | Like 'mapMaybe' but maps a monadic function.
769--
769--
@@ -787,7 +787,7 @@ mapM_ f m = go (toStream m)
787 let stop = return ()
787 let stop = return ()
788 single a = void (f a)
788 single a = void (f a)
789 yield a r = f a >> go r
789 yield a r = f a >> go r
790− in (C.runStream m1) Nothing stop single yield
790+ in (K.runStream m1) Nothing stop single yield
791
791
792-- | Reduce a stream of monadic actions to a stream of the output of those
792-- | Reduce a stream of monadic actions to a stream of the output of those
793-- actions.
793-- actions.
@@ -806,7 +806,7 @@ mapM_ f m = go (toStream m)
806sequence :: (IsStream t, MonadAsync m) => t m (m a) -> t m a
806sequence :: (IsStream t, MonadAsync m) => t m (m a) -> t m a
807sequence m = go (toStream m)
807sequence m = go (toStream m)
808 where
808 where
809− go m1 = fromStream $ C.Stream $ \svr stp sng yld ->
809+ go m1 = fromStream $ K.Stream $ \svr stp sng yld ->
810 let single ma = ma >>= sng
810 let single ma = ma >>= sng
811− yield ma r = C.runStream (toStream $ ma |: go r) svr stp sng yld
811+ yield ma r = K.runStream (toStream $ ma |: go r) svr stp sng yld
812− in (C.runStream m1) Nothing stp single yield
812+ in (K.runStream m1) Nothing stp single yield
src/Streamly/Streams/Ahead.hs+1−1
@@ -44,7 +44,7 @@ import Data.Semigroup (Semigroup(..))
44import qualified Data.Heap as H
44import qualified Data.Heap as H
45
45
46import Streamly.Streams.SVar (fromSVar)
46import Streamly.Streams.SVar (fromSVar)
47−import Streamly.Streams.CPS
47+import Streamly.Streams.StreamK
48import Streamly.SVar
48import Streamly.SVar
49
49
50#ifdef DIAGNOSTICS
50#ifdef DIAGNOSTICS
src/Streamly/Streams/Async.hs+1−1
@@ -52,7 +52,7 @@ import Data.Semigroup (Semigroup(..))
52import qualified Data.Set as S
52import qualified Data.Set as S
53
53
54import Streamly.Streams.SVar (fromSVar)
54import Streamly.Streams.SVar (fromSVar)
55−import Streamly.Streams.CPS
55+import Streamly.Streams.StreamK
56import Streamly.SVar
56import Streamly.SVar
57
57
58#include "Instances.hs"
58#include "Instances.hs"
src/Streamly/Streams/Parallel.hs+1−1
@@ -47,7 +47,7 @@ import Data.Functor (void)
47import Data.Semigroup (Semigroup(..))
47import Data.Semigroup (Semigroup(..))
48
48
49import Streamly.Streams.SVar (fromSVar)
49import Streamly.Streams.SVar (fromSVar)
50−import Streamly.Streams.CPS
50+import Streamly.Streams.StreamK
51import Streamly.SVar
51import Streamly.SVar
52
52
53#include "Instances.hs"
53#include "Instances.hs"
src/Streamly/Streams/Prelude.hs+4−4
@@ -40,8 +40,8 @@ where
40import Streamly.Streams.Serial (SerialT)
40import Streamly.Streams.Serial (SerialT)
41import Streamly.SVar (SVar)
41import Streamly.SVar (SVar)
42
42
43−import Streamly.Streams.CPS hiding (runStream)
43+import Streamly.Streams.StreamK hiding (runStream)
44−import qualified Streamly.Streams.CPS as C
44+import qualified Streamly.Streams.StreamK as K
45
45
46------------------------------------------------------------------------------
46------------------------------------------------------------------------------
47-- Fold Utilities
47-- Fold Utilities
@@ -126,7 +126,7 @@ unfoldrM step = go
126 case mayb of
126 case mayb of
127 Nothing -> stp
127 Nothing -> stp
128 Just (a, b) ->
128 Just (a, b) ->
129− C.runStream (a `cons` go b) svr stp sng yld
129+ K.runStream (a `cons` go b) svr stp sng yld
130-}
130-}
131
131
132------------------------------------------------------------------------------
132------------------------------------------------------------------------------
@@ -146,7 +146,7 @@ streamFold
146 -> m r
146 -> m r
147streamFold svr step single blank m =
147streamFold svr step single blank m =
148 let yield a x = step a (fromStream x)
148 let yield a x = step a (fromStream x)
149− in (C.runStream (toStream m)) svr blank single yield
149+ in (K.runStream (toStream m)) svr blank single yield
150
150
151-- | Run a streaming composition, discard the results. By default it interprets
151-- | Run a streaming composition, discard the results. By default it interprets
152-- the stream as 'SerialT', to run other types of streams use the type adapting
152-- the stream as 'SerialT', to run other types of streams use the type adapting
src/Streamly/Streams/SVar.hs+2−2
@@ -10,7 +10,7 @@
10{-# LANGUAGE UndecidableInstances #-} -- XXX
10{-# LANGUAGE UndecidableInstances #-} -- XXX
11
11
12-- |
12-- |
13−-- Module : Streamly.CPS.Concurrent
13+-- Module : Streamly.Streams.SVar
14-- Copyright : (c) 2017 Harendra Kumar
14-- Copyright : (c) 2017 Harendra Kumar
15--
15--
16-- License : BSD3
16-- License : BSD3
@@ -29,7 +29,7 @@ where
29import Control.Monad.Catch (throwM)
29import Control.Monad.Catch (throwM)
30
30
31import Streamly.SVar
31import Streamly.SVar
32−import Streamly.Streams.CPS
32+import Streamly.Streams.StreamK
33
33
34-- MVar diagnostics has some overhead - around 5% on asyncly null benchmark, we
34-- MVar diagnostics has some overhead - around 5% on asyncly null benchmark, we
35-- can keep it on in production to debug problems quickly if and when they
35-- can keep it on in production to debug problems quickly if and when they
src/Streamly/Streams/Serial.hs+2−2
@@ -52,8 +52,8 @@ import Control.Monad.State.Class (MonadState(..))
52import Control.Monad.Trans.Class (MonadTrans(lift))
52import Control.Monad.Trans.Class (MonadTrans(lift))
53import Data.Semigroup (Semigroup(..))
53import Data.Semigroup (Semigroup(..))
54
54
55−import Streamly.Streams.CPS hiding (serial)
55+import Streamly.Streams.StreamK hiding (serial)
56−import qualified Streamly.Streams.CPS as C
56+import qualified Streamly.Streams.StreamK as C
57
57
58#include "Instances.hs"
58#include "Instances.hs"
59
59
src/Streamly/Streams/CPS.hs → src/Streamly/Streams/StreamK.hsrenamed+2−2
@@ -11,7 +11,7 @@
11{-# LANGUAGE UndecidableInstances #-} -- XXX
11{-# LANGUAGE UndecidableInstances #-} -- XXX
12
12
13-- |
13-- |
14−-- Module : Streamly.Streams.CPS
14+-- Module : Streamly.Streams.StreamK
15-- Copyright : (c) 2017 Harendra Kumar
15-- Copyright : (c) 2017 Harendra Kumar
16--
16--
17-- License : BSD3
17-- License : BSD3
@@ -20,7 +20,7 @@
20-- Portability : GHC
20-- Portability : GHC
21--
21--
22--
22--
23−module Streamly.Streams.CPS
23+module Streamly.Streams.StreamK
24 (
24 (
25 -- * Streams
25 -- * Streams
26 IsStream (..)
26 IsStream (..)
src/Streamly/Streams/Zip.hs+1−1
@@ -44,7 +44,7 @@ import Data.Semigroup (Semigroup(..))
44import Prelude hiding (repeat, zipWith)
44import Prelude hiding (repeat, zipWith)
45
45
46import Streamly.Streams.Async (mkAsync)
46import Streamly.Streams.Async (mkAsync)
47−import Streamly.Streams.CPS
47+import Streamly.Streams.StreamK
48import Streamly.SVar (MonadAsync)
48import Streamly.SVar (MonadAsync)
49
49
50#include "Instances.hs"
50#include "Instances.hs"
streamly.cabal+1−1
@@ -108,7 +108,7 @@ flag examples-sdl
108library
108library
109 hs-source-dirs: src
109 hs-source-dirs: src
110 other-modules: Streamly.SVar
110 other-modules: Streamly.SVar
111− , Streamly.Streams.CPS
111+ , Streamly.Streams.StreamK
112 , Streamly.Streams.Serial
112 , Streamly.Streams.Serial
113 , Streamly.Streams.SVar
113 , Streamly.Streams.SVar
114 , Streamly.Streams.Async
114 , Streamly.Streams.Async