-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Path walking utilities for Haskell programs
--   
--   <a>System.Directory.PathWalk</a> 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.
--   
--   <pre>
--   import System.Directory.PathWalk
--   
--   pathWalk "some/directory" $ \root dirs files -&gt; do
--     forM_ files $ \file -&gt;
--       when (".hs" `isSuffixOf` file) $ do
--         putStrLn $ joinPath [root, file]
--   </pre>
@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 <a>pathWalk</a>, the callback always returns
--   '()'. If using <a>pathWalkInterruptible</a>, it returns whether to
--   continue, prevent recursing further, or stop traversal entirely.
type Callback m a = FilePath -> [FilePath] -> [FilePath] -> m a

-- | <a>pathWalk</a> 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.
--   
--   <pre>
--   pathWalk "src" $ \dir subdirs files -&gt; do
--     forM_ files $ \file -&gt; do
--       when ("Test.hs" `isSuffixOf` file) $ do
--         registerTestFile $ dir &lt;/&gt; file
--   </pre>
pathWalk :: MonadIO m => FilePath -> Callback m () -> m ()

-- | The callback given to <a>pathWalkInterruptible</a> 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 <a>pathWalk</a>, except that the
--   callback can determine whether to continue traversal. See
--   <a>WalkStatus</a>.
pathWalkInterruptible :: MonadIO m => FilePath -> Callback m WalkStatus -> m ()

-- | Traverses a directory tree, just like <a>pathWalk</a>. The difference
--   is that each callback returns a <a>Monoid</a> value, all of which are
--   accumulated into the result. Note that this uses <tt>WriterT</tt> 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 <a>pathWalk</a>. Instead of running a callback per
--   directory, it returns a lazy list that reads from the filesystem as
--   the list is evaluated.
--   
--   <a>pathWalkLazy</a> does not allow selective recursion. For richer
--   functionality, see the directory-tree package at
--   <a>https://hackage.haskell.org/package/directory-tree</a>
pathWalkLazy :: MonadIO m => FilePath -> m [(FilePath, [FilePath], [FilePath])]
instance GHC.Classes.Eq System.Directory.PathWalk.WalkStatus
instance GHC.Show.Show System.Directory.PathWalk.WalkStatus
