@@ -1,9 +1,9 @@
1module Streamly.Examples.ListDirRecursive where
1module Streamly.Examples.ListDirRecursive where
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)
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