Skip to content

Instantly share code, notes, and snippets.

@qnikst
Last active July 20, 2019 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnikst/8f1418b9faad332442a38d2677ff6fbc to your computer and use it in GitHub Desktop.
Save qnikst/8f1418b9faad332442a38d2677ff6fbc to your computer and use it in GitHub Desktop.
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