Information collected during the traversal of a directory.
Constructors
FileInfoinfoPath :: FilePathfile path
infoDepth :: Intcurrent recursion depth
infoStatus :: FileStatusstatus of file
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulefilemanip-0.3.6.3Haskell98
This module provides functions for traversing a filesystem hierarchy. The find function generates a lazy list of matching files, while fold performs a left fold.
Both find and fold allow fine control over recursion, using the FindClause type. This type is also used to pre-filter the results returned by find.
The FindClause type lets you write filtering and recursion control expressions clearly and easily.
For example, this clause matches C source files.
extension ==? ".c" ||? extension ==? ".h"
Because FindClause is a monad, you can use the usual monad machinery to, for example, lift pure functions into it.
Here's a clause that will return True for any file whose
directory name contains the word "temp".
(isInfixOf "temp") `liftM` directory
Information collected during the traversal of a directory.
FileInfoinfoPath :: FilePathfile path
infoDepth :: Intcurrent recursion depth
infoStatus :: FileStatusstatus of file
Monad FindClauseDefined in filemanip-0.3.6.3 · System.FilePath.FindFunctor FindClauseDefined in filemanip-0.3.6.3 · System.FilePath.FindApplicative FindClauseDefined in filemanip-0.3.6.3 · System.FilePath.Findfind :: RecursionPredicatecontrol recursion into subdirectories
-> FilterPredicatedecide whether a file appears in the result
-> FilePathdirectory to start searching
-> IO [FilePath]files that matched the FilterPredicate
Search a directory recursively, with recursion controlled by a RecursionPredicate. Lazily return a sorted list of all files matching the given FilterPredicate. Any errors that occur are ignored, with warnings printed to stderr.
Search a directory recursively, with recursion controlled by a RecursionPredicate. Fold over all files found. Any errors that occur are ignored, with warnings printed to stderr. The fold function is run from "left" to "right", so it should be strict in its left argument to avoid space leaks. If you need a right-to-left fold, use foldr on the result of findWithHandler instead.
findWithHandler :: (FilePath -> IOException -> IO [FilePath])error handler
-> RecursionPredicatecontrol recursion into subdirectories
-> FilterPredicatedecide whether a file appears in the result
-> FilePathdirectory to start searching
-> IO [FilePath]files that matched the FilterPredicate
Search a directory recursively, with recursion controlled by a RecursionPredicate. Lazily return a sorted list of all files matching the given FilterPredicate. Any errors that occur are dealt with by the given handler.
foldWithHandler :: (FilePath -> a -> IOException -> IO a)error handler
-> RecursionPredicatecontrol recursion into subdirectories
-> (a -> FileInfo -> a)function to fold with
-> aseed value for fold
-> FilePathdirectory to start searching
-> IO afinal value after folding
Search a directory recursively, with recursion controlled by a RecursionPredicate. Fold over all files found. Any errors that occur are dealt with by the given handler. The fold is strict, and run from "left" to "right", so the folded function should be strict in its left argument to avoid space leaks. If you need a right-to-left fold, use foldr on the result of findWithHandler instead.
Run the given FindClause on the given FileInfo and return its result. This can be useful if you are writing a function to pass to fold.
Example:
myFoldFunc :: a -> FileInfo -> a
myFoldFunc a i = let useThisFile = evalClause (fileName ==? "foo") i
in if useThisFile
then fiddleWith a
else a
Return the type of a file. This is much more useful for case analysis than the usual functions on FileStatus values.
Lift a binary operator into the FindClause monad, so that it
becomes a combinator. The left hand side of the combinator should
be a FindClause a, while the right remains a normal value of
type a.
Return the name of the file being visited.
Return the FileStatus for the current file.
Return the current recursion depth.
Return the current FileInfo.
Unconditionally return True.
These are simply lifted versions of the FileStatus accessor functions in the System.Posix.Files module. The definitions all have the following form:
deviceID :: FindClause System.Posix.Types.DeviceID
deviceID = System.Posix.Files.deviceID `liftM` fileStatus
Return the permission bits of the FileMode.
Return the canonical path of the file being visited.
See canonicalizePath for details of what canonical path means.
Return the canonical name of the file (canonical path with the directory part removed).
If the current file is a symbolic link, return Just the status of the ultimate endpoint of the link. Otherwise (including in the case of an error), return Nothing.
Example:
statusType `liftM` followStatus ==? RegularFile
These are lifted versions of the most commonly used binary operators. They have the same fixities and associativities as their unlifted counterparts. They are lifted using liftOp, like so:
(==?) = liftOp (==)Return True if the current file's name matches the given GlobPattern.
Return True if the current file's name does not match the given GlobPattern.
This operator is useful to check if bits are set in a FileMode.