@@ -147,16 +147,16 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
147-- using the 'lift' combinator. Some examples of streams with a single element:
147-- using the 'lift' combinator. Some examples of streams with a single element:
150−-- return 1 :: StreamT IO Int
150+-- return 1 :: 'StreamT' IO Int
153−-- liftIO $ putStrLn "Hello world!" :: StreamT IO ()
153+-- liftIO $ putStrLn "Hello world!" :: 'StreamT' IO ()
156-- We can combine streams using '<>' to create streams of many elements:
156-- We can combine streams using '<>' to create streams of many elements:
159−-- return 1 <> return 2 <> return 3 :: StreamT IO Int
159+-- return 1 <> return 2 <> return 3 :: 'StreamT' IO Int
162-- For more ways to construct or generate a stream see the module
162-- For more ways to construct or generate a stream see the module
@@ -168,9 +168,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
168-- the underlying monad and discarding the result stream:
168-- the underlying monad and discarding the result stream:
171−-- import Streamly
171+-- import "Streamly"
173−-- main = runStreamT $ liftIO $ putStrLn "Hello world!"
173+-- main = 'runStreamT' $ liftIO $ putStrLn "Hello world!"
176-- 'toList' runs a stream computation and collects the result stream in a list
176-- 'toList' runs a stream computation and collects the result stream in a list
@@ -182,10 +182,10 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
182-- StreamT@.
182-- StreamT@.
185−-- import Streamly
185+-- import "Streamly"
187-- main = do
187-- main = do
188−-- xs \<- toList $ serially $ return 1 <> return 2
188+-- xs \<- 'toList' $ 'serially' $ return 1 <> return 2
189-- print xs
189-- print xs
@@ -202,7 +202,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
202-- function to introduce a delay specified in seconds.
202-- function to introduce a delay specified in seconds.
205−-- import Streamly
205+-- import "Streamly"
206-- import Control.Concurrent
206-- import Control.Concurrent
208-- delay n = liftIO $ do
208-- delay n = liftIO $ do
@@ -219,7 +219,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
219-- total of 6 seconds because everything is serial:
219-- total of 6 seconds because everything is serial:
222−-- main = runStreamT $ delay 3 <> delay 2 <> delay 1
222+-- main = 'runStreamT' $ delay 3 <> delay 2 <> delay 1
225-- ThreadId 36: Delay 3
225-- ThreadId 36: Delay 3
@@ -234,7 +234,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
234-- 3, 2, 4 and takes a total of 10 seconds because everything is serial:
234-- 3, 2, 4 and takes a total of 10 seconds because everything is serial:
237−-- main = runStreamT $ (delay 1 <> delay 2) \<=> (delay 3 <> delay 4)
237+-- main = 'runStreamT' $ (delay 1 <> delay 2) '<=>' (delay 3 <> delay 4)
240-- ThreadId 36: Delay 1
240-- ThreadId 36: Delay 1
@@ -253,7 +253,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
253-- next one in a separate thread and so on:
253-- next one in a separate thread and so on:
256−-- main = runStreamT $ delay 3 <| delay 2 <| delay 1
256+-- main = 'runStreamT' $ delay 3 '<|' delay 2 '<|' delay 1
259-- ThreadId 42: Delay 1
259-- ThreadId 42: Delay 1
@@ -267,7 +267,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
267-- traversed in DFS style just like '<>'.
267-- traversed in DFS style just like '<>'.
270−-- main = runStreamT $ (p 1 <| p 2) <| (p 3 <| p 4)
270+-- main = 'runStreamT' $ (p 1 '<|' p 2) '<|' (p 3 '<|' p 4)
271-- where p = liftIO . print
271-- where p = liftIO . print
@@ -290,7 +290,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
290-- of them blocks:
290-- of them blocks:
293−-- main = runStreamT $ traced (sqrt 9) <| traced (sqrt 16) <| traced (sqrt 25)
293+-- main = 'runStreamT' $ traced (sqrt 9) '<|' traced (sqrt 16) '<|' traced (sqrt 25)
296-- ThreadId 40
296-- ThreadId 40
@@ -328,10 +328,10 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
328-- prints the name of the search engine as a response arrives:
328-- prints the name of the search engine as a response arrives:
331−-- import Streamly
331+-- import "Streamly"
332-- import Network.HTTP.Simple
332-- import Network.HTTP.Simple
334−-- main = runStreamT $ google \<|> bing \<|> duckduckgo
334+-- main = 'runStreamT' $ google \<|> bing \<|> duckduckgo
336-- google = get "https://www.google.com/search?q=haskell"
336-- google = get "https://www.google.com/search?q=haskell"
337-- bing = get "https://www.bing.com/search?q=haskell"
337-- bing = get "https://www.bing.com/search?q=haskell"
@@ -369,13 +369,13 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
369-- All of the following are equivalent:
369-- All of the following are equivalent:
372−-- import Streamly
372+-- import "Streamly"
374-- main = do
374-- main = do
375−-- toList . serially $ foldWith (<>) (map return [1..10]) >>= print
375+-- 'toList' . 'serially' $ 'foldWith' (<>) (map return [1..10]) >>= print
376−-- toList . serially $ foldMapWith (<>) return [1..10] >>= print
376+-- 'toList' . 'serially' $ 'foldMapWith' (<>) return [1..10] >>= print
377−-- toList . serially $ forEachWith (<>) [1..10] return >>= print
377+-- 'toList' . 'serially' $ 'forEachWith' (<>) [1..10] return >>= print
378−-- toList . serially $ each [1..10] >>= print
378+-- 'toList' . 'serially' $ 'each' [1..10] >>= print
381-- $transforming
381-- $transforming
@@ -409,8 +409,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
409-- list transformer like serial composition.
409-- list transformer like serial composition.
412−-- main = runStreamT $ do
412+-- main = 'runStreamT' $ do
413−-- x <- each [3,2,1]
413+-- x <- 'each' [3,2,1]
414-- delay x
414-- delay x
@@ -430,9 +430,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
430-- loops in imperative programming.
430-- loops in imperative programming.
433−-- main = runStreamT $ do
433+-- main = 'runStreamT' $ do
434−-- x <- each [1,2]
434+-- x <- 'each' [1,2]
435−-- y <- each [3,4]
435+-- y <- 'each' [3,4]
436-- liftIO $ putStrLn $ show (x, y)
436-- liftIO $ putStrLn $ show (x, y)
@@ -455,8 +455,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
455-- This is the concurrent version of 'StreamT'.
455-- This is the concurrent version of 'StreamT'.
458−-- main = runAsyncT $ do
458+-- main = 'runAsyncT' $ do
459−-- x <- each [3,2,1]
459+-- x <- 'each' [3,2,1]
460-- delay x
460-- delay x
@@ -479,9 +479,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
479-- demand from the consumer.
479-- demand from the consumer.
482−-- main = runAsyncT $ do
482+-- main = 'runAsyncT' $ do
483−-- x <- each [1,2]
483+-- x <- 'each' [1,2]
484−-- y <- each [3,4]
484+-- y <- 'each' [3,4]
485-- liftIO $ putStrLn $ show (x, y)
485-- liftIO $ putStrLn $ show (x, y)
@@ -502,9 +502,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
502-- the continuations or iterations of the inner loop.
502-- the continuations or iterations of the inner loop.
505−-- main = runInterleavedT $ do
505+-- main = 'runInterleavedT' $ do
506−-- x <- each [1,2]
506+-- x <- 'each' [1,2]
507−-- y <- each [3,4]
507+-- y <- 'each' [3,4]
508-- liftIO $ putStrLn $ show (x, y)
508-- liftIO $ putStrLn $ show (x, y)
@@ -525,8 +525,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
525-- concurrently instead of the demand driven concurrency of 'AsyncT'.
525-- concurrently instead of the demand driven concurrency of 'AsyncT'.
528−-- main = runParallelT $ do
528+-- main = 'runParallelT' $ do
529−-- x <- each [3,2,1]
529+-- x <- 'each' [3,2,1]
530-- delay x
530-- delay x
@@ -546,9 +546,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
546-- specific mode of composition. For example look at the following code.
546-- specific mode of composition. For example look at the following code.
549−-- import Streamly
549+-- import "Streamly"
551−-- composed :: Streaming t => t m a
551+-- composed :: 'Streaming' t => t m a
552-- composed = do
552-- composed = do
553-- sz <- sizes
553-- sz <- sizes
554-- cl <- colors
554-- cl <- colors
@@ -557,28 +557,28 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
560−-- sizes = each [1, 2, 3]
560+-- sizes = 'each' [1, 2, 3]
561−-- colors = each ["red", "green", "blue"]
561+-- colors = 'each' ["red", "green", "blue"]
562−-- shapes = each ["triangle", "square", "circle"]
562+-- shapes = 'each' ["triangle", "square", "circle"]
565-- Now we can interpret this in whatever way we want:
565-- Now we can interpret this in whatever way we want:
568−-- main = runStreamT composed
568+-- main = 'runStreamT' composed
569−-- main = runAsyncT composed
569+-- main = 'runAsyncT' composed
570−-- main = runInterleavedT composed
570+-- main = 'runInterleavedT' composed
571−-- main = runParallelT composed
571+-- main = 'runParallelT' composed
574-- Equivalently, we can also write it using the type adapter combinators, like
574-- Equivalently, we can also write it using the type adapter combinators, like
578−-- main = runStreaming $ serially $ composed
578+-- main = 'runStreaming' $ 'serially' $ composed
579−-- main = runStreaming $ asyncly $ composed
579+-- main = 'runStreaming' $ 'asyncly' $ composed
580−-- main = runStreaming $ interleaving $ composed
580+-- main = 'runStreaming' $ 'interleaving' $ composed
581−-- main = runStreaming $ parallely $ composed
581+-- main = 'runStreaming' $ 'parallely' $ composed
584-- As an exercise try to figure out the output of this code for each mode of
584-- As an exercise try to figure out the output of this code for each mode of
@@ -593,9 +593,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
593-- 'fmap', namely, 'asyncMap' and 'parMap' are provided.
593-- 'fmap', namely, 'asyncMap' and 'parMap' are provided.
596−-- import Streamly
596+-- import "Streamly"
598−-- main = (toList $ serially $ fmap show $ each [1..10]) >>= print
598+-- main = ('toList' $ 'serially' $ fmap show $ 'each' [1..10]) >>= print
601-- Also see the 'mapM' and 'sequence' functions for mapping actions, in the
601-- Also see the 'mapM' and 'sequence' functions for mapping actions, in the
@@ -611,15 +611,15 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
611-- seconds (1 + 3 + 4 + 2 + 3 + 4):
611-- seconds (1 + 3 + 4 + 2 + 3 + 4):
614−-- import Streamly
614+-- import "Streamly"
615−-- import Streamly.Prelude
615+-- import "Streamly.Prelude"
616-- import Control.Concurrent
616-- import Control.Concurrent
618-- s1 = d 1 <> d 2
618-- s1 = d 1 <> d 2
619-- s2 = d 3 <> d 4
619-- s2 = d 3 <> d 4
620-- d n = delay n >> return n
620-- d n = delay n >> return n
622−-- main = (toList . serially $ (,) \<$> s1 \<*> s2) >>= print
622+-- main = ('toList' . 'serially' $ (,) \<$> s1 \<*> s2) >>= print
625-- ThreadId 36: Delay 1
625-- ThreadId 36: Delay 1
@@ -635,7 +635,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
635-- since it is serial it takes a total of 17 seconds:
635-- since it is serial it takes a total of 17 seconds:
638−-- main = (toList . interleaving $ (,) \<$> s1 \<*> s2) >>= print
638+-- main = ('toList' . 'interleaving' $ (,) \<$> s1 \<*> s2) >>= print
641-- ThreadId 36: Delay 1
641-- ThreadId 36: Delay 1
@@ -651,7 +651,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
651-- of 10 seconds (1 + 2 + 3 + 4):
651-- of 10 seconds (1 + 2 + 3 + 4):
654−-- main = (toList . asyncly $ (,) \<$> s1 \<*> s2) >>= print
654+-- main = ('toList' . 'asyncly' $ (,) \<$> s1 \<*> s2) >>= print
657-- ThreadId 34: Delay 1
657-- ThreadId 34: Delay 1
@@ -667,7 +667,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
667-- therefore takes a total of 10 seconds (1 + 2 + 3 + 4):
667-- therefore takes a total of 10 seconds (1 + 2 + 3 + 4):
670−-- main = (toList . parallely $ (,) \<$> s1 \<*> s2) >>= print
670+-- main = ('toList' . 'parallely' $ (,) \<$> s1 \<*> s2) >>= print
673-- ThreadId 34: Delay 1
673-- ThreadId 34: Delay 1
@@ -712,15 +712,15 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
712-- 'ZipStream' zips streams serially:
712-- 'ZipStream' zips streams serially:
715−-- import Streamly
715+-- import "Streamly"
716−-- import Streamly.Prelude
716+-- import "Streamly.Prelude"
717-- import Control.Concurrent
717-- import Control.Concurrent
719-- d n = delay n >> return n
719-- d n = delay n >> return n
720−-- s1 = adapt . serially $ d 1 <> d 2
720+-- s1 = 'adapt' . 'serially' $ d 1 <> d 2
721−-- s2 = adapt . serially $ d 3 <> d 4
721+-- s2 = 'adapt' . 'serially' $ d 3 <> d 4
723−-- main = (toList . zipping $ (,) \<$> s1 \<*> s2) >>= print
723+-- main = ('toList' . 'zipping' $ (,) \<$> s1 \<*> s2) >>= print
726-- This takes total 10 seconds to zip, which is (1 + 2 + 3 + 4) since
726-- This takes total 10 seconds to zip, which is (1 + 2 + 3 + 4) since
@@ -739,18 +739,18 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
739-- 'ZipAsync' zips streams concurrently:
739-- 'ZipAsync' zips streams concurrently:
742−-- import Streamly
742+-- import "Streamly"
743−-- import Streamly.Prelude
743+-- import "Streamly.Prelude"
744-- import Control.Concurrent
744-- import Control.Concurrent
745-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
745-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
747-- d n = delay n >> return n
747-- d n = delay n >> return n
748−-- s1 = adapt . serially $ d 1 <> d 2
748+-- s1 = 'adapt' . 'serially' $ d 1 <> d 2
749−-- s2 = adapt . serially $ d 3 <> d 4
749+-- s2 = 'adapt' . 'serially' $ d 3 <> d 4
751-- main = do
751-- main = do
752-- liftIO $ hSetBuffering stdout LineBuffering
752-- liftIO $ hSetBuffering stdout LineBuffering
753−-- (toList . zippingAsync $ (,) \<$> s1 \<*> s2) >>= print
753+-- ('toList' . 'zippingAsync' $ (,) \<$> s1 \<*> s2) >>= print
756-- This takes 7 seconds to zip, which is max (1,3) + max (2,4) because 1 and 3
756-- This takes 7 seconds to zip, which is max (1,3) + max (2,4) because 1 and 3
@@ -774,12 +774,12 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
774-- sum and print them serially:
774-- sum and print them serially:
777−-- import Streamly
777+-- import "Streamly"
778−-- import Streamly.Prelude (toList)
778+-- import "Streamly.Prelude" (toList)
779-- import Data.List (sum)
779-- import Data.List (sum)
781-- main = do
781-- main = do
782−-- squares \<- toList $ serially $ forEachWith (<|) [1..100] $ \\x -\> return $ x * x
782+-- squares \<- 'toList' $ 'serially' $ 'forEachWith' ('<|') [1..100] $ \\x -\> return $ x * x
783-- print $ sum squares
783-- print $ sum squares
@@ -788,14 +788,14 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
788-- monadic bind.
788-- monadic bind.
791−-- import Streamly
791+-- import "Streamly"
792−-- import Streamly.Prelude (toList)
792+-- import "Streamly.Prelude" (toList)
793-- import Data.List (sum)
793-- import Data.List (sum)
795-- main = do
795-- main = do
796−-- z \<- toList $ asyncly $ do
796+-- z \<- 'toList' $ 'asyncly' $ do
797−-- xsq \<- forEachWith (\<|) [1..100] $ \\x -> return $ x * x
797+-- xsq \<- 'forEachWith' ('<|') [1..100] $ \\x -> return $ x * x
798−-- ysq \<- forEachWith (\<|) [1..100] $ \\x -> return $ x * x
798+-- ysq \<- 'forEachWith' ('<|') [1..100] $ \\x -> return $ x * x
799-- return $ sqrt (xsq + ysq)
799-- return $ sqrt (xsq + ysq)
800-- print $ sum z
800-- print $ sum z
@@ -807,7 +807,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
808-- {-\# LANGUAGE FlexibleContexts #-}
808-- {-\# LANGUAGE FlexibleContexts #-}
810−-- import Streamly
810+-- import "Streamly"
811-- import Control.Concurrent (threadDelay)
811-- import Control.Concurrent (threadDelay)
812-- import Control.Monad (when)
812-- import Control.Monad (when)
813-- import Control.Monad.State
813-- import Control.Monad.State
@@ -815,7 +815,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
816-- data Event = Harm Int | Heal Int | Quit deriving (Show)
816-- data Event = Harm Int | Heal Int | Quit deriving (Show)
818−-- userAction :: MonadIO m => StreamT m Event
818+-- userAction :: MonadIO m => 'StreamT' m Event
819-- userAction = cycle1 $ liftIO askUser
819-- userAction = cycle1 $ liftIO askUser
821-- askUser = do
821-- askUser = do
@@ -825,10 +825,10 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
825-- "quit" -> return Quit
825-- "quit" -> return Quit
826-- _ -> putStrLn "What?" >> askUser
826-- _ -> putStrLn "What?" >> askUser
828−-- acidRain :: MonadIO m => StreamT m Event
828+-- acidRain :: MonadIO m => 'StreamT' m Event
829-- acidRain = cycle1 $ liftIO (threadDelay 1000000) >> return (Harm 1)
829-- acidRain = cycle1 $ liftIO (threadDelay 1000000) >> return (Harm 1)
831−-- game :: (MonadAsync m, MonadState Int m) => StreamT m ()
831+-- game :: ('MonadAsync' m, MonadState Int m) => 'StreamT' m ()
832-- game = do
832-- game = do
833-- event \<- userAction \<|> acidRain
833-- event \<- userAction \<|> acidRain
834-- case event of
834-- case event of
@@ -843,7 +843,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
843-- main = do
843-- main = do
844-- putStrLn "Your health is deteriorating due to acid rain,\\
844-- putStrLn "Your health is deteriorating due to acid rain,\\
845-- \\ type \\"potion\\" or \\"quit\\""
845-- \\ type \\"potion\\" or \\"quit\\""
846−-- _ <- runStateT (runStreamT game) 60
846+-- _ <- runStateT ('runStreamT' game) 60
847-- return ()
847-- return ()