Cabal-3.4.0.0: A framework for packaging Haskell software

Distribution.Types.PackageDescription

Description

This defines the data structure for the .cabal file format. There are several parts to this structure. It has top level info and then Library, Executable, TestSuite, and Benchmark sections each of which have associated BuildInfo data that's used to build the library, exe, test, or benchmark. To further complicate things there is both a PackageDescription and a GenericPackageDescription. This distinction relates to cabal configurations. When we initially read a .cabal file we get a GenericPackageDescription which has all the conditional sections. Before actually building a package we have to decide on each conditional. Once we've done that we get a PackageDescription. It was done this way initially to avoid breaking too much stuff when the feature was introduced. It could probably do with being rationalised at some point to make it simpler.

Synopsis

# Documentation

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 FieldsspecVersion :: CabalSpecVersionThe version of the Cabal spec that this package description uses.package :: PackageIdentifier licenseRaw :: Either License License licenseFiles :: [FilePath] copyright :: !ShortText maintainer :: !ShortText author :: !ShortText stability :: !ShortText testedWith :: [(CompilerFlavor, VersionRange)] homepage :: !ShortText pkgUrl :: !ShortText bugReports :: !ShortText sourceRepos :: [SourceRepo] synopsis :: !ShortTextA one-line summary of this packagedescription :: !ShortTextA more verbose description of this packagecategory :: !ShortText customFieldsPD :: [(String, String)]Custom fields starting with x-, stored in a simple assoc-list.buildTypeRaw :: Maybe BuildTypeThe original build-type value as parsed from the .cabal file without defaulting. See also buildType.Since: 2.2setupBuildInfo :: Maybe SetupBuildInfo library :: Maybe Library subLibraries :: [Library] executables :: [Executable] foreignLibs :: [ForeignLib] testSuites :: [TestSuite] benchmarks :: [Benchmark] dataFiles :: [FilePath] dataDir :: FilePath extraSrcFiles :: [FilePath] extraTmpFiles :: [FilePath] extraDocFiles :: [FilePath]

#### Instances

Instances details

The SPDX LicenseExpression of the package.

Since: 2.2.0.0

See license.

Since: 2.2.0.0

The effective build-type after applying defaulting rules.

The original build-type value parsed is stored in the buildTypeRaw field. However, the build-type field is optional and can therefore be empty in which case we need to compute the effective build-type. This function implements the following defaulting rules:

• For cabal-version:2.0 and below, default to the Custom build-type unconditionally.
• Otherwise, if a custom-setup stanza is defined, default to the Custom build-type; else default to Simple build-type.

Since: 2.2

Does this package have a buildable PUBLIC library?

Does this package have any libraries?

withLib :: PackageDescription -> (Library -> IO ()) -> IO () Source #

If the package description has a buildable library section, call the given function with the library build info as argument. You probably want withLibLBI if you have a LocalBuildInfo, see the note in Distribution.Types.ComponentRequestedSpec for more information.

does this package have any executables?

withExe :: PackageDescription -> (Executable -> IO ()) -> IO () Source #

Perform the action on each buildable Executable in the package description. You probably want withExeLBI if you have a LocalBuildInfo, see the note in Distribution.Types.ComponentRequestedSpec for more information.

Does this package have any test suites?

withTest :: PackageDescription -> (TestSuite -> IO ()) -> IO () Source #

Perform an action on each buildable TestSuite in a package. You probably want withTestLBI if you have a LocalBuildInfo, see the note in Distribution.Types.ComponentRequestedSpec for more information.

Does this package have any benchmarks?

withBenchmark :: PackageDescription -> (Benchmark -> IO ()) -> IO () Source #

Perform an action on each buildable Benchmark in a package. You probably want withBenchLBI if you have a LocalBuildInfo, see the note in Distribution.Types.ComponentRequestedSpec for more information.

Does this package have any foreign libraries?

withForeignLib :: PackageDescription -> (ForeignLib -> IO ()) -> IO () Source #

Perform the action on each buildable ForeignLib in the package description.

All BuildInfo in the PackageDescription: libraries, executables, test-suites and benchmarks.

Useful for implementing package checks.

Return all of the BuildInfos of enabled components, i.e., all of the ones that would be built if you run ./Setup build.

Get the combined build-depends entries of all components.

Get the combined build-depends entries of all enabled components, per the given request spec.

All the components in the package.

A list of all components in the package that are buildable, i.e., were not marked with buildable: False. This does NOT indicate if we are actually going to build the component, see enabledComponents instead.

Since: 2.0.0.2

A list of all components in the package that are enabled.

Since: 2.0.0.2