ModuleCabal-syntax-3.16.0.0Haskell2010
Distribution.Utils.Path
- 22 types
- 2 classes
- 20 values
- PackageCabal-syntax-3.16.0.0
- Exports44
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourcePath.hs
Symbolic path endpoints
2 declarationsIs this symbolic path allowed to be absolute, or must it be relative?
Constructors
AllowAbsoluteThe path may be absolute, or it may be relative.
OnlyRelativeThe path must be relative.
Abstract directory locations
Abstract directory: current working directory.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: package directory (e.g. a directory containing the .cabal file).
See Note [Symbolic paths] in Distribution.Utils.Path.
Instances2Newtype
Newtype [RelativePath Pkg 'File] CompatLicenseFileDefined in Cabal-syntax-3.16.0.0 · Distribution.PackageDescription.FieldGrammarNewtype (SymbolicPath Pkg ('Dir DataDir)) CompatDataDirDefined in Cabal-syntax-3.16.0.0 · Distribution.PackageDescription.FieldGrammar
Abstract directory: dist directory (e.g. dist-newstyle).
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: source directory (a search directory for source files).
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: include directory (a search directory for CPP includes like header files, e.g. with ghc -I).
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: search directory for extra libraries.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: MacOS framework directory.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: build directory.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: directory for build artifacts, such as documentation or .hie files.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: package database directory.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: data files directory.
See Note [Symbolic paths] in Distribution.Utils.Path.
Instances1Newtype
Newtype (SymbolicPath Pkg ('Dir DataDir)) CompatDataDirDefined in Cabal-syntax-3.16.0.0 · Distribution.PackageDescription.FieldGrammar
Abstract directory: directory for HPC .mix files.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: directory for HPC .tix files.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: a temporary directory.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: directory for response files.
See Note [Symbolic paths] in Distribution.Utils.Path.
Abstract directory: directory for pkg-config files.
See Note [Symbolic paths] in Distribution.Utils.Path.
Symbolic paths
6 declarationsA symbolic relative path, relative to an abstract location specified
by the from type parameter.
They are *symbolic*, which means we cannot perform any IO until we interpret them (using e.g. interpretSymbolicPath).
A symbolic path which is allowed to be absolute.
They are *symbolic*, which means we cannot perform any IO until we interpret them (using e.g. interpretSymbolicPath).
Constructors
AbsolutePath (forall from. SymbolicPath from to)
Instances1PathLike
(b1 ~ 'Dir b2, c2 ~ c3, midAbsolute ~ 'OnlyRelative) => PathLike (AbsolutePath b1) (SymbolicPathX midAbsolute b2 c2) (AbsolutePath c3)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Path
A symbolic path, possibly relative to an abstract location specified
by the from type parameter.
They are *symbolic*, which means we cannot perform any IO until we interpret them (using e.g. interpretSymbolicPath).
Instances20Newtype, Eq, Data, Ord, Read, Show, …
Newtype [RelativePath Pkg 'File] CompatLicenseFileDefined in Cabal-syntax-3.16.0.0 · Distribution.PackageDescription.FieldGrammar(b1 ~ 'Dir b2, c2 ~ c3, midAbsolute ~ 'OnlyRelative) => PathLike (AbsolutePath b1) (SymbolicPathX midAbsolute b2 c2) (AbsolutePath c3)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathNewtype (SymbolicPath Pkg ('Dir DataDir)) CompatDataDirDefined in Cabal-syntax-3.16.0.0 · Distribution.PackageDescription.FieldGrammarNewtype (RelativePath from to) (RelativePathNT from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.FieldGrammar.NewtypesNewtype (SymbolicPath from to) (SymbolicPathNT from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.FieldGrammar.NewtypesEq (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Path(Typeable from, Typeable allowAbsolute, Typeable to) => Data (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathOrd (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathRead (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathShow (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathGeneric (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathNFData (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathBinary (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathParsec (SymbolicPathX 'AllowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathParsec (SymbolicPathX 'OnlyRelative from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathPretty (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Path(Typeable allowAbsolute, Typeable from, Typeable to) => Structured (SymbolicPathX allowAbsolute from to)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Pathp ~ 'File => FileLike (SymbolicPathX allowAbsolute dir p)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Path(b1 ~ 'Dir b2, a3 ~ a1, c2 ~ c3, midAbsolute ~ 'OnlyRelative) => PathLike (SymbolicPathX allowAbsolute a1 b1) (SymbolicPathX midAbsolute b2 c2) (SymbolicPathX allowAbsolute a3 c3)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathThis instance ensures we don't accidentally discard a symbolic path in a
System.FilePath.</>operation due to the second path being absolute.(Recall that
a / b = bwheneverbis absolute.)type Rep (SymbolicPathX allowAbsolute from to) = D1 ('MetaDataDefined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Path"SymbolicPathX"
"Distribution.Utils.Path"
"Cabal-syntax-3.16.0.0-c954"
'True) (C1 ('MetaCons"SymbolicPath"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)))
Types that support System.FilePath.<.>.
Types that support System.FilePath.</>.
Methods
(</>) :: p -> q -> rinfixr 5Like
System.FilePath.</>, but also supporting symbolic paths.
Instances3PathLike
PathLike FilePath FilePath FilePathDefined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Path(b1 ~ 'Dir b2, c2 ~ c3, midAbsolute ~ 'OnlyRelative) => PathLike (AbsolutePath b1) (SymbolicPathX midAbsolute b2 c2) (AbsolutePath c3)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.Path(b1 ~ 'Dir b2, a3 ~ a1, c2 ~ c3, midAbsolute ~ 'OnlyRelative) => PathLike (SymbolicPathX allowAbsolute a1 b1) (SymbolicPathX midAbsolute b2 c2) (SymbolicPathX allowAbsolute a3 c3)Defined in Cabal-syntax-3.16.0.0 · Distribution.Utils.PathThis instance ensures we don't accidentally discard a symbolic path in a
System.FilePath.</>operation due to the second path being absolute.(Recall that
a / b = bwheneverbis absolute.)
Symbolic path API
Extract the FilePath underlying a SymbolicPath or RelativePath, without interpreting it.
Use this function e.g. to validate the underlying filepath.
When interacting with the file system, you should instead use interpretSymbolicPath or interpretSymbolicPathCWD.
See Note [Symbolic paths] in Distribution.Utils.Path.
A symbolic path from a directory to itself.
Make a RelativePath, ensuring the path is not absolute, but performing no further checks.
Make a SymbolicPath, which may be relative or absolute.
Make a SymbolicPath which may be relative or absolute, without performing any checks.
Avoid using this function in new code.
Change what a symbolic path is pointing to.
Change both what a symbolic path is pointing from and pointing to.
Avoid using this in new code.
Weakening: convert a relative symbolic path to a symbolic path, "forgetting" that it is relative.
Is this symbolic path a relative symbolic path?
Interpret a symbolic path with respect to the given directory.
Use this function before directly interacting with the file system in order to take into account a working directory argument.
NB: when invoking external programs (such as GHC), it is preferable to set
the working directory of the process and use interpretSymbolicPathCWD
rather than calling this function, as this function will turn relative paths
into absolute paths if the working directory is an absolute path.
This can degrade error messages, or worse, break the behaviour entirely
(because the program might expect certain paths to be relative).
See Note [Symbolic paths] in Distribution.Utils.Path.
General filepath API
Like System.FilePath.takeDirectory, for symbolic paths.
Like System.FilePath.dropExtensions, for symbolic paths.
Like System.FilePath.replaceExtension, for symbolic paths.
Like System.FilePath.normalise, for symbolic paths.
Working directory handling
Interpret a symbolic path, **under the assumption that the working directory is the package directory**.
Use interpretSymbolicPath instead if you need to take into account a working directory argument before directly interacting with the file system.
Use this function instead of interpretSymbolicPath when invoking a child process: set the working directory of the sub-process, and use this function, e.g.:
callGhc :: Maybe (SymbolicPath CWD (Dir Pkg))
-> SymbolicPath (Dir Pkg) File
-> IO ()
callGhc mbWorkDir inputFile =
runProgramInvocation $
programInvocationCwd mbWorkDir ghcProg [interpretSymbolicPathCWD inputFile]In this example, programInvocationCwd sets the working directory, so it is
appropriate to use interpretSymbolicPathCWD to provide its arguments.
See Note [Symbolic paths] in Distribution.Utils.Path.
Absolute path to the current working directory.
Try to make a symbolic path relative.
This function does nothing if the path is already relative.
NB: this function may fail to make the path relative.
Module names
Retrieve the relative symbolic path to a Haskell module.