@@ -40,6 +40,9 @@ module Streamly.Tutorial
40 -- * Flavors of Streams
40 -- * Flavors of Streams
41 -- $flavors
41 -- $flavors
43+ -- * Imports and Supporting Code
43 -- * Generating Streams
46 -- * Generating Streams
44 -- $generating
47 -- $generating
@@ -258,7 +261,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
260-- > import "Streamly"
263-- > import "Streamly"
261−-- > import "Streamly.Prelude" (|:)
264+-- > import "Streamly.Prelude" ((|:))
262-- > import qualified "Streamly.Prelude" as S
265-- > import qualified "Streamly.Prelude" as S
@@ -359,16 +362,26 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
359-- on the stream type in effect. The stream type and therefore the composition
362-- on the stream type in effect. The stream type and therefore the composition
360-- style can be changed at any point using one of the type combinators as
363-- style can be changed at any point using one of the type combinators as
361-- discussed earlier.
364-- discussed earlier.
363−-- To illustrate concurrent vs serial composition aspects, we will use the
368+-- In most of example snippets we do not repeat the imports. Where imports are
364−-- following @delay@ function to introduce a delay specified in seconds.
369+-- not explicitly specified use the imports shown below.
367-- import "Streamly"
372-- import "Streamly"
368−-- import "Streamly.Prelude" (nil)
373+-- import "Streamly.Prelude" ((|:), nil)
369-- import qualified "Streamly.Prelude" as S
374-- import qualified "Streamly.Prelude" as S
370-- import Control.Concurrent
376-- import Control.Concurrent
377+-- import Control.Monad (forever)
380+-- To illustrate concurrent vs serial composition aspects, we will use the
381+-- following @delay@ function to introduce a sleep or delay specified in
382+-- seconds. After the delay it prints the number of seconds it slept.
372-- delay n = S.'once' $ do
385-- delay n = S.'once' $ do
373-- threadDelay (n * 1000000)
386-- threadDelay (n * 1000000)
374-- tid \<- myThreadId
387-- tid \<- myThreadId
@@ -862,7 +875,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
862-- import "Streamly.Prelude"
875-- import "Streamly.Prelude"
864-- main = 'runStream' . 'asyncly' $ do
877-- main = 'runStream' . 'asyncly' $ do
865−-- x <- 'fromFoldable' [3,2,1]
878+-- x <- S.'fromFoldable' [3,2,1]
866-- delay x
879-- delay x
@@ -988,7 +1001,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
988-- import "Streamly"
1001-- import "Streamly"
989-- import qualified "Streamly.Prelude" as S
1002-- import qualified "Streamly.Prelude" as S
991−-- composed :: 'IsStream' t => t m a
1004+-- composed :: (IsStream t, Monad (t IO)) => t IO ()
992-- composed = do
1005-- composed = do
993-- sz <- sizes
1006-- sz <- sizes
994-- cl <- colors
1007-- cl <- colors
@@ -1130,8 +1143,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1130-- import Control.Concurrent
1143-- import Control.Concurrent
1132-- d n = delay n >> return n
1145-- d n = delay n >> return n
1133−-- s1 = 'streamly' $ d 1 <> d 2
1146+-- s1 = 'serially' $ d 1 <> d 2
1134−-- s2 = 'streamly' $ d 3 <> d 4
1147+-- s2 = 'serially' $ d 3 <> d 4
1136-- main = (S.'toList' . 'zipSerially' $ (,) \<$> s1 \<*> s2) >>= print
1149-- main = (S.'toList' . 'zipSerially' $ (,) \<$> s1 \<*> s2) >>= print
@@ -1161,8 +1174,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1161-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
1174-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
1163-- d n = delay n >> return n
1176-- d n = delay n >> return n
1164−-- s1 = 'streamly' $ d 1 <> d 2
1177+-- s1 = 'serially' $ d 1 <> d 2
1165−-- s2 = 'streamly' $ d 3 <> d 4
1178+-- s2 = 'serially' $ d 3 <> d 4
1167-- main = do
1180-- main = do
1168-- hSetBuffering stdout LineBuffering
1181-- hSetBuffering stdout LineBuffering
@@ -1243,6 +1256,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
1243-- import "Streamly"
1256-- import "Streamly"
1244-- import Control.Concurrent (threadDelay)
1257-- import Control.Concurrent (threadDelay)
1245-- import Control.Monad (when)
1258-- import Control.Monad (when)
1259+-- import Control.Monad.IO.Class (MonadIO(..))
1246-- import Control.Monad.State (MonadState, get, modify, runStateT)
1260-- import Control.Monad.State (MonadState, get, modify, runStateT)
1247-- import Data.Semigroup (cycle1)
1261-- import Data.Semigroup (cycle1)