@@ -185,7 +185,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
185-- represents a single IO action whereas the 'Serial' monad represents a series
185-- represents a single IO action whereas the 'Serial' monad represents a series
186-- of IO actions. The only change you need to make to go from 'IO' to 'Serial'
186-- of IO actions. The only change you need to make to go from 'IO' to 'Serial'
187-- is to use 'runStream' to run the monad and to prefix the IO actions with
187-- is to use 'runStream' to run the monad and to prefix the IO actions with
188−-- either 'once' or 'liftIO'. If you use liftIO you can switch from 'Serial'
188+-- either 'yieldM' or 'liftIO'. If you use liftIO you can switch from 'Serial'
189-- to IO monad by simply removing the 'runStream' function; no other changes
189-- to IO monad by simply removing the 'runStream' function; no other changes
190-- are needed unless you have used some stream specific composition or
190-- are needed unless you have used some stream specific composition or
191-- combinators.
191-- combinators.
@@ -347,13 +347,17 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
347-- ["hello","world"]
347-- ["hello","world"]
350−-- To create a singleton stream from a pure value use 'pure' and to create a
350+-- To create a singleton stream from a pure value use 'yield' or 'pure' and to
351−-- singleton stream from a monadic action use 'once'.
351+-- create a singleton stream from a monadic action use 'yieldM'. Note that in
352+-- case of Zip applicative streams "pure" repeats the value to generate an
354-- > S.'toList' $ 'pure' 1
356-- > S.'toList' $ 'pure' 1
356−-- > S.'toList' $ S.'once' 'getLine'
358+-- > S.'toList' $ 'yield' 1
360+-- > S.'toList' $ S.'yieldM' 'getLine'
358-- ["hello"]
362-- ["hello"]
@@ -506,7 +510,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
506-- seconds. After the delay it prints the number of seconds it slept.
510-- seconds. After the delay it prints the number of seconds it slept.
509−-- delay n = S.'once' $ do
513+-- delay n = S.'yieldM' $ do
510-- threadDelay (n * 1000000)
514-- threadDelay (n * 1000000)
511-- tid \<- myThreadId
515-- tid \<- myThreadId
512-- putStrLn (show tid ++ ": Delay " ++ show n)
516-- putStrLn (show tid ++ ": Delay " ++ show n)
@@ -737,7 +741,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
739-- main = 'runStream' . 'asyncly' $ traced (sqrt 9) '<>' traced (sqrt 16) '<>' traced (sqrt 25)
743-- main = 'runStream' . 'asyncly' $ traced (sqrt 9) '<>' traced (sqrt 16) '<>' traced (sqrt 25)
740−-- where traced m = S.'once' (myThreadId >>= print) >> return m
744+-- where traced m = S.'yieldM' (myThreadId >>= print) >> return m
743-- ThreadId 40
747-- ThreadId 40
@@ -859,7 +863,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
859-- google = get "https://www.google.com/search?q=haskell"
863-- google = get "https://www.google.com/search?q=haskell"
860-- bing = get "https://www.bing.com/search?q=haskell"
864-- bing = get "https://www.bing.com/search?q=haskell"
861-- duckduckgo = get "https://www.duckduckgo.com/?q=haskell"
865-- duckduckgo = get "https://www.duckduckgo.com/?q=haskell"
862−-- get s = S.'once' (httpNoBody (parseRequest_ s) >> putStrLn (show s))
866+-- get s = S.'yieldM' (httpNoBody (parseRequest_ s) >> putStrLn (show s))
865-- The polymorphic version of the binary operation '<>' of the 'Parallel' type
869-- The polymorphic version of the binary operation '<>' of the 'Parallel' type
@@ -918,7 +922,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
918-- 'runStream' $ 'foldWith' 'async' (map delay [1..10])
922-- 'runStream' $ 'foldWith' 'async' (map delay [1..10])
919-- 'runStream' $ 'foldMapWith' 'async' delay [1..10]
923-- 'runStream' $ 'foldMapWith' 'async' delay [1..10]
920-- 'runStream' $ 'forEachWith' 'async' [1..10] delay
924-- 'runStream' $ 'forEachWith' 'async' [1..10] delay
921−-- where delay n = S.'once' $ threadDelay (n * 1000000) >> print n
925+-- where delay n = S.'yieldM' $ threadDelay (n * 1000000) >> print n
924-- $nesting
928-- $nesting
@@ -988,7 +992,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
988-- import "Streamly"
992-- import "Streamly"
989-- import qualified "Streamly.Prelude" as S
993-- import qualified "Streamly.Prelude" as S
991−-- main = 'runStream' $ forever $ S.once getLine >>= S.once . putStrLn
995+-- main = 'runStream' $ forever $ S.yieldM getLine >>= S.yieldM . putStrLn
994-- When multiple streams are composed using this style they nest in a DFS
998-- When multiple streams are composed using this style they nest in a DFS
@@ -1003,7 +1007,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1003-- main = 'runStream' $ do
1007-- main = 'runStream' $ do
1004-- x <- S.'fromFoldable' [1,2]
1008-- x <- S.'fromFoldable' [1,2]
1005-- y <- S.'fromFoldable' [3,4]
1009-- y <- S.'fromFoldable' [3,4]
1006−-- S.'once' $ putStrLn $ show (x, y)
1010+-- S.'yieldM' $ putStrLn $ show (x, y)
@@ -1100,7 +1104,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1100-- main = 'runStream' . 'asyncly' $ do
1104-- main = 'runStream' . 'asyncly' $ do
1101-- x <- S.'fromFoldable' [1,2]
1105-- x <- S.'fromFoldable' [1,2]
1102-- y <- S.'fromFoldable' [3,4]
1106-- y <- S.'fromFoldable' [3,4]
1103−-- S.'once' $ putStrLn $ show (x, y)
1107+-- S.'yieldM' $ putStrLn $ show (x, y)
@@ -1125,7 +1129,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1125-- main = 'runStream' . 'wSerially' $ do
1129-- main = 'runStream' . 'wSerially' $ do
1126-- x <- S.'fromFoldable' [1,2]
1130-- x <- S.'fromFoldable' [1,2]
1127-- y <- S.'fromFoldable' [3,4]
1131-- y <- S.'fromFoldable' [3,4]
1128−-- S.once $ putStrLn $ show (x, y)
1132+-- S.yieldM $ putStrLn $ show (x, y)
@@ -1153,7 +1157,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1153-- main = 'runStream' . 'wAsyncly' $ do
1157-- main = 'runStream' . 'wAsyncly' $ do
1154-- x <- S.'fromFoldable' [1,2]
1158-- x <- S.'fromFoldable' [1,2]
1155-- y <- S.'fromFoldable' [3,4]
1159-- y <- S.'fromFoldable' [3,4]
1156−-- S.'once' $ putStrLn $ show (x, y)
1160+-- S.'yieldM' $ putStrLn $ show (x, y)
@@ -1202,7 +1206,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1202-- sz <- sizes
1206-- sz <- sizes
1203-- cl <- colors
1207-- cl <- colors
1204-- sh <- shapes
1208-- sh <- shapes
1205−-- S.'once' $ putStrLn $ show (sz, cl, sh)
1209+-- S.'yieldM' $ putStrLn $ show (sz, cl, sh)