on master help sign in
update README to use "once"
3f777b8Harendra Kumar
README.md+3−3
@@ -35,7 +35,7 @@ import qualified Streamly.Prelude as S
35loops = do
35loops = do
36 x <- S.fromFoldable [1,2]
36 x <- S.fromFoldable [1,2]
37 y <- S.fromFoldable [3,4]
37 y <- S.fromFoldable [3,4]
38− liftIO $ putStrLn $ show (x, y)
38+ S.once $ putStrLn $ show (x, y)
39
39
40main = runStream loops
40main = runStream loops
41```
41```
@@ -95,8 +95,8 @@ import Streamly
95
95
96main = runStream $ coparallely $ getCurrentDir >>= readdir
96main = runStream $ coparallely $ getCurrentDir >>= readdir
97 where readdir d = do
97 where readdir d = do
98− (dirs, files) <- liftIO $ listDir d
98+ (dirs, files) <- S.once $ listDir d
99− liftIO $ mapM_ putStrLn $ map show files
99+ S.once $ mapM_ putStrLn $ map show files
100 -- read the subdirs concurrently, (<>) is concurrent
100 -- read the subdirs concurrently, (<>) is concurrent
101 foldMap readdir dirs
101 foldMap readdir dirs
102```
102```
src/Streamly/Examples/ListDirRecursive.hs+3−3
@@ -1,9 +1,9 @@
1module Streamly.Examples.ListDirRecursive where
1module Streamly.Examples.ListDirRecursive where
2
2
3−import Control.Monad.IO.Class (liftIO)
4import Path.IO (listDir, getCurrentDir)
3import Path.IO (listDir, getCurrentDir)
5import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
4import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
6import Streamly (runStream, coparallely)
5import Streamly (runStream, coparallely)
6+import Streamly.Prelude (once)
7
7
8-- | This example demonstrates that there is little difference between regular
8-- | This example demonstrates that there is little difference between regular
9-- IO code and concurrent streamly code. You can just remove
9-- IO code and concurrent streamly code. You can just remove
@@ -13,6 +13,6 @@ listDirRecursive = do
13 hSetBuffering stdout LineBuffering
13 hSetBuffering stdout LineBuffering
14 runStream . coparallely $ getCurrentDir >>= readdir
14 runStream . coparallely $ getCurrentDir >>= readdir
15 where readdir d = do
15 where readdir d = do
16− (ds, fs) <- liftIO $ listDir d
16+ (ds, fs) <- once $ listDir d
17− liftIO $ mapM_ putStrLn $ map show fs ++ map show ds
17+ once $ mapM_ putStrLn $ map show fs ++ map show ds
18 foldMap readdir ds
18 foldMap readdir ds