hspretty-0.2.0.0: My opinionated Haskell project formatter.
Safe HaskellNone
LanguageHaskell2010

PathFilter

Description

 
Synopsis

Documentation

data PathAccept Source #

Does a filter accept a path?

Constructors

Accept

Filter accepts the path.

Reject

Filter rejects the path.

Instances

Instances details
Show PathAccept Source # 
Instance details

Defined in PathFilter

toBool :: PathAccept -> Bool Source #

Convert a PathAccept type to a Bool suitable for filtering.

newtype PathFilter Source #

Path filter: examine a relative file and decide if we accept it.

Constructors

PathFilter 

Instances

Instances details
Semigroup PathFilter Source # 
Instance details

Defined in PathFilter

Monoid PathFilter Source # 
Instance details

Defined in PathFilter

pfNoHidden :: PathFilter Source #

PathFilter that excludes hidden files or directories, starting with a period.

For example:

>>> :set -XQuasiQuotes
>>> import qualified Path
>>> unPathFilter pfNoHidden [Path.relfile|src/.hidden/something.txt|]
Reject
>>> unPathFilter pfNoHidden [Path.relfile|src/nothidden/something.txt|]
Accept

pfNoDistNewstyle :: PathFilter Source #

PathFilter that excludes any path components that are named dist-newstyle.

pfExtension :: ShortText -> PathFilter Source #

PathFilter that keeps only files with a given extension.

The extension to be tested should start with a period.

For example:

>>> :set -XQuasiQuotes -XOverloadedStrings
>>> import qualified Path
>>> pfHs = pfExtension ".hs"
>>> unPathFilter pfHs [Path.relfile|src/ModuleA/ModuleB.hs|]
Accept
>>> unPathFilter pfHs [Path.relfile|src/ModuleA/something.txt|]
Reject

componentFilter :: (ShortText -> PathAccept) -> PathFilter Source #

Create a filter from a function that examines each component of a path.

pathComponents :: Path Rel File -> [ShortText] Source #

Return the components of a path as a list.

For example:

>>> :set -XQuasiQuotes
>>> import qualified Path
>>> pathComponents [Path.relfile|dir/package/file.txt|]
["dir","package","file.txt"]
>>> pathComponents [Path.relfile|file.txt|]
["file.txt"]