| Safe Haskell | Safe |
|---|---|
| Language | Haskell98 |
System.Directory.ListTree
Description
Monadic directory tree.
-- List of files under "." or subfolders with ".markdown" extension,
-- except for those with a name starting with "_" somewhere in their path. (like "_cache/index.markdown")
markdownFiles :: ListT IO FilePath
markdownFiles
= filter ((== ".markdown") . takeExtension) -- only take files with a ".markdown" extension
. lastL -- get the leaves of the tree (files, not directories)
. scanl1 appendPath -- transform tree nodes to filenames including path
. prune (not . isPrefixOf "_") -- ignore directories or files whose name starts with "_"
$ directoryTree "." -- directory tree starting at "."Module name System.Directory.Tree is a better fit but it is taken by "directory-tree", a read-directory-tree-in-bulk module.
- directoryTree :: MonadIO m => FilePath -> ListT (ListT m) FilePath
- appendPath :: FilePath -> FilePath -> FilePath