@@ -150,17 +150,19 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
151-- $eliminating
151-- $eliminating
153−-- 'runAsyncly' runs composed actions in the 'AsyncT' monad, lowering the type
153+-- 'runStreaming' runs composed actions in a streaming monad, lowering the type
154-- into the underlying monad and discarding the values generated by the stream;
154-- into the underlying monad and discarding the values generated by the stream;
155-- 'toList' collects the resulting stream in a list. 'uncons' can be used
155-- 'toList' collects the resulting stream in a list. 'uncons' can be used
156−-- to deconstruct an 'AsyncT' stream into head and tail.
156+-- to deconstruct a stream into head and tail. Before you run a stream you need
157+-- to express the type of the stream by using one of the streaming type
158+-- combinators ('serially', 'asyncly', 'parallely' etc.).
159-- import Streamly
161-- import Streamly
161-- main = do
163-- main = do
162−-- runAsyncly $ liftIO $ putStrLn "Hello world!"
164+-- runStreaming $ serially $ liftIO $ putStrLn "Hello world!"
163−-- xs \<- toList $ return 1 <> return 2
165+-- xs \<- toList $ serially $ return 1 <> return 2
164-- print xs
166-- print xs
@@ -191,7 +193,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
191-- prints the sequence 3, 2, 1 and takes a total of 6 seconds:
193-- prints the sequence 3, 2, 1 and takes a total of 6 seconds:
194−-- main = runAsyncly $ timer 3 <> timer 2 <> timer 1
196+-- main = runStreaming $ serially $ timer 3 <> timer 2 <> timer 1
197-- ThreadId 36: Timer 3
199-- ThreadId 36: Timer 3
@@ -205,7 +207,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
205-- following example should print the sequence 1, 3, 2, 4:
207-- following example should print the sequence 1, 3, 2, 4:
208−-- main = runAsyncly $ (timer 1 <> timer 2) \<=> (timer 3 <> timer 4)
210+-- main = runStreaming $ serially $ (timer 1 <> timer 2) \<=> (timer 3 <> timer 4)
211-- ThreadId 36: Timer 1
213-- ThreadId 36: Timer 1
@@ -232,7 +234,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
232-- computation to keep up even if none of them blocks:
234-- computation to keep up even if none of them blocks:
235−-- main = runAsyncly $ traced (sqrt 9) <| traced (sqrt 16) <| traced (sqrt 25)
237+-- main = runStreaming $ serially $ traced (sqrt 9) <| traced (sqrt 16) <| traced (sqrt 25)
238-- ThreadId 40
240-- ThreadId 40
@@ -244,7 +246,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
244-- next one in a separate thread and so on:
246-- next one in a separate thread and so on:
247−-- main = runAsyncly $ timer 3 <| timer 2 <| timer 1
249+-- main = runStreaming $ serially $ timer 3 <| timer 2 <| timer 1
250-- ThreadId 42: Timer 1
252-- ThreadId 42: Timer 1
@@ -255,7 +257,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
255-- When we have a hierarchy of computations this operator follows DFS style:
257-- When we have a hierarchy of computations this operator follows DFS style:
258−-- main = runAsyncly $ (p 1 <| p 2) <| (p 3 <| p 4)
260+-- main = runStreaming $ serially $ (p 1 <| p 2) <| (p 3 <| p 4)
259-- where p = liftIO . print
261-- where p = liftIO . print
@@ -292,7 +294,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
292-- import Streamly
294-- import Streamly
293-- import Network.HTTP.Simple
295-- import Network.HTTP.Simple
295−-- main = runAsyncly $ google \<|> bing \<|> duckduckgo
297+-- main = runStreaming $ serially $ google \<|> bing \<|> duckduckgo
297-- google = get "https://www.google.com/search?q=haskell"
299-- google = get "https://www.google.com/search?q=haskell"
298-- bing = get "https://www.bing.com/search?q=haskell"
300-- bing = get "https://www.bing.com/search?q=haskell"
@@ -327,11 +329,11 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
327-- import Streamly
329-- import Streamly
329-- main = do
331-- main = do
330−-- runAsyncly $ liftIO $ putStrLn "Hello world!"
332+-- runStreaming $ serially $ liftIO $ putStrLn "Hello world!"
331−-- xs \<- toList $ return 1 <> return 2; print xs
333+-- xs \<- toList . serially $ return 1 <> return 2; print xs
332−-- xs \<- toList $ foldWith (<>) (map return [1..10]); print xs
334+-- xs \<- toList . serially $ foldWith (<>) (map return [1..10]); print xs
333−-- xs \<- toList $ foldMapWith (<>) return [1..10]; print xs
335+-- xs \<- toList . serially $ foldMapWith (<>) return [1..10]; print xs
334−-- xs \<- toList $ forEachWith (<>) [1..10] return; print xs
336+-- xs \<- toList . serially $ forEachWith (<>) [1..10] return; print xs
337-- $transforming
339-- $transforming
@@ -348,7 +350,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
349-- $functor
351-- $functor
351−-- The simplest way to transform an 'AsyncT' stream is by mapping a function on
353+-- The simplest way to transform a stream is by mapping a function on
352-- all elements of the stream using 'fmap'.
354-- all elements of the stream using 'fmap'.
@@ -357,7 +359,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
357-- main = do
359-- main = do
358-- let nums = foldMapWith (<>) return [1..10]
360-- let nums = foldMapWith (<>) return [1..10]
359-- let strings = fmap show nums
361-- let strings = fmap show nums
360−-- (toList $ fmap putStrLn strings) >>= sequence
362+-- (toList $ serially $ fmap putStrLn strings) >>= sequence
363-- $applicative
365-- $applicative
@@ -374,7 +376,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
374-- The following example prints all combinations of size, color and shape:
376-- The following example prints all combinations of size, color and shape:
377−-- main = (toList $ (,,) \<$> sizes \<*> colors \<*> shapes) >>= print
379+-- main = (toList . serially $ (,,) \<$> sizes \<*> colors \<*> shapes) >>= print
@@ -398,7 +400,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
398-- import Streamly
400-- import Streamly
399-- import Data.Semigroup (cycle1)
401-- import Data.Semigroup (cycle1)
401−-- main = runAsyncly $ do
403+-- main = runStreaming $ serially $ do
402-- str <- cycle1 (liftIO getLine)
404-- str <- cycle1 (liftIO getLine)
403-- liftIO $ putStrLn str
405-- liftIO $ putStrLn str
@@ -408,7 +410,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
408-- combinations of size, color and shape.
410-- combinations of size, color and shape.
411−-- main = runAsyncly $ do
413+-- main = runStreaming $ serially $ do
412-- sz <- sizes
414-- sz <- sizes
413-- cl <- colors
415-- cl <- colors
414-- sh <- shapes
416-- sh <- shapes
@@ -425,17 +427,13 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
426-- $interleavedNesting
428-- $interleavedNesting
428−-- Instead of the regular bind operation (>>=) we can use the interleaved bind
429−-- operator (>->) to interleave the iterations of the nested loops. For
433-- import Streamly
431-- import Streamly
435−-- main = runAsyncly $
433+-- main = runStreaming $ interleaved $
436−-- sizes >-> \\sz ->
434+-- sz <- sizes
437−-- colors >-> \\cl ->
435+-- cl <- colors
438−-- shapes >-> \\sh ->
436+-- sh <- shapes
439-- liftIO $ putStrLn $ show (sz, cl, sh)
437-- liftIO $ putStrLn $ show (sz, cl, sh)
@@ -458,12 +456,12 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
458-- tid <- myThreadId
456-- tid <- myThreadId
459-- putStrLn (show tid ++ ": " ++ s)
457-- putStrLn (show tid ++ ": " ++ s)
461−-- main = runAsyncly $ do
459+-- main = runStreaming $ asyncly $ do
462-- liftIO $ hSetBuffering stdout LineBuffering
460-- liftIO $ hSetBuffering stdout LineBuffering
463−-- sizes >>| \\sz ->
461+-- sz <- sizes
464−-- colors >>| \\cl ->
462+-- cl <- colors
465−-- shapes >>| \\sh ->
463+-- sh <- shapes
466−-- liftIO $ printWithTid $ show (sz, cl, sh)
464+-- liftIO $ putStrLn $ show (sz, cl, sh)
@@ -485,12 +483,12 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
485-- tid <- myThreadId
483-- tid <- myThreadId
486-- putStrLn (show tid ++ ": " ++ s)
484-- putStrLn (show tid ++ ": " ++ s)
488−-- main = runAsyncly $ do
486+-- main = runStreaming $ parallely $ do
489-- liftIO $ hSetBuffering stdout LineBuffering
487-- liftIO $ hSetBuffering stdout LineBuffering
490−-- sizes >|> \\sz ->
488+-- sz <- sizes
491−-- colors >|> \\cl ->
489+-- cl <- colors
492−-- shapes >|> \\sh ->
490+-- sh <- shapes
493−-- liftIO $ printWithTid $ show (sz, cl, sh)
491+-- liftIO $ putStrLn $ show (sz, cl, sh)
@@ -520,7 +518,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
520-- import Data.List (sum)
518-- import Data.List (sum)
522-- main = do
520-- main = do
523−-- squares \<- toList $ foldMapWith (<|) (\x -\> return $ x * x) [1..100]
521+-- squares \<- toList $ serially $ foldMapWith (<|) (\x -\> return $ x * x) [1..100]
524-- print $ sum squares
522-- print $ sum squares
@@ -533,8 +531,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
533-- import Data.List (sum)
531-- import Data.List (sum)
535-- main = do
533-- main = do
536−-- z \<- toList $ foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>| \\xsq ->
534+-- z \<- toList $ asyncly $ foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>= \\xsq ->
537−-- foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>| \\ysq ->
535+-- foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>= \\ysq ->
538-- return $ sqrt (xsq + ysq)
536-- return $ sqrt (xsq + ysq)
539-- print $ sum z
537-- print $ sum z
@@ -580,7 +578,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
580-- main = do
578-- main = do
581-- putStrLn "Your health is deteriorating due to acid rain,\
579-- putStrLn "Your health is deteriorating due to acid rain,\
582-- \ type \"potion\" or \"quit\""
580-- \ type \"potion\" or \"quit\""
583−-- runStateT (runAsyncly game) 60
581+-- runStateT (runStreaming $ serially $ game) 60
586-- $statemachine
584-- $statemachine