Here is one way to list all Haskell files in a directory tree, using directory-tree that is not in a hidden directory (whose name starts with '.'):
import Data.Traversable (traverse)
import System.Directory.Tree (
AnchoredDirTree(..), DirTree(..),
filterDir, readDirectoryWith
)
import System.FilePath (takeExtension)
listFilesDirFiltered = do
_:/tree <- readDirectoryWith return "C:\\devmy\\code"
traverse print $ filterDir myPred tree
return ()
where myPred (Dir ('.':_) _) = False
myPred (File n _) = takeExtension n == ".hs"
myPred _ = True
main = listFilesDirFiltered
Works on both Windows and Linux.
walkDir
to be defined pretty easily I would guess, e.g. withtoList
provided by theFoldable
instance. – Kahl