HORIZON HASKELLDocslts/ghc-9.14.xb2f3bfd2026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11

ModuleCabal-syntax-3.16.0.0Haskell2010

Distribution.Utils.Path

  • 22 types
  • 2 classes
  • 20 values

Symbolic path endpoints

2 declarations
datadata FileOrDir
#

A type-level symbolic name, to an abstract file or directory (e.g. the Cabal package directory).

Constructors

  • File

    A file (with no further information).

  • Dir Type

    The abstract name of a directory or category of directories, e.g. the package directory or a source directory.

datadata AllowAbsolute
#

Is this symbolic path allowed to be absolute, or must it be relative?

Constructors

Abstract directory locations

datadata CWD
#

Abstract directory: current working directory.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Dist
#

Abstract directory: dist directory (e.g. dist-newstyle).

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Source
#

Abstract directory: source directory (a search directory for source files).

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Include
#

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.

datadata Lib
#

Abstract directory: search directory for extra libraries.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Framework
#

Abstract directory: MacOS framework directory.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Build
#

Abstract directory: build directory.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Artifacts
#

Abstract directory: directory for build artifacts, such as documentation or .hie files.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata PkgDB
#

Abstract directory: package database directory.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata DataDir
#

Abstract directory: data files directory.

See Note [Symbolic paths] in Distribution.Utils.Path.

Instances1Newtype
datadata Mix
#

Abstract directory: directory for HPC .mix files.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Tix
#

Abstract directory: directory for HPC .tix files.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Tmp
#

Abstract directory: a temporary directory.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata Response
#

Abstract directory: directory for response files.

See Note [Symbolic paths] in Distribution.Utils.Path.

datadata PkgConf
#

Abstract directory: directory for pkg-config files.

See Note [Symbolic paths] in Distribution.Utils.Path.

Symbolic paths

6 declarations
newtypenewtype SymbolicPathX (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir)
#

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, …
classclass FileLike p where
#

Types that support System.FilePath.<.>.

Methods

  • (<.>) :: p -> String -> pinfixr 7

    Like System.FilePath.<.>, but also supporting symbolic paths.

Instances2FileLike
classclass PathLike p q r | q r -> p, p r -> q, p q -> r where
#

Types that support System.FilePath.</>.

Methods

  • (</>) :: p -> q -> rinfixr 5

    Like System.FilePath.</>, but also supporting symbolic paths.

Instances3PathLike

Symbolic path API

valueinterpretSymbolicPath
  1. :: Maybe (SymbolicPath CWD ('Dir from))
  2. -> SymbolicPathX allowAbsolute from to
  3. -> FilePath
#

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

Working directory handling

valueinterpretSymbolicPathCWD :: SymbolicPathX allowAbsolute from to -> FilePath
#

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.

Module names