FilePather-0.0.2: Functions on System.FilePath

System.FilePath.FilePather

Contents

Synopsis

Data type

data FilePather a Source

A function that takes a FilePath and produces a value.

Constructor and unwrapper

filePather :: (FilePath -> a) -> FilePather aSource

Construct a FilePather from the given function

FilePather values

filePath :: FilePather FilePathSource

A value that runs the identity function.

always :: FilePather BoolSource

A value that always produces the value True.

always' :: FilePather (a -> Bool)Source

A value using a constant function that produces the value True.

never :: FilePather BoolSource

A value that always produces the value False.

never' :: FilePather (a -> Bool)Source

A value that always produces a constant function that produces the value False.

extension :: FilePather FilePathSource

A value that produces the extension of the given FilePath.

extension' :: FilePather (a -> FilePath)Source

A value using a constant function that produces the extension of the given FilePath.

directory :: FilePather FilePathSource

A value that produces the directory of the given FilePath.

directory' :: FilePather (a -> FilePath)Source

A value using a constant function that produces the directory of the given FilePath.

hasExtension :: FilePather BoolSource

A value that produces a value denoting whether or not the given FilePath has an extension.

hasExtension' :: FilePather (a -> Bool)Source

A value using a constant function that produces a value denoting whether or not the given FilePath has an extension.

splitExtension :: FilePather (String, String)Source

A value that produces a value splitting the given FilePath by its extension.

splitExtension' :: FilePather (a -> (String, String))Source

A value using a constant function that produces a value splitting the given FilePath by its extension.

splitDirectories :: FilePather [FilePath]Source

A value that produces a value splitting the given FilePath into its directories.

splitDirectories' :: FilePather (a -> [FilePath])Source

A value using a constant function that produces a value splitting the given FilePath into its directories.

hasTrailingPathSeparator :: FilePather BoolSource

A value that produces a value denoting whether or not the given FilePath has a trailing path separator.

hasTrailingPathSeparator' :: FilePather (a -> Bool)Source

A value using a constant function that produces a value denoting whether or not the given FilePath has a trailing path separator.

fileName :: FilePather FilePathSource

A value that produces the file name of the given FilePath.

fileName' :: FilePather (a -> FilePath)Source

A value using a constant function that produces the file name of the given FilePath.

baseName :: FilePather FilePathSource

A value that produces the base name of the given FilePath.

baseName' :: FilePather (a -> FilePath)Source

A value using a constant function that produces the base name of the given FilePath.

normalise :: FilePather FilePathSource

A value that normalises the given FilePath.

normalise' :: FilePather (a -> FilePath)Source

A value using a constant function that normalises the given FilePath.

makeValid :: FilePather FilePathSource

A value that makes valid the given FilePath.

makeValid' :: FilePather (a -> FilePath)Source

A value using a constant function that makes valid the given FilePath.

isRelative :: FilePather BoolSource

A value that produces a value denoting whether or not the given FilePath has is relative.

isRelative' :: FilePather (a -> Bool)Source

A value using a constant function that produces a value denoting whether or not the given FilePath has is relative.

isAbsolute :: FilePather BoolSource

A value that produces a value denoting whether or not the given FilePath has is absolute.

isAbsolute' :: FilePather (a -> Bool)Source

A value using a constant function that produces a value denoting whether or not the given FilePath has is absolute.

isValid :: FilePather BoolSource

A value that produces a value denoting whether or not the given FilePath has is valid.

isValid' :: FilePather (a -> Bool)Source

A value using a constant function that produces a value denoting whether or not the given FilePath has is valid.

Find predicates

data FileType Source

The possible types of a file.

Constructors

File

The type is a normal file.

Directory

The type is a directory.

Unknown

The type is unknown.

Instances

type RecursePredicate = FilePather BoolSource

A recurse predicate takes a FilePath and returns whether or not to continue recursing on that file.

type FilterPredicate = FilePather (FileType -> Bool)Source

A filter predicate takes a FilePath and a file type and returns whether or not to filter the value.

isFile :: Applicative f => f (FileType -> Bool)Source

Compares for equivalence to a File in an applicative functor.

isDirectory :: Applicative f => f (FileType -> Bool)Source

Compares for equivalence to a Directory in an applicative functor.

isUnknown :: Applicative f => f (FileType -> Bool)Source

Compares for equivalence to Unknown in an applicative functor.

Find

findSource

Arguments

:: RecursePredicate

The recurse predicate determines whether to continue recursing on the given file path.

-> FilterPredicate

The filter predicate determines whether to keep the current file path.

-> FilePath

The file path to begin finding files.

-> IO [FilePath]

All files found.

Finds all files using the given recurse predicate and filter predicate in the given file path.

Combinators

extensionSatisfies :: (FilePath -> Bool) -> FilterPredicateSource

Returns a filter predicate based on whether a file extension satisfies a predicate.

extensionOneOf :: [FilePath] -> FilterPredicateSource

Returns a filter predicate based on whether a file extension is one of the given list of extensions.

extensionEq :: FilePath -> FilterPredicateSource

Returns a filter predicate based on whether a file extension equals the given extension.

findHereSource

Arguments

:: RecursePredicate

The recurse predicate determines whether to continue recursing on the given file path.

-> FilterPredicate

The filter predicate determines whether to keep the current file path.

-> IO [FilePath]

All files found.

Find in the current directory.

indirSource

Arguments

:: FilePath

The directory to switch to.

-> (FilePath -> IO a)

The action to run after being given the current directory.

-> IO a

The result of running the action in the switched directory.

Switches to the given directory, runs the given action by passing the current directory and running in the switched directory, then returns to the current directory. The directory is switched back, even if an exception occurs during execution of the action.

| This is useful to run a script in a different directory without switching to it and back again.

indir'Source

Arguments

:: FilePath

The directory to switch to.

-> IO a

The action to run.

-> IO a

The result of running the action in the switched directory.

Switches to the given directory, runs the given action and running in the switched directory, then returns to the current directory. The directory is switched back, even if an exception occurs during execution of the action.

| This is useful to run a script in a different directory without switching to it and back again.