MIT licensed by Christine Dodrill
Maintained by [email protected]
This version can be pinned in stack with:pathwalk-0.3.1.2@sha256:e12cc53b1f4d19e96afc22a9d8607862f41c6bef638101f4c0a16065443df43f,2296

Module documentation for 0.3.1.2

System.Directory.PathWalk is an implementation of Python's excellent os.walk function. Given a root directory, it recursively scans all subdirectories, calling a callback with directories and files it finds. Importantly, it calls the callback as soon as it finishes scanning each directory to allow the caller to begin processing results immediately.

Maximum memory usage is O(N+M) where N is the depth of the tree and M is the maximum number of entries in a particular directory.

import System.Directory.PathWalk

pathWalk "some/directory" $ \root dirs files -> do
  forM_ files $ \file ->
    when (".hs" `isSuffixOf` file) $ do
      putStrLn $ joinPath [root, file]