Last active
July 20, 2019 09:35
-
-
Save qnikst/8f1418b9faad332442a38d2677ff6fbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Traversable | |
import Data.Foldable | |
import Data.List | |
import System.IO.Unsafe | |
import System.Directory | |
main = do | |
xs <- foo ["/Users/qnikst/"] | |
for_ xs $ putStrLn | |
foo [] = pure [] | |
foo (d:ds) = do | |
current <- listDirectory d | |
xt <- for current $ \fn -> do | |
isDir <- doesDirectoryExist fn | |
pure (isDir, fn) | |
let (dirs, files) = partition fst xt | |
next <- unsafeInterleaveIO $ foo ((map snd dirs)++ds) | |
pure $ (map ((\f->d++"/"++f).snd) files)++next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment