@@ -1,8 +1,9 @@
1module Main (main) where
1module Main (main) where
3−import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
3+import Data.Bifunctor (bimap)
4−import Streamly (async)
5import Data.Function ((&))
4import Data.Function ((&))
5+import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
6+import Streamly (ahead)
7import qualified Streamly.Prelude as S
8import qualified Streamly.Prelude as S
8import qualified Streamly.Internal.Prelude as S
9import qualified Streamly.Internal.Prelude as S
@@ -13,19 +14,12 @@ import qualified Streamly.Internal.FileSystem.Dir as Dir
13main :: IO ()
14main :: IO ()
15 hSetBuffering stdout LineBuffering
16 hSetBuffering stdout LineBuffering
16− -- XXX Fix bug in enqueueAhead when mixing serial with ahead:
17− -- (\x -> S.yield dir <> S.concatMapWith ahead recursePath x)
18− -- :: SerialT IO String
19− -- or S.cons dir . S.concatMapWith ahead recursePath
20− S.mapM_ print $ S.concatMapTreeWith async listDir
17+ S.mapM_ print $ S.concatMapTreeWith ahead listDir
21 (S.yieldM $ return (Left "."))
18 (S.yieldM $ return (Left "."))
25 listDir dir =
22 listDir dir =
26 Dir.toEither dir -- SerialT IO (Either String String)
23 Dir.toEither dir -- SerialT IO (Either String String)
27− & S.map (prefixDir dir) -- SerialT IO (Either String String)
24+ & S.map (bimap prefix prefix) -- SerialT IO (Either String String)
28−
25+ where prefix x = dir ++ "/" ++ x
29− prefixDir :: String -> Either String String -> Either String String
30− prefixDir dir (Right x) = Right $ dir ++ "/" ++ x
31− prefixDir dir (Left x) = Left $ dir ++ "/" ++ x