@@ -182,6 +182,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
184-- import "Streamly"
184-- import "Streamly"
185+-- import "Streamly.Prelude"
186-- main = do
187-- main = do
187-- xs \<- 'toList' $ 'serially' $ return 1 <> return 2
188-- xs \<- 'toList' $ 'serially' $ return 1 <> return 2
@@ -369,6 +370,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
371-- import "Streamly"
372-- import "Streamly"
373+-- import "Streamly.Prelude"
373-- main = do
375-- main = do
374-- 'toList' . 'serially' $ 'foldWith' (<>) (map return [1..10]) >>= print
376-- 'toList' . 'serially' $ 'foldWith' (<>) (map return [1..10]) >>= print
@@ -408,6 +410,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
408-- list transformer like serial composition.
410-- list transformer like serial composition.
414+-- import "Streamly.Prelude"
411-- main = 'runStreamT' $ do
416-- main = 'runStreamT' $ do
412-- x <- 'each' [3,2,1]
417-- x <- 'each' [3,2,1]
413-- delay x
418-- delay x
@@ -423,12 +428,25 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
423-- same thread one after another. When compared to imperative programming, this
428-- same thread one after another. When compared to imperative programming, this
424-- can also be viewed as a @for@ loop with three iterations.
429-- can also be viewed as a @for@ loop with three iterations.
431+-- A console echo loop copying standard input to standard output can simply be
432+-- written like this:
436+-- import Data.Semigroup (cycle1)
438+-- main = 'runStreamT' $ cycle1 (liftIO getLine) >>= liftIO . putStrLn
426-- When multiple streams are composed using this style they nest in a DFS
441-- When multiple streams are composed using this style they nest in a DFS
427-- manner i.e. nested iterations of an iteration are executed before we proceed
442-- manner i.e. nested iterations of an iteration are executed before we proceed
428-- to the next iteration at higher level. This behaves just like nested @for@
443-- to the next iteration at higher level. This behaves just like nested @for@
429-- loops in imperative programming.
444-- loops in imperative programming.
448+-- import "Streamly.Prelude"
432-- main = 'runStreamT' $ do
450-- main = 'runStreamT' $ do
433-- x <- 'each' [1,2]
451-- x <- 'each' [1,2]
434-- y <- 'each' [3,4]
452-- y <- 'each' [3,4]
@@ -454,6 +472,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
454-- This is the concurrent version of 'StreamT'.
472-- This is the concurrent version of 'StreamT'.
476+-- import "Streamly.Prelude"
457-- main = 'runAsyncT' $ do
478-- main = 'runAsyncT' $ do
458-- x <- 'each' [3,2,1]
479-- x <- 'each' [3,2,1]
459-- delay x
480-- delay x
@@ -478,6 +499,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
478-- demand from the consumer.
499-- demand from the consumer.
503+-- import "Streamly.Prelude"
481-- main = 'runAsyncT' $ do
505-- main = 'runAsyncT' $ do
482-- x <- 'each' [1,2]
506-- x <- 'each' [1,2]
483-- y <- 'each' [3,4]
507-- y <- 'each' [3,4]
@@ -501,6 +525,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
501-- the continuations or iterations of the inner loop.
525-- the continuations or iterations of the inner loop.
529+-- import "Streamly.Prelude"
504-- main = 'runInterleavedT' $ do
531-- main = 'runInterleavedT' $ do
505-- x <- 'each' [1,2]
532-- x <- 'each' [1,2]
506-- y <- 'each' [3,4]
533-- y <- 'each' [3,4]
@@ -524,6 +551,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
524-- concurrently instead of the demand driven concurrency of 'AsyncT'.
551-- concurrently instead of the demand driven concurrency of 'AsyncT'.
555+-- import "Streamly.Prelude"
527-- main = 'runParallelT' $ do
557-- main = 'runParallelT' $ do
528-- x <- 'each' [3,2,1]
558-- x <- 'each' [3,2,1]
529-- delay x
559-- delay x
@@ -546,6 +576,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
548-- import "Streamly"
578-- import "Streamly"
579+-- import "Streamly.Prelude"
550-- composed :: 'Streaming' t => t m a
582-- composed :: 'Streaming' t => t m a
551-- composed = do
583-- composed = do
@@ -889,8 +921,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
889-- demonstrated below.
921-- demonstrated below.
892−-- import Streamly
924+-- import "Streamly"
893−-- import Streamly.Prelude
925+-- import "Streamly.Prelude"
894-- import System.IO (stdin)
926-- import System.IO (stdin)
896-- -- Adapt uncons to return an Either instead of Maybe
928-- -- Adapt uncons to return an Either instead of Maybe
@@ -911,7 +943,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
911-- -- pipe to streamly
943-- -- pipe to streamly
912-- -- Adapt P.next to return a Maybe instead of Either
944-- -- Adapt P.next to return a Maybe instead of Either
913-- let nextM p = P.next p >>= either (\\_ -> return Nothing) (return . Just)
945-- let nextM p = P.next p >>= either (\\_ -> return Nothing) (return . Just)
914−-- runStreamT $ unfoldrM nextM P.stdinLn >>= lift . putStrLn
946+-- 'runStreamT' $ 'unfoldrM' nextM P.stdinLn >>= lift . putStrLn
917-- Interop with @streaming@:
949-- Interop with @streaming@:
@@ -925,7 +957,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
925-- S.stdoutLn $ S.unfoldr unconsE stdinLn
957-- S.stdoutLn $ S.unfoldr unconsE stdinLn
927-- -- streaming to streamly
959-- -- streaming to streamly
928−-- runStreamT $ unfoldrM S.uncons S.stdinLn >>= lift . putStrLn
960+-- 'runStreamT' $ unfoldrM S.uncons S.stdinLn >>= lift . putStrLn