stack-1.3.2: The Haskell Tool Stack

Safe Haskell | None
Language | Haskell2010

Path.Find

Description

Finding files.

Synopsis

- findFileUp :: (MonadIO m, MonadThrow m) => Path Abs Dir -> (Path Abs File -> Bool) -> Maybe (Path Abs Dir) -> m (Maybe (Path Abs File))
- findDirUp :: (MonadIO m, MonadThrow m) => Path Abs Dir -> (Path Abs Dir -> Bool) -> Maybe (Path Abs Dir) -> m (Maybe (Path Abs Dir))
- findFiles :: Path Abs Dir -> (Path Abs File -> Bool) -> (Path Abs Dir -> Bool) -> IO [Path Abs File]
- findInParents :: MonadIO m => (Path Abs Dir -> m (Maybe a)) -> Path Abs Dir -> m (Maybe a)

# Documentation

findFileUp #

Arguments

:: (MonadIO m, MonadThrow m) |
=> Path Abs Dir | Start here.
-> (Path Abs File -> Bool) | Predicate to match the file.
-> Maybe (Path Abs Dir) | Do not ascend above this directory.
-> m (Maybe (Path Abs File)) | Absolute file path.

Find the location of a file matching the given predicate.

findDirUp #

Arguments

:: (MonadIO m, MonadThrow m) |
=> Path Abs Dir | Start here.
-> (Path Abs Dir -> Bool) | Predicate to match the directory.
-> Maybe (Path Abs Dir) | Do not ascend above this directory.
-> m (Maybe (Path Abs Dir)) | Absolute directory path.

Find the location of a directory matching the given predicate.

findFiles #

Arguments

:: Path Abs Dir | Root directory to begin with.
-> (Path Abs File -> Bool) | Predicate to match files.
-> (Path Abs Dir -> Bool) | Predicate for which directories to traverse.
-> IO [Path Abs File] | List of matching files.

Find files matching predicate below a root directory.

NOTE: this skips symbolic directory links, to avoid loops. This may not make sense for all uses of file finding.

TODO: write one of these that traverses symbolic links but efficiently ignores loops.

findInParents :: MonadIO m => (Path Abs Dir -> m (Maybe a)) -> Path Abs Dir -> m (Maybe a) #

`findInParents f path` applies `f` to `path` and its `parent`s until it finds a `Just` or reaches the root directory.