@@ -150,17 +150,19 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
150150
151151-- $eliminating
152152--
153−-- 'runAsyncly' runs composed actions in the 'AsyncT' monad, lowering the type
153+-- 'runStreaming' runs composed actions in a streaming monad, lowering the type
154154-- into the underlying monad and discarding the values generated by the stream;
155155-- '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.).
157159--
158160-- @
159161-- import Streamly
160162--
161163-- main = do
162−-- runAsyncly $ liftIO $ putStrLn "Hello world!"
163−-- xs \<- toList $ return 1 <> return 2
164+-- runStreaming $ serially $ liftIO $ putStrLn "Hello world!"
165+-- xs \<- toList $ serially $ return 1 <> return 2
164166-- print xs
165167-- @
166168
@@ -191,7 +193,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
191193-- prints the sequence 3, 2, 1 and takes a total of 6 seconds:
192194--
193195-- @
194−-- main = runAsyncly $ timer 3 <> timer 2 <> timer 1
196+-- main = runStreaming $ serially $ timer 3 <> timer 2 <> timer 1
195197-- @
196198-- @
197199-- ThreadId 36: Timer 3
@@ -205,7 +207,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
205207-- following example should print the sequence 1, 3, 2, 4:
206208--
207209-- @
208−-- main = runAsyncly $ (timer 1 <> timer 2) \<=> (timer 3 <> timer 4)
210+-- main = runStreaming $ serially $ (timer 1 <> timer 2) \<=> (timer 3 <> timer 4)
209211-- @
210212-- @
211213-- ThreadId 36: Timer 1
@@ -232,7 +234,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
232234-- computation to keep up even if none of them blocks:
233235--
234236-- @
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)
236238-- @
237239-- @
238240-- ThreadId 40
@@ -244,7 +246,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
244246-- next one in a separate thread and so on:
245247--
246248-- @
247−-- main = runAsyncly $ timer 3 <| timer 2 <| timer 1
249+-- main = runStreaming $ serially $ timer 3 <| timer 2 <| timer 1
248250-- @
249251-- @
250252-- ThreadId 42: Timer 1
@@ -255,7 +257,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
255257-- When we have a hierarchy of computations this operator follows DFS style:
256258--
257259-- @
258−-- main = runAsyncly $ (p 1 <| p 2) <| (p 3 <| p 4)
260+-- main = runStreaming $ serially $ (p 1 <| p 2) <| (p 3 <| p 4)
259261-- where p = liftIO . print
260262-- @
261263-- @
@@ -292,7 +294,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
292294-- import Streamly
293295-- import Network.HTTP.Simple
294296--
295−-- main = runAsyncly $ google \<|> bing \<|> duckduckgo
297+-- main = runStreaming $ serially $ google \<|> bing \<|> duckduckgo
296298-- where
297299-- google = get "https://www.google.com/search?q=haskell"
298300-- bing = get "https://www.bing.com/search?q=haskell"
@@ -327,11 +329,11 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
327329-- import Streamly
328330--
329331-- main = do
330−-- runAsyncly $ liftIO $ putStrLn "Hello world!"
331−-- xs \<- toList $ return 1 <> return 2; print xs
332−-- xs \<- toList $ foldWith (<>) (map return [1..10]); print xs
333−-- xs \<- toList $ foldMapWith (<>) return [1..10]; print xs
334−-- xs \<- toList $ forEachWith (<>) [1..10] return; print xs
332+-- runStreaming $ serially $ liftIO $ putStrLn "Hello world!"
333+-- xs \<- toList . serially $ return 1 <> return 2; print xs
334+-- xs \<- toList . serially $ foldWith (<>) (map return [1..10]); print xs
335+-- xs \<- toList . serially $ foldMapWith (<>) return [1..10]; print xs
336+-- xs \<- toList . serially $ forEachWith (<>) [1..10] return; print xs
335337-- @
336338
337339-- $transforming
@@ -348,7 +350,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
348350
349351-- $functor
350352--
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
352354-- all elements of the stream using 'fmap'.
353355--
354356-- @
@@ -357,7 +359,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
357359-- main = do
358360-- let nums = foldMapWith (<>) return [1..10]
359361-- let strings = fmap show nums
360−-- (toList $ fmap putStrLn strings) >>= sequence
362+-- (toList $ serially $ fmap putStrLn strings) >>= sequence
361363-- @
362364
363365-- $applicative
@@ -374,7 +376,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
374376-- The following example prints all combinations of size, color and shape:
375377--
376378-- @
377−-- main = (toList $ (,,) \<$> sizes \<*> colors \<*> shapes) >>= print
379+-- main = (toList . serially $ (,,) \<$> sizes \<*> colors \<*> shapes) >>= print
378380--
379381-- where
380382--
@@ -398,7 +400,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
398400-- import Streamly
399401-- import Data.Semigroup (cycle1)
400402--
401−-- main = runAsyncly $ do
403+-- main = runStreaming $ serially $ do
402404-- str <- cycle1 (liftIO getLine)
403405-- liftIO $ putStrLn str
404406-- @
@@ -408,7 +410,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
408410-- combinations of size, color and shape.
409411--
410412-- @
411−-- main = runAsyncly $ do
413+-- main = runStreaming $ serially $ do
412414-- sz <- sizes
413415-- cl <- colors
414416-- sh <- shapes
@@ -425,17 +427,13 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
425427
426428-- $interleavedNesting
427429--
428−-- Instead of the regular bind operation (>>=) we can use the interleaved bind
429−-- operator (>->) to interleave the iterations of the nested loops. For
430−-- example:
431−--
432430-- @
433431-- import Streamly
434432--
435−-- main = runAsyncly $
436−-- sizes >-> \\sz ->
437−-- colors >-> \\cl ->
438−-- shapes >-> \\sh ->
433+-- main = runStreaming $ interleaved $
434+-- sz <- sizes
435+-- cl <- colors
436+-- sh <- shapes
439437-- liftIO $ putStrLn $ show (sz, cl, sh)
440438--
441439-- where
@@ -458,12 +456,12 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
458456-- tid <- myThreadId
459457-- putStrLn (show tid ++ ": " ++ s)
460458--
461−-- main = runAsyncly $ do
459+-- main = runStreaming $ asyncly $ do
462460-- liftIO $ hSetBuffering stdout LineBuffering
463−-- sizes >>| \\sz ->
464−-- colors >>| \\cl ->
465−-- shapes >>| \\sh ->
466−-- liftIO $ printWithTid $ show (sz, cl, sh)
461+-- sz <- sizes
462+-- cl <- colors
463+-- sh <- shapes
464+-- liftIO $ putStrLn $ show (sz, cl, sh)
467465--
468466-- where
469467--
@@ -485,12 +483,12 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
485483-- tid <- myThreadId
486484-- putStrLn (show tid ++ ": " ++ s)
487485--
488−-- main = runAsyncly $ do
486+-- main = runStreaming $ parallely $ do
489487-- liftIO $ hSetBuffering stdout LineBuffering
490−-- sizes >|> \\sz ->
491−-- colors >|> \\cl ->
492−-- shapes >|> \\sh ->
493−-- liftIO $ printWithTid $ show (sz, cl, sh)
488+-- sz <- sizes
489+-- cl <- colors
490+-- sh <- shapes
491+-- liftIO $ putStrLn $ show (sz, cl, sh)
494492--
495493-- where
496494--
@@ -520,7 +518,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
520518-- import Data.List (sum)
521519--
522520-- main = do
523−-- squares \<- toList $ foldMapWith (<|) (\x -\> return $ x * x) [1..100]
521+-- squares \<- toList $ serially $ foldMapWith (<|) (\x -\> return $ x * x) [1..100]
524522-- print $ sum squares
525523-- @
526524--
@@ -533,8 +531,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
533531-- import Data.List (sum)
534532--
535533-- main = do
536−-- z \<- toList $ foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>| \\xsq ->
537−-- foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>| \\ysq ->
534+-- z \<- toList $ asyncly $ foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>= \\xsq ->
535+-- foldMapWith (\<|) (\\x -> return $ x * x) [1..100] >>= \\ysq ->
538536-- return $ sqrt (xsq + ysq)
539537-- print $ sum z
540538-- @
@@ -580,7 +578,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
580578-- main = do
581579-- putStrLn "Your health is deteriorating due to acid rain,\
582580-- \ type \"potion\" or \"quit\""
583−-- runStateT (runAsyncly game) 60
581+-- runStateT (runStreaming $ serially $ game) 60
584582-- @
585583
586584-- $statemachine