-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Path walking utilities for Haskell programs -- -- 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]
--
@package pathwalk
@version 0.3.1.2
-- | Provides path traversal functions much like Python's os.walk.
module System.Directory.PathWalk
-- | Called with a directory, list of relative subdirectories, and a list
-- of file names. If using pathWalk, the callback always returns
-- '()'. If using pathWalkInterruptible, it returns whether to
-- continue, prevent recursing further, or stop traversal entirely.
type Callback m a = FilePath -> [FilePath] -> [FilePath] -> m a
-- | pathWalk recursively enumerates the given root directory,
-- calling callback once per directory with the traversed directory name,
-- a list of subdirectories, and a list of files.
--
-- The subdirectories and file names are always relative to the root
-- given.
--
--
-- pathWalk "src" $ \dir subdirs files -> do
-- forM_ files $ \file -> do
-- when ("Test.hs" `isSuffixOf` file) $ do
-- registerTestFile $ dir </> file
--
pathWalk :: MonadIO m => FilePath -> Callback m () -> m ()
-- | The callback given to pathWalkInterruptible returns a
-- WalkStatus which determines which subsequent directories are
-- traversed.
data WalkStatus
-- | Continue recursing all subdirectories.
Continue :: WalkStatus
-- | Do not traverse deeper.
StopRecursing :: WalkStatus
-- | Stop recursing entirely.
Stop :: WalkStatus
-- | Traverses a directory tree, just like pathWalk, except that the
-- callback can determine whether to continue traversal. See
-- WalkStatus.
pathWalkInterruptible :: MonadIO m => FilePath -> Callback m WalkStatus -> m ()
-- | Traverses a directory tree, just like pathWalk. The difference
-- is that each callback returns a Monoid value, all of which are
-- accumulated into the result. Note that this uses WriterT and
-- thus frequently appends to the right of the monoid. Be careful to
-- avoid accidental quadratic behavior by using a data structure that
-- supports fast appends. For example, use Data.Sequence instead of a
-- list.
pathWalkAccumulate :: (MonadIO m, Monoid o) => FilePath -> Callback m o -> m o
-- | The lazy version of pathWalk. Instead of running a callback per
-- directory, it returns a lazy list that reads from the filesystem as
-- the list is evaluated.
--
-- pathWalkLazy does not allow selective recursion. For richer
-- functionality, see the directory-tree package at
-- https://hackage.haskell.org/package/directory-tree
pathWalkLazy :: MonadIO m => FilePath -> m [(FilePath, [FilePath], [FilePath])]
instance GHC.Classes.Eq System.Directory.PathWalk.WalkStatus
instance GHC.Show.Show System.Directory.PathWalk.WalkStatus