cabal-install-3.10.2.1: The command-line interface for Cabal and Hackage.

Safe Haskell | None
Language | Haskell2010

Distribution.Client.Glob

Synopsis

- data FilePathGlob = FilePathGlob FilePathRoot FilePathGlobRel
- data FilePathRoot
  - = FilePathRelative
  - | FilePathRoot FilePath
  - | FilePathHomeDir
- data FilePathGlobRel
  - = GlobDir !Glob !FilePathGlobRel
  - | GlobFile !Glob
  - | GlobDirTrailing
- type Glob = [GlobPiece]
- data GlobPiece
  - = WildCard
  - | Literal String
  - | Union [Glob]
- matchFileGlob :: FilePath -> FilePathGlob -> IO [FilePath]
- matchFileGlobRel :: FilePath -> FilePathGlobRel -> IO [FilePath]
- matchGlob :: Glob -> String -> Bool
- isTrivialFilePathGlob :: FilePathGlob -> Maybe FilePath
- getFilePathRootDirectory :: FilePathRoot -> FilePath -> IO FilePath

# Documentation

data FilePathGlob #

A file path specified by globbing

Constructors

FilePathGlob FilePathRoot FilePathGlobRel |

#### Instances

Instances details

Parsec FilePathGlob # |
Instance details Defined in Distribution.Client.Glob Methods parsec :: CabalParsing m => m FilePathGlob #
Pretty FilePathGlob # |
Instance details Defined in Distribution.Client.Glob Methods pretty :: FilePathGlob -> Doc # prettyVersioned :: CabalSpecVersion -> FilePathGlob -> Doc #
Structured FilePathGlob # |
Instance details Defined in Distribution.Client.Glob Methods structure :: Proxy FilePathGlob -> Structure # structureHash' :: Tagged FilePathGlob MD5
Generic FilePathGlob # |
Instance details Defined in Distribution.Client.Glob Associated Types
type Rep FilePathGlob |
Instance details Defined in Distribution.Client.Glob type Rep FilePathGlob = D1 ('MetaData "FilePathGlob" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "FilePathGlob" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePathRoot) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePathGlobRel)))
Methods from :: FilePathGlob -> Rep FilePathGlob x # to :: Rep FilePathGlob x -> FilePathGlob #
Show FilePathGlob # |
Instance details Defined in Distribution.Client.Glob Methods showsPrec :: Int -> FilePathGlob -> ShowS # show :: FilePathGlob -> String # showList :: [FilePathGlob] -> ShowS #
Binary FilePathGlob # |
Instance details Defined in Distribution.Client.Glob Methods put :: FilePathGlob -> Put # get :: Get FilePathGlob # putList :: [FilePathGlob] -> Put #
Eq FilePathGlob # |
Instance details Defined in Distribution.Client.Glob Methods (==) :: FilePathGlob -> FilePathGlob -> Bool # (/=) :: FilePathGlob -> FilePathGlob -> Bool #
type Rep FilePathGlob # |
Instance details Defined in Distribution.Client.Glob type Rep FilePathGlob = D1 ('MetaData "FilePathGlob" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "FilePathGlob" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePathRoot) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePathGlobRel)))

data FilePathRoot #

Constructors

FilePathRelative |
FilePathRoot FilePath | e.g. `"/"`, `"c:"` or result of `takeDrive`
FilePathHomeDir |

#### Instances

Instances details

Parsec FilePathRoot # |
Instance details Defined in Distribution.Client.Glob Methods parsec :: CabalParsing m => m FilePathRoot #
Pretty FilePathRoot # |
Instance details Defined in Distribution.Client.Glob Methods pretty :: FilePathRoot -> Doc # prettyVersioned :: CabalSpecVersion -> FilePathRoot -> Doc #
Structured FilePathRoot # |
Instance details Defined in Distribution.Client.Glob Methods structure :: Proxy FilePathRoot -> Structure # structureHash' :: Tagged FilePathRoot MD5
Generic FilePathRoot # |
Instance details Defined in Distribution.Client.Glob Associated Types
type Rep FilePathRoot |
Instance details Defined in Distribution.Client.Glob type Rep FilePathRoot = D1 ('MetaData "FilePathRoot" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "FilePathRelative" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FilePathRoot" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "FilePathHomeDir" 'PrefixI 'False) (U1 :: Type -> Type)))
Methods from :: FilePathRoot -> Rep FilePathRoot x # to :: Rep FilePathRoot x -> FilePathRoot #
Show FilePathRoot # |
Instance details Defined in Distribution.Client.Glob Methods showsPrec :: Int -> FilePathRoot -> ShowS # show :: FilePathRoot -> String # showList :: [FilePathRoot] -> ShowS #
Binary FilePathRoot # |
Instance details Defined in Distribution.Client.Glob Methods put :: FilePathRoot -> Put # get :: Get FilePathRoot # putList :: [FilePathRoot] -> Put #
Eq FilePathRoot # |
Instance details Defined in Distribution.Client.Glob Methods (==) :: FilePathRoot -> FilePathRoot -> Bool # (/=) :: FilePathRoot -> FilePathRoot -> Bool #
type Rep FilePathRoot # |
Instance details Defined in Distribution.Client.Glob type Rep FilePathRoot = D1 ('MetaData "FilePathRoot" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "FilePathRelative" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FilePathRoot" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "FilePathHomeDir" 'PrefixI 'False) (U1 :: Type -> Type)))

data FilePathGlobRel #

Constructors

GlobDir !Glob !FilePathGlobRel |
GlobFile !Glob |
GlobDirTrailing | trailing dir, a glob ending in `/`

#### Instances

Instances details

Parsec FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob Methods parsec :: CabalParsing m => m FilePathGlobRel #
Pretty FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob Methods pretty :: FilePathGlobRel -> Doc # prettyVersioned :: CabalSpecVersion -> FilePathGlobRel -> Doc #
Structured FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob Methods structure :: Proxy FilePathGlobRel -> Structure # structureHash' :: Tagged FilePathGlobRel MD5
Generic FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob Associated Types
type Rep FilePathGlobRel |
Instance details Defined in Distribution.Client.Glob type Rep FilePathGlobRel = D1 ('MetaData "FilePathGlobRel" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "GlobDir" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Glob) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FilePathGlobRel)) :+: (C1 ('MetaCons "GlobFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Glob)) :+: C1 ('MetaCons "GlobDirTrailing" 'PrefixI 'False) (U1 :: Type -> Type)))
Methods from :: FilePathGlobRel -> Rep FilePathGlobRel x # to :: Rep FilePathGlobRel x -> FilePathGlobRel #
Show FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob Methods showsPrec :: Int -> FilePathGlobRel -> ShowS # show :: FilePathGlobRel -> String # showList :: [FilePathGlobRel] -> ShowS #
Binary FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob Methods put :: FilePathGlobRel -> Put # get :: Get FilePathGlobRel # putList :: [FilePathGlobRel] -> Put #
Eq FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob Methods (==) :: FilePathGlobRel -> FilePathGlobRel -> Bool # (/=) :: FilePathGlobRel -> FilePathGlobRel -> Bool #
type Rep FilePathGlobRel # |
Instance details Defined in Distribution.Client.Glob type Rep FilePathGlobRel = D1 ('MetaData "FilePathGlobRel" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "GlobDir" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Glob) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FilePathGlobRel)) :+: (C1 ('MetaCons "GlobFile" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Glob)) :+: C1 ('MetaCons "GlobDirTrailing" 'PrefixI 'False) (U1 :: Type -> Type)))

type Glob = [GlobPiece] #

A single directory or file component of a globbed path

data GlobPiece #

A piece of a globbing pattern

Constructors

WildCard |
Literal String |
Union [Glob] |

#### Instances

Instances details

Structured GlobPiece # |
Instance details Defined in Distribution.Client.Glob Methods structure :: Proxy GlobPiece -> Structure # structureHash' :: Tagged GlobPiece MD5
Generic GlobPiece # |
Instance details Defined in Distribution.Client.Glob Associated Types
type Rep GlobPiece |
Instance details Defined in Distribution.Client.Glob type Rep GlobPiece = D1 ('MetaData "GlobPiece" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "WildCard" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Literal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "Union" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Glob]))))
Methods from :: GlobPiece -> Rep GlobPiece x # to :: Rep GlobPiece x -> GlobPiece #
Show GlobPiece # |
Instance details Defined in Distribution.Client.Glob Methods showsPrec :: Int -> GlobPiece -> ShowS # show :: GlobPiece -> String # showList :: [GlobPiece] -> ShowS #
Binary GlobPiece # |
Instance details Defined in Distribution.Client.Glob Methods put :: GlobPiece -> Put # get :: Get GlobPiece # putList :: [GlobPiece] -> Put #
Eq GlobPiece # |
Instance details Defined in Distribution.Client.Glob Methods (==) :: GlobPiece -> GlobPiece -> Bool # (/=) :: GlobPiece -> GlobPiece -> Bool #
type Rep GlobPiece # |
Instance details Defined in Distribution.Client.Glob type Rep GlobPiece = D1 ('MetaData "GlobPiece" "Distribution.Client.Glob" "cabal-install-3.10.2.1-EH6AEtqwlbKE3rh89dIk81" 'False) (C1 ('MetaCons "WildCard" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Literal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "Union" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Glob]))))

matchFileGlob :: FilePath -> FilePathGlob -> IO [FilePath] #

Match a `FilePathGlob` against the file system, starting from a given root directory for relative paths. The results of relative globs are relative to the given root. Matches for absolute globs are absolute.

matchFileGlobRel :: FilePath -> FilePathGlobRel -> IO [FilePath] #

Match a `FilePathGlobRel` against the file system, starting from a given root directory. The results are all relative to the given root.

matchGlob :: Glob -> String -> Bool #

Match a globbing pattern against a file path component

isTrivialFilePathGlob :: FilePathGlob -> Maybe FilePath #

Check if a `FilePathGlob` doesn't actually make use of any globbing and is in fact equivalent to a non-glob `FilePath`.

If it is trivial in this sense then the result is the equivalent constant `FilePath`. On the other hand if it is not trivial (so could in principle match more than one file) then the result is `Nothing`.

getFilePathRootDirectory #

Arguments

:: FilePathRoot |
-> FilePath | root for relative paths
-> IO FilePath |

Get the `FilePath` corresponding to a `FilePathRoot`.

The `FilePath` argument is required to supply the path for the `FilePathRelative` case.