cabal-file-th-0.2: Template Haskell expressions for reading fields from a project's cabal file.

Distribution.PackageDescription.TH

Contents

Description

Utility functions for reading cabal file fields through template haskell.

Synopsis

Template Haskell functions

packageVariable :: Text a => (PackageDescription -> a) -> Q ExpSource

Renders the package variable specified by the function. The cabal file interrogated is the first one that is found in the current working directory.

packageVariableFrom :: Text a => FilePath -> (PackageDescription -> a) -> Q ExpSource

Renders the package variable specified by the function, from a cabal file and the given path.

Cabal file data structures

The data structures for the cabal file are re-exported here for ease of use.

data PackageDescription

This data type is the internal representation of the file pkg.cabal. It contains two kinds of information about the package: information which is needed for all packages, such as the package name and version, and information which is needed for the simple build system only, such as the compiler options and library name.

Constructors

PackageDescription 

Fields

package :: PackageIdentifier
 
license :: License
 
licenseFile :: FilePath
 
copyright :: String
 
maintainer :: String
 
author :: String
 
stability :: String
 
testedWith :: [(CompilerFlavor, VersionRange)]
 
homepage :: String
 
pkgUrl :: String
 
bugReports :: String
 
sourceRepos :: [SourceRepo]
 
synopsis :: String

A one-line summary of this package

description :: String

A more verbose description of this package

category :: String
 
customFieldsPD :: [(String, String)]

Custom fields starting with x-, stored in a simple assoc-list.

buildDepends :: [Dependency]
 
specVersionRaw :: Either Version VersionRange

The version of the Cabal spec that this package description uses. For historical reasons this is specified with a version range but only ranges of the form >= v make sense. We are in the process of transitioning to specifying just a single version, not a range.

buildType :: Maybe BuildType
 
library :: Maybe Library
 
executables :: [Executable]
 
testSuites :: [TestSuite]
 
dataFiles :: [FilePath]
 
dataDir :: FilePath
 
extraSrcFiles :: [FilePath]
 
extraTmpFiles :: [FilePath]
 

data PackageIdentifier

The name and version of a package.

Constructors

PackageIdentifier 

Fields

pkgName :: PackageName

The name of this package, eg. foo

pkgVersion :: Version

the version of this package, eg 1.2

data Version

A Version represents the version of a software entity.

An instance of Eq is provided, which implements exact equality modulo reordering of the tags in the versionTags field.

An instance of Ord is also provided, which gives lexicographic ordering on the versionBranch fields (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2, etc.). This is expected to be sufficient for many uses, but note that you may need to use a more specific ordering for your versioning scheme. For example, some versioning schemes may include pre-releases which have tags "pre1", "pre2", and so on, and these would need to be taken into account when determining ordering. In some cases, date ordering may be more appropriate, so the application would have to look for date tags in the versionTags field and compare those. The bottom line is, don't always assume that compare and other Ord operations are the right thing for every Version.

Similarly, concrete representations of versions may differ. One possible concrete representation is provided (see showVersion and parseVersion), but depending on the application a different concrete representation may be more appropriate.

Constructors

Version 

Fields

versionBranch :: [Int]

The numeric branch for this version. This reflects the fact that most software versions are tree-structured; there is a main trunk which is tagged with versions at various points (1,2,3...), and the first branch off the trunk after version 3 is 3.1, the second branch off the trunk after version 3 is 3.2, and so on. The tree can be branched arbitrarily, just by adding more digits.

We represent the branch as a list of Int, so version 3.2.1 becomes [3,2,1]. Lexicographic ordering (i.e. the default instance of Ord for [Int]) gives the natural ordering of branches.

versionTags :: [String]

A version can be tagged with an arbitrary list of strings. The interpretation of the list of tags is entirely dependent on the entity that this version applies to.