cabal-helper-1.0.0.0: Give Haskell development tools access to Cabal project environment

LicenseApache-2.0
Safe HaskellNone
LanguageHaskell2010

CabalHelper.Compiletime.Types

Description

 
Synopsis

Documentation

data ProjType Source #

The kind of project being managed by a QueryEnv (pun intended). Used as a phantom-type variable throughout to make the project type being passed into various functions correspond to the correct implementation.

Constructors

Cabal CabalProjType

cabal project.

Stack

stack project.

data SProjType pt where Source #

A "singleton" datatype for ProjType which allows us to establish a correspondence between a runtime representation of ProjType to the compile-time value at the type level.

If you just want to know the runtime ProjType use demoteSProjType to convert to that.

Constructors

SCabal :: !(SCabalProjType pt) -> SProjType (Cabal pt) 
SStack :: SProjType Stack 
Instances
Show (SProjType pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> SProjType pt -> ShowS #

show :: SProjType pt -> String #

showList :: [SProjType pt] -> ShowS #

data SCabalProjType pt where Source #

This is a singleton, like SProjType, but restricted to just the Cabal project types. We use this to restrict some functions which don't make sense for Stack to just the Cabal project types.

Instances
Show (SCabalProjType pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

data ProjLoc (pt :: ProjType) where Source #

Location of a project context. This is usually just the path project's top-level source code directory together with an optional project-type specific config file path.

To find any recognized default project contexts in a given directory use findProjects.

Build tools usually allow the user to specify the location of their project config files manually, so we also support passing this path here with the *File constructors.

Correspondence between Project and Package Source Directories

Note that the project's source directory does not necessarily correspond to the directory containing the project config file, though in some cases it does.

For example cabal v2-build allows the cabal.project file to be positively anywhere in the filesystem when specified via the --cabal-project command-line flag, corresponding to the ProjLocV2File constructor here. This config file can then refer to package directories with absolute paths in the packages: declaration.

Hence it isn't actually possible to find one directory which contains the whole project's source code but rather we have to consider each package's source directory individually, see pSourceDir

Constructors

ProjLocV1CabalFile

A fully specified cabal v1-build project context. Here you can specify both the path to the .cabal file and the source directory of the package. The cabal file path corresponds to the --cabal-file=PATH flag on the cabal command line.

Note that more than one such files existing in a package directory is a user error and while cabal will still complain about that we won't.

Also note that for this project type the concepts of project and package coincide.

Fields

ProjLocV1Dir

A cabal v1-build project context. Essentially the same as ProjLocV1CabalFile but this will dynamically search for the cabal file for you as cabal-install does by default.

If more than one .cabal file is found in the given directory we will shamelessly throw a obscure exception so prefer ProjLocV1CabalFile if you don't want that to happen. This mainly exists for easy upgrading from the cabal-helper-0.8 series.

Fields

ProjLocV2File

A cabal v2-build project context. The path to the cabal.project file, though you can call it whatever you like. This configuration file then points to the packages that make up this project. This corresponds to the --cabal-project=PATH flag on the cabal command line.

Fields

ProjLocV2Dir

This is equivalent to ProjLocV2File but using the default cabal.project file name in the given directory.

Fields

ProjLocStackYaml

A stack project context. Specify the path to the stack.yaml file here. This configuration file then points to the packages that make up this project. Corresponds to stack's --stack-yaml=PATH command line flag if different from the default name, stack.yaml.

Note: with Stack the invariant takeDirectory plStackYaml == projdir holds.

Fields

Instances
Show (ProjLoc pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> ProjLoc pt -> ShowS #

show :: ProjLoc pt -> String #

showList :: [ProjLoc pt] -> ShowS #

data DistDir (pt :: ProjType) where Source #

A build directory for a certain project type. The pt type variable must be compatible with the ProjLoc used. This is enforced by the type system so you can't get this wrong.

Constructors

DistDirCabal :: !(SCabalProjType pt) -> !FilePath -> DistDir (Cabal pt)

A build-directory for cabal, aka. dist-dir in Cabal terminology. SCabalProjType specifies whether we should use v2-build or v1-build. This choice must correspond to ProjLoc 's project type.

DistDirStack :: !(Maybe RelativePath) -> DistDir Stack

A build-directory for stack, aka. work-dir. Optionally override Stack's work-dir. If you just want to use Stack's default set to Nothing

Instances
Show (DistDir pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> DistDir pt -> ShowS #

show :: DistDir pt -> String #

showList :: [DistDir pt] -> ShowS #

data Ex a Source #

General purpose existential wrapper. Useful for hiding a phantom type argument.

Say you have:

{-# LANGUAGE DataKinds, GADTS #-}
data K = A | B | ...
data Q k where
  QA :: ... -> Q 'A
  QB :: ... -> Q 'B

and you want a list of Q. You can use Ex to hide the phantom type argument and recover it later by matching on the GADT constructors:

qa :: Q A
qa = QA

qb :: Q B
qb = QB

mylist :: [Ex Q]
mylist = [Ex qa, Ex qb]

Constructors

Ex (a x) 

type QueryEnv pt = QueryEnvI QueryCache pt Source #

Environment for running a Query. The constructor is not exposed in the API to allow extending it with more fields without breaking user code.

To create a QueryEnv use the mkQueryEnv smart constructor instead. Some field accessors are exported and may be used to override the defaults filled in by mkQueryEnv. See below.

Note that this environment contains an IORef used as a cache. If you want to take advantage of this you should not simply discard the value returned by the smart constructor after one use.

data QueryEnvI c (pt :: ProjType) Source #

Constructors

QueryEnv 

Fields

type QueryCache = QueryCacheI PreInfo Programs ProjInfo UnitInfo Source #

Full instansiation of QueryCacheI, with all cache fields visible

type QCPreInfo progs proj_info unit_info = QueryCacheI PreInfo progs proj_info unit_info Source #

QueryCacheI, only instantiated with PreInfo cache.

type QCProgs proj_info unit_info = QueryCacheI PreInfo Programs proj_info unit_info Source #

QueryCacheI, only instantiated with PreInfo and configured Programs cache.

data QueryCacheI pre_info progs proj_info unit_info pt Source #

Constructors

QueryCache 

Fields

data Package' units Source #

A Package is a named collection of many Units.

Constructors

Package 

Fields

Instances
Show units => Show (Package' units) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> Package' units -> ShowS #

show :: Package' units -> String #

showList :: [Package' units] -> ShowS #

data Unit pt Source #

A Unit is essentially a "build target". It is used to refer to a set of components (exes, libs, tests etc.) which are managed by a certain instance of the Cabal build-system[1]. We may get information on the components in a unit by retriving the corresponding UnitInfo.

[1]: No I'm not talking about the cabal-install build-tool, I'm talking about the Cabal build-system. Note the distinction. Both cabal-install and Stack use the Cabal build-system (aka lib:Cabal) underneath.

Note that a Unit value is only valid within the QueryEnv context it was created in, this is however this is not enforced by the API. Furthermore if the user changes the underlying project configuration while your application is running even a properly scoped Unit could become invalid because the component it belongs to was removed from the cabal file.

Constructors

Unit 

Fields

Instances
Show (Unit pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> Unit pt -> ShowS #

show :: Unit pt -> String #

showList :: [Unit pt] -> ShowS #

data UnitImpl pt where Source #

Instances
Show (UnitImpl pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> UnitImpl pt -> ShowS #

show :: UnitImpl pt -> String #

showList :: [UnitImpl pt] -> ShowS #

uComponentName :: Unit pt -> Maybe ChComponentName Source #

This returns the component a Unit corresponds to. This information is only available if the correspondence happens to be unique and known before querying setup-config for the respective project type. Currently this only applies to pt=V2.

This is intended to be used as an optimization, to allow reducing the number of helper invocations for clients that don't need to know the entire project structure.

data UnitHeader Source #

The setup-config header. Note that Cabal writes all the package names in the header using Char8 and hence all characters are truncated from Unicode codepoints to 8-bit Latin-1.

We can be fairly confident that uhSetupId and uhCompilerId won't have names that cause trouble here so it's ok to look at them but user packages are free to have any unicode name.

Constructors

UnitHeader 

Fields

  • uhPackageId :: !(ByteString, Version)

    Name and version of the source package. This is only going to be usable for unicode package names starting with Cabal-3.0.0.0. See uiPackageId for an alternative that always works.

  • uhSetupId :: !(ByteString, Version)

    Name and version of the Setup.hs implementation. We expect Cabal here, naturally.

  • uhCompilerId :: !(ByteString, Version)

    Name and version of the compiler that was used to build Setup.hs. WARNING: This does not identify the GHC version the project is configured to use!

newtype UnitId Source #

Constructors

UnitId String 
Instances
Eq UnitId Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

(==) :: UnitId -> UnitId -> Bool #

(/=) :: UnitId -> UnitId -> Bool #

Ord UnitId Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Read UnitId Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Show UnitId Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

data UnitInfo Source #

The information extracted from a 'Unit'\'s on-disk configuration cache.

Constructors

UnitInfo 

Fields

data ProjConf pt where Source #

Files relevant to the project-scope configuration. We gather them here so we can refer to their paths conveniently throughout the code. These files are not necessarily guaranteed to even exist.

Constructors

ProjConfV1 

Fields

ProjConfV2 
ProjConfStack 

Fields

data ProjInfo pt Source #

Project-scope information cache.

Constructors

ProjInfo 

Fields

Instances
Show (ProjInfo pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> ProjInfo pt -> ShowS #

show :: ProjInfo pt -> String #

showList :: [ProjInfo pt] -> ShowS #

data ProjInfoImpl pt where Source #

Constructors

ProjInfoV1 

Fields

ProjInfoV2 

Fields

ProjInfoStack :: ProjInfoImpl Stack 
Instances
Show (ProjInfoImpl pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

data PreInfo pt where Source #

Constructors

PreInfoCabal :: PreInfo (Cabal cpt) 
PreInfoStack 

Fields

Instances
Show (PreInfo pt) Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Methods

showsPrec :: Int -> PreInfo pt -> ShowS #

show :: PreInfo pt -> String #

showList :: [PreInfo pt] -> ShowS #

newtype CabalFile Source #

Constructors

CabalFile FilePath 
Instances
Show CabalFile Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

type Verbose = ?verbose :: Word -> Bool Source #

type Env = (?progs :: Programs, ?verbose :: Word -> Bool) Source #

type Progs = ?progs :: Programs Source #

data Programs Source #

Configurable paths to various programs we use.

Constructors

Programs 

Fields

Instances
Eq Programs Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Ord Programs Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Read Programs Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Show Programs Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Generic Programs Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Associated Types

type Rep Programs :: Type -> Type #

Methods

from :: Programs -> Rep Programs x #

to :: Rep Programs x -> Programs #

type Rep Programs Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

defaultPrograms :: Programs Source #

By default all programs use their unqualified names, i.e. they will be searched for on PATH.

data EnvOverride Source #

Instances
Eq EnvOverride Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Ord EnvOverride Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Read EnvOverride Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Show EnvOverride Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Generic EnvOverride Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

Associated Types

type Rep EnvOverride :: Type -> Type #

type Rep EnvOverride Source # 
Instance details

Defined in CabalHelper.Compiletime.Types

type Rep EnvOverride = D1 (MetaData "EnvOverride" "CabalHelper.Compiletime.Types" "cabal-helper-1.0.0.0-3RovMtTNraDHCRO0uwfQKJ-c-h-internal" False) (C1 (MetaCons "EnvPrepend" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) :+: (C1 (MetaCons "EnvAppend" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) :+: C1 (MetaCons "EnvReplace" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))