HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleCabal-syntax-3.12.1.0Haskell2010

Distribution.Types.PackageDescription

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.

  • 1 type
  • 26 values
datadata 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

Instances12Eq, Data, Ord, Read, Show, Generic, …

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.

valuewithLib :: PackageDescription -> (Library -> IO ()) -> IO ()
#

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#buildable_vs_enabled_components for more information.

valuewithExe :: PackageDescription -> (Executable -> IO ()) -> IO ()
#

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#buildable_vs_enabled_components for more information.

valuewithTest :: PackageDescription -> (TestSuite -> IO ()) -> IO ()
#

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#buildable_vs_enabled_components for more information.

valuewithBenchmark :: PackageDescription -> (Benchmark -> IO ()) -> IO ()
#

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#buildable_vs_enabled_components for more information.