Safe Haskell | Safe-Infered |
---|
Utility functions for reading cabal file fields through template haskell.
- packageVariable :: Text a => (PackageDescription -> a) -> Q Exp
- packageVariableFrom :: Text a => FilePath -> (PackageDescription -> a) -> Q Exp
- data PackageDescription = PackageDescription {
- 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
- description :: String
- category :: String
- customFieldsPD :: [(String, String)]
- buildDepends :: [Dependency]
- specVersionRaw :: Either Version VersionRange
- buildType :: Maybe BuildType
- library :: Maybe Library
- executables :: [Executable]
- testSuites :: [TestSuite]
- benchmarks :: [Benchmark]
- dataFiles :: [FilePath]
- dataDir :: FilePath
- extraSrcFiles :: [FilePath]
- extraTmpFiles :: [FilePath]
- data PackageIdentifier = PackageIdentifier {}
- data Version = Version {
- versionBranch :: [Int]
- versionTags :: [String]
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.
PackageDescription | |
|
data PackageIdentifier
The name and version of a package.
PackageIdentifier | |
|
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.
Version | |
|