@@ -147,16 +147,16 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
147147-- using the 'lift' combinator. Some examples of streams with a single element:
148148--
149149-- @
150−-- return 1 :: StreamT IO Int
150+-- return 1 :: 'StreamT' IO Int
151151-- @
152152-- @
153−-- liftIO $ putStrLn "Hello world!" :: StreamT IO ()
153+-- liftIO $ putStrLn "Hello world!" :: 'StreamT' IO ()
154154-- @
155155--
156156-- We can combine streams using '<>' to create streams of many elements:
157157--
158158-- @
159−-- return 1 <> return 2 <> return 3 :: StreamT IO Int
159+-- return 1 <> return 2 <> return 3 :: 'StreamT' IO Int
160160-- @
161161--
162162-- For more ways to construct or generate a stream see the module
@@ -168,9 +168,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
168168-- the underlying monad and discarding the result stream:
169169--
170170-- @
171−-- import Streamly
171+-- import "Streamly"
172172--
173−-- main = runStreamT $ liftIO $ putStrLn "Hello world!"
173+-- main = 'runStreamT' $ liftIO $ putStrLn "Hello world!"
174174-- @
175175--
176176-- 'toList' runs a stream computation and collects the result stream in a list
@@ -182,10 +182,10 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
182182-- StreamT@.
183183--
184184-- @
185−-- import Streamly
185+-- import "Streamly"
186186--
187187-- main = do
188−-- xs \<- toList $ serially $ return 1 <> return 2
188+-- xs \<- 'toList' $ 'serially' $ return 1 <> return 2
189189-- print xs
190190-- @
191191--
@@ -202,7 +202,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
202202-- function to introduce a delay specified in seconds.
203203--
204204-- @
205−-- import Streamly
205+-- import "Streamly"
206206-- import Control.Concurrent
207207--
208208-- delay n = liftIO $ do
@@ -219,7 +219,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
219219-- total of 6 seconds because everything is serial:
220220--
221221-- @
222−-- main = runStreamT $ delay 3 <> delay 2 <> delay 1
222+-- main = 'runStreamT' $ delay 3 <> delay 2 <> delay 1
223223-- @
224224-- @
225225-- ThreadId 36: Delay 3
@@ -234,7 +234,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
234234-- 3, 2, 4 and takes a total of 10 seconds because everything is serial:
235235--
236236-- @
237−-- main = runStreamT $ (delay 1 <> delay 2) \<=> (delay 3 <> delay 4)
237+-- main = 'runStreamT' $ (delay 1 <> delay 2) '<=>' (delay 3 <> delay 4)
238238-- @
239239-- @
240240-- ThreadId 36: Delay 1
@@ -253,7 +253,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
253253-- next one in a separate thread and so on:
254254--
255255-- @
256−-- main = runStreamT $ delay 3 <| delay 2 <| delay 1
256+-- main = 'runStreamT' $ delay 3 '<|' delay 2 '<|' delay 1
257257-- @
258258-- @
259259-- ThreadId 42: Delay 1
@@ -267,7 +267,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
267267-- traversed in DFS style just like '<>'.
268268--
269269-- @
270−-- main = runStreamT $ (p 1 <| p 2) <| (p 3 <| p 4)
270+-- main = 'runStreamT' $ (p 1 '<|' p 2) '<|' (p 3 '<|' p 4)
271271-- where p = liftIO . print
272272-- @
273273-- @
@@ -290,7 +290,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
290290-- of them blocks:
291291--
292292-- @
293−-- main = runStreamT $ traced (sqrt 9) <| traced (sqrt 16) <| traced (sqrt 25)
293+-- main = 'runStreamT' $ traced (sqrt 9) '<|' traced (sqrt 16) '<|' traced (sqrt 25)
294294-- @
295295-- @
296296-- ThreadId 40
@@ -328,10 +328,10 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
328328-- prints the name of the search engine as a response arrives:
329329--
330330-- @
331−-- import Streamly
331+-- import "Streamly"
332332-- import Network.HTTP.Simple
333333--
334−-- main = runStreamT $ google \<|> bing \<|> duckduckgo
334+-- main = 'runStreamT' $ google \<|> bing \<|> duckduckgo
335335-- where
336336-- google = get "https://www.google.com/search?q=haskell"
337337-- bing = get "https://www.bing.com/search?q=haskell"
@@ -369,13 +369,13 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
369369-- All of the following are equivalent:
370370--
371371-- @
372−-- import Streamly
372+-- import "Streamly"
373373--
374374-- main = do
375−-- toList . serially $ foldWith (<>) (map return [1..10]) >>= print
376−-- toList . serially $ foldMapWith (<>) return [1..10] >>= print
377−-- toList . serially $ forEachWith (<>) [1..10] return >>= print
378−-- toList . serially $ each [1..10] >>= print
375+-- 'toList' . 'serially' $ 'foldWith' (<>) (map return [1..10]) >>= print
376+-- 'toList' . 'serially' $ 'foldMapWith' (<>) return [1..10] >>= print
377+-- 'toList' . 'serially' $ 'forEachWith' (<>) [1..10] return >>= print
378+-- 'toList' . 'serially' $ 'each' [1..10] >>= print
379379-- @
380380
381381-- $transforming
@@ -409,8 +409,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
409409-- list transformer like serial composition.
410410--
411411-- @
412−-- main = runStreamT $ do
413−-- x <- each [3,2,1]
412+-- main = 'runStreamT' $ do
413+-- x <- 'each' [3,2,1]
414414-- delay x
415415-- @
416416-- @
@@ -430,9 +430,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
430430-- loops in imperative programming.
431431--
432432-- @
433−-- main = runStreamT $ do
434−-- x <- each [1,2]
435−-- y <- each [3,4]
433+-- main = 'runStreamT' $ do
434+-- x <- 'each' [1,2]
435+-- y <- 'each' [3,4]
436436-- liftIO $ putStrLn $ show (x, y)
437437-- @
438438-- @
@@ -455,8 +455,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
455455-- This is the concurrent version of 'StreamT'.
456456--
457457-- @
458−-- main = runAsyncT $ do
459−-- x <- each [3,2,1]
458+-- main = 'runAsyncT' $ do
459+-- x <- 'each' [3,2,1]
460460-- delay x
461461-- @
462462-- @
@@ -479,9 +479,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
479479-- demand from the consumer.
480480--
481481-- @
482−-- main = runAsyncT $ do
483−-- x <- each [1,2]
484−-- y <- each [3,4]
482+-- main = 'runAsyncT' $ do
483+-- x <- 'each' [1,2]
484+-- y <- 'each' [3,4]
485485-- liftIO $ putStrLn $ show (x, y)
486486-- @
487487-- @
@@ -502,9 +502,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
502502-- the continuations or iterations of the inner loop.
503503--
504504-- @
505−-- main = runInterleavedT $ do
506−-- x <- each [1,2]
507−-- y <- each [3,4]
505+-- main = 'runInterleavedT' $ do
506+-- x <- 'each' [1,2]
507+-- y <- 'each' [3,4]
508508-- liftIO $ putStrLn $ show (x, y)
509509-- @
510510-- @
@@ -525,8 +525,8 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
525525-- concurrently instead of the demand driven concurrency of 'AsyncT'.
526526--
527527-- @
528−-- main = runParallelT $ do
529−-- x <- each [3,2,1]
528+-- main = 'runParallelT' $ do
529+-- x <- 'each' [3,2,1]
530530-- delay x
531531-- @
532532-- @
@@ -546,9 +546,9 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
546546-- specific mode of composition. For example look at the following code.
547547--
548548-- @
549−-- import Streamly
549+-- import "Streamly"
550550--
551−-- composed :: Streaming t => t m a
551+-- composed :: 'Streaming' t => t m a
552552-- composed = do
553553-- sz <- sizes
554554-- cl <- colors
@@ -557,28 +557,28 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
557557--
558558-- where
559559--
560−-- sizes = each [1, 2, 3]
561−-- colors = each ["red", "green", "blue"]
562−-- shapes = each ["triangle", "square", "circle"]
560+-- sizes = 'each' [1, 2, 3]
561+-- colors = 'each' ["red", "green", "blue"]
562+-- shapes = 'each' ["triangle", "square", "circle"]
563563-- @
564564--
565565-- Now we can interpret this in whatever way we want:
566566--
567567-- @
568−-- main = runStreamT composed
569−-- main = runAsyncT composed
570−-- main = runInterleavedT composed
571−-- main = runParallelT composed
568+-- main = 'runStreamT' composed
569+-- main = 'runAsyncT' composed
570+-- main = 'runInterleavedT' composed
571+-- main = 'runParallelT' composed
572572-- @
573573--
574574-- Equivalently, we can also write it using the type adapter combinators, like
575575-- this:
576576--
577577-- @
578−-- main = runStreaming $ serially $ composed
579−-- main = runStreaming $ asyncly $ composed
580−-- main = runStreaming $ interleaving $ composed
581−-- main = runStreaming $ parallely $ composed
578+-- main = 'runStreaming' $ 'serially' $ composed
579+-- main = 'runStreaming' $ 'asyncly' $ composed
580+-- main = 'runStreaming' $ 'interleaving' $ composed
581+-- main = 'runStreaming' $ 'parallely' $ composed
582582-- @
583583--
584584-- 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))
593593-- 'fmap', namely, 'asyncMap' and 'parMap' are provided.
594594--
595595-- @
596−-- import Streamly
596+-- import "Streamly"
597597--
598−-- main = (toList $ serially $ fmap show $ each [1..10]) >>= print
598+-- main = ('toList' $ 'serially' $ fmap show $ 'each' [1..10]) >>= print
599599-- @
600600--
601601-- Also see the 'mapM' and 'sequence' functions for mapping actions, in the
@@ -611,15 +611,15 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
611611-- seconds (1 + 3 + 4 + 2 + 3 + 4):
612612--
613613-- @
614−-- import Streamly
615−-- import Streamly.Prelude
614+-- import "Streamly"
615+-- import "Streamly.Prelude"
616616-- import Control.Concurrent
617617--
618618-- s1 = d 1 <> d 2
619619-- s2 = d 3 <> d 4
620620-- d n = delay n >> return n
621621--
622−-- main = (toList . serially $ (,) \<$> s1 \<*> s2) >>= print
622+-- main = ('toList' . 'serially' $ (,) \<$> s1 \<*> s2) >>= print
623623-- @
624624-- @
625625-- ThreadId 36: Delay 1
@@ -635,7 +635,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
635635-- since it is serial it takes a total of 17 seconds:
636636--
637637-- @
638−-- main = (toList . interleaving $ (,) \<$> s1 \<*> s2) >>= print
638+-- main = ('toList' . 'interleaving' $ (,) \<$> s1 \<*> s2) >>= print
639639-- @
640640-- @
641641-- ThreadId 36: Delay 1
@@ -651,7 +651,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
651651-- of 10 seconds (1 + 2 + 3 + 4):
652652--
653653-- @
654−-- main = (toList . asyncly $ (,) \<$> s1 \<*> s2) >>= print
654+-- main = ('toList' . 'asyncly' $ (,) \<$> s1 \<*> s2) >>= print
655655-- @
656656-- @
657657-- ThreadId 34: Delay 1
@@ -667,7 +667,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
667667-- therefore takes a total of 10 seconds (1 + 2 + 3 + 4):
668668--
669669-- @
670−-- main = (toList . parallely $ (,) \<$> s1 \<*> s2) >>= print
670+-- main = ('toList' . 'parallely' $ (,) \<$> s1 \<*> s2) >>= print
671671-- @
672672-- @
673673-- ThreadId 34: Delay 1
@@ -712,15 +712,15 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
712712-- 'ZipStream' zips streams serially:
713713--
714714-- @
715−-- import Streamly
716−-- import Streamly.Prelude
715+-- import "Streamly"
716+-- import "Streamly.Prelude"
717717-- import Control.Concurrent
718718--
719719-- d n = delay n >> return n
720−-- s1 = adapt . serially $ d 1 <> d 2
721−-- s2 = adapt . serially $ d 3 <> d 4
720+-- s1 = 'adapt' . 'serially' $ d 1 <> d 2
721+-- s2 = 'adapt' . 'serially' $ d 3 <> d 4
722722--
723−-- main = (toList . zipping $ (,) \<$> s1 \<*> s2) >>= print
723+-- main = ('toList' . 'zipping' $ (,) \<$> s1 \<*> s2) >>= print
724724-- @
725725--
726726-- 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))
739739-- 'ZipAsync' zips streams concurrently:
740740--
741741-- @
742−-- import Streamly
743−-- import Streamly.Prelude
742+-- import "Streamly"
743+-- import "Streamly.Prelude"
744744-- import Control.Concurrent
745745-- import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
746746--
747747-- d n = delay n >> return n
748−-- s1 = adapt . serially $ d 1 <> d 2
749−-- s2 = adapt . serially $ d 3 <> d 4
748+-- s1 = 'adapt' . 'serially' $ d 1 <> d 2
749+-- s2 = 'adapt' . 'serially' $ d 3 <> d 4
750750--
751751-- main = do
752752-- liftIO $ hSetBuffering stdout LineBuffering
753−-- (toList . zippingAsync $ (,) \<$> s1 \<*> s2) >>= print
753+-- ('toList' . 'zippingAsync' $ (,) \<$> s1 \<*> s2) >>= print
754754-- @
755755--
756756-- 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))
774774-- sum and print them serially:
775775--
776776-- @
777−-- import Streamly
778−-- import Streamly.Prelude (toList)
777+-- import "Streamly"
778+-- import "Streamly.Prelude" (toList)
779779-- import Data.List (sum)
780780--
781781-- main = do
782−-- squares \<- toList $ serially $ forEachWith (<|) [1..100] $ \\x -\> return $ x * x
782+-- squares \<- 'toList' $ 'serially' $ 'forEachWith' ('<|') [1..100] $ \\x -\> return $ x * x
783783-- print $ sum squares
784784-- @
785785--
@@ -788,14 +788,14 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
788788-- monadic bind.
789789--
790790-- @
791−-- import Streamly
792−-- import Streamly.Prelude (toList)
791+-- import "Streamly"
792+-- import "Streamly.Prelude" (toList)
793793-- import Data.List (sum)
794794--
795795-- main = do
796−-- z \<- toList $ asyncly $ do
797−-- xsq \<- forEachWith (\<|) [1..100] $ \\x -> return $ x * x
798−-- ysq \<- forEachWith (\<|) [1..100] $ \\x -> return $ x * x
796+-- z \<- 'toList' $ 'asyncly' $ do
797+-- xsq \<- 'forEachWith' ('<|') [1..100] $ \\x -> return $ x * x
798+-- ysq \<- 'forEachWith' ('<|') [1..100] $ \\x -> return $ x * x
799799-- return $ sqrt (xsq + ysq)
800800-- print $ sum z
801801-- @
@@ -807,7 +807,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
807807-- @
808808-- {-\# LANGUAGE FlexibleContexts #-}
809809--
810−-- import Streamly
810+-- import "Streamly"
811811-- import Control.Concurrent (threadDelay)
812812-- import Control.Monad (when)
813813-- import Control.Monad.State
@@ -815,7 +815,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
815815--
816816-- data Event = Harm Int | Heal Int | Quit deriving (Show)
817817--
818−-- userAction :: MonadIO m => StreamT m Event
818+-- userAction :: MonadIO m => 'StreamT' m Event
819819-- userAction = cycle1 $ liftIO askUser
820820-- where
821821-- askUser = do
@@ -825,10 +825,10 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
825825-- "quit" -> return Quit
826826-- _ -> putStrLn "What?" >> askUser
827827--
828−-- acidRain :: MonadIO m => StreamT m Event
828+-- acidRain :: MonadIO m => 'StreamT' m Event
829829-- acidRain = cycle1 $ liftIO (threadDelay 1000000) >> return (Harm 1)
830830--
831−-- game :: (MonadAsync m, MonadState Int m) => StreamT m ()
831+-- game :: ('MonadAsync' m, MonadState Int m) => 'StreamT' m ()
832832-- game = do
833833-- event \<- userAction \<|> acidRain
834834-- case event of
@@ -843,7 +843,7 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
843843-- main = do
844844-- putStrLn "Your health is deteriorating due to acid rain,\\
845845-- \\ type \\"potion\\" or \\"quit\\""
846−-- _ <- runStateT (runStreamT game) 60
846+-- _ <- runStateT ('runStreamT' game) 60
847847-- return ()
848848-- @
849849