on master help sign in
update README to use "once"
commit3f777b8e76fb705ce8f927f54f51b32ee4d012bf authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 3 May 2018, 04:59 (8 years ago) parent33ae318
2 files changed+6−6
README.md+3−3 src/Streamly/Examples/ListDirRecursive.hs+3−3
README.md+3−3
@@ -35,7 +35,7 @@ import qualified Streamly.Prelude as S
3535loops = do
3636 x <- S.fromFoldable [1,2]
3737 y <- S.fromFoldable [3,4]
38− liftIO $ putStrLn $ show (x, y)
38+ S.once $ putStrLn $ show (x, y)
3939
4040main = runStream loops
4141```
@@ -95,8 +95,8 @@ import Streamly
9595
9696main = runStream $ coparallely $ getCurrentDir >>= readdir
9797 where readdir d = do
98− (dirs, files) <- liftIO $ listDir d
99− liftIO $ mapM_ putStrLn $ map show files
98+ (dirs, files) <- S.once $ listDir d
99+ S.once $ mapM_ putStrLn $ map show files
100100 -- read the subdirs concurrently, (<>) is concurrent
101101 foldMap readdir dirs
102102```
src/Streamly/Examples/ListDirRecursive.hs+3−3
@@ -1,9 +1,9 @@
11module Streamly.Examples.ListDirRecursive where
22
3−import Control.Monad.IO.Class (liftIO)
43import Path.IO (listDir, getCurrentDir)
54import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
65import Streamly (runStream, coparallely)
6+import Streamly.Prelude (once)
77
88-- | This example demonstrates that there is little difference between regular
99-- IO code and concurrent streamly code. You can just remove
@@ -13,6 +13,6 @@ listDirRecursive = do
1313 hSetBuffering stdout LineBuffering
1414 runStream . coparallely $ getCurrentDir >>= readdir
1515 where readdir d = do
16− (ds, fs) <- liftIO $ listDir d
17− liftIO $ mapM_ putStrLn $ map show fs ++ map show ds
16+ (ds, fs) <- once $ listDir d
17+ once $ mapM_ putStrLn $ map show fs ++ map show ds
1818 foldMap readdir ds