on master help sign in
Fix nomenclature in examples
commit56cb8e6981cdd17e55b128434e34901505ca4fbe authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 13 May 2018, 10:48 (8 years ago) parentb03a7b6
4 files changed+13−13
examples/AcidRain.hs+3−3 examples/ListDir.hs+3−3 examples/MergeSort.hs+5−5 examples/SearchQuery.hs+2−2
examples/AcidRain.hs+3−3
@@ -12,7 +12,7 @@ import Data.Semigroup (cycle1)
1212
1313data Event = Harm Int | Heal Int | Quit deriving (Show)
1414
15−userAction :: MonadIO m => StreamT m Event
15+userAction :: MonadIO m => SerialT m Event
1616userAction = cycle1 $ liftIO askUser
1717 where
1818 askUser = do
@@ -22,10 +22,10 @@ userAction = cycle1 $ liftIO askUser
2222 "quit" -> return Quit
2323 _ -> putStrLn "What?" >> askUser
2424
25−acidRain :: MonadIO m => StreamT m Event
25+acidRain :: MonadIO m => SerialT m Event
2626acidRain = cycle1 $ liftIO (threadDelay 1000000) >> return (Harm 1)
2727
28−game :: (MonadParallel m, MonadState Int m) => StreamT m ()
28+game :: (MonadAsync m, MonadState Int m) => SerialT m ()
2929game = do
3030 event <- userAction `parallel` acidRain
3131 case event of
examples/ListDir.hs+3−3
@@ -1,17 +1,17 @@
11import Control.Monad.IO.Class (liftIO)
22import Path.IO (listDir, getCurrentDir)
33import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
4−import Streamly (runStream, asParAhead)
4+import Streamly (runStream, asyncly)
55
66-- | List the current directory recursively using concurrent processing
77--
88-- This example demonstrates that there is little difference between regular
99-- IO code and concurrent streamly code. You can just remove
10−-- 'runStream . asParAhead' and this becomes your regular IO code.
10+-- 'runStream . asyncly' and this becomes your regular IO code.
1111main :: IO ()
1212main = do
1313 hSetBuffering stdout LineBuffering
14− runStream . asParAhead $ getCurrentDir >>= readdir
14+ runStream . asyncly $ getCurrentDir >>= readdir
1515 where readdir d = do
1616 (ds, fs) <- liftIO $ listDir d
1717 liftIO $ mapM_ putStrLn $ map show fs ++ map show ds
examples/MergeSort.hs+5−5
@@ -7,20 +7,20 @@ import Streamly
77import Streamly.Prelude (once)
88import qualified Streamly.Prelude as A
99
10−getSorted :: Stream Word16
10+getSorted :: Serial Word16
1111getSorted = do
1212 g <- once getStdGen
1313 let ls = take 100000 (randoms g) :: [Word16]
1414 foldMap return (sort ls)
1515
1616-- | merge two streams generating the elements from each in parallel
17−mergeAsync :: Ord a => Stream a -> Stream a -> Stream a
17+mergeAsync :: Ord a => Serial a -> Serial a -> Serial a
1818mergeAsync a b = do
19− x <- once $ async a
20− y <- once $ async b
19+ x <- once $ mkAsync a
20+ y <- once $ mkAsync b
2121 merge x y
2222
23−merge :: Ord a => Stream a -> Stream a -> Stream a
23+merge :: Ord a => Serial a -> Serial a -> Serial a
2424merge a b = do
2525 a1 <- once $ A.uncons a
2626 case a1 of
examples/SearchQuery.hs+2−2
@@ -10,10 +10,10 @@ import Network.HTTP.Simple
1010main :: IO ()
1111main = do
1212 putStrLn "Using parallel semigroup composition"
13− runStream . asParallel $ google <> bing <> duckduckgo
13+ runStream . parallely $ google <> bing <> duckduckgo
1414
1515 putStrLn "\nUsing parallel applicative zip"
16− runStream . asZipParallel $ (,,) <$> google <*> bing <*> duckduckgo
16+ runStream . zipAsyncly $ (,,) <$> google <*> bing <*> duckduckgo
1717
1818 where
1919 get :: IsStream t => String -> t IO ()