Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import Control.Monad.Trans.List (ListT(..))
  2. import Control.Monad.Trans (lift)
  3. import System.Directory (getDirectoryContents, doesDirectoryExist)
  4.  
  5. listDir :: FilePath -> ListT IO FilePath
  6. listDir path = do
  7. isDirectory <- lift $ doesDirectoryExist path
  8. if not isDirectory
  9. then ListT $ return [path]
  10. else do
  11. contents <- lift $ getDirectoryContents path
  12. let files = map ((path ++ "/") ++) . filter (`notElem` [".", ".."]) $ contents
  13. (ListT $ return files) >>= listDir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement