Skip to content

Instantly share code, notes, and snippets.

@davidallsopp
Created November 10, 2014 10:35
Show Gist options
  • Select an option

  • Save davidallsopp/c6a27ee9dbcab7fd4f78 to your computer and use it in GitHub Desktop.

Select an option

Save davidallsopp/c6a27ee9dbcab7fd4f78 to your computer and use it in GitHub Desktop.
Recursively finding files in (cross-platform) Haskell
module FindFiles where
import System.FilePath.Find
-- Can't install FileManip on Windows because it depends on "unix", which (surprise!) can't be installed
-- on Windows without Cygwin etc. Instead, install filemanip not FileManip (obviously ?!)
-- which depends on unix-compat, which is fine on Windows
main :: IO ()
main = do
-- paths <- find always always "."
-- paths <- find always (fileType ==? RegularFile) "."
paths <- find always (fileType ==? RegularFile &&? extension ==? ".hs") "."
mapM_ putStrLn paths
-- TODO See also find-conduit (http://hackage.haskell.org/package/find-conduit)
-- which might be handy if planning to use conduit to process the files?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment