Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Control.Monad.Trans.List (ListT(..))
- import Control.Monad.Trans (lift)
- import System.Directory (getDirectoryContents, doesDirectoryExist)
- listDir :: FilePath -> ListT IO FilePath
- listDir path = do
- isDirectory <- lift $ doesDirectoryExist path
- if not isDirectory
- then ListT $ return [path]
- else do
- contents <- lift $ getDirectoryContents path
- let files = map ((path ++ "/") ++) . filter (`notElem` [".", ".."]) $ contents
- (ListT $ return files) >>= listDir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement