HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

ModuleCabal-3.12.1.0Haskell2010

Distribution.Simple.Program.Db

This provides a ProgramDb type which holds configured and not-yet configured programs. It is the parameter to lots of actions elsewhere in Cabal that need to look up and run programs. If we had a Cabal monad, the ProgramDb would probably be a reader or state component of it.

One nice thing about using it is that any program that is registered with Cabal will get some "configure" and ".cabal" helpers like --with-foo-args --foo-path= and extra-foo-args.

There's also a hook for adding programs in a Setup.lhs script. See hookedPrograms in Distribution.Simple.UserHooks. This gives a hook user the ability to get the above flags and such so that they don't have to write all the PATH logic inside Setup.lhs.

  • 1 type
  • 29 values
  • PackageCabal-3.12.1.0
  • Exports30
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceDb.hs

The collection of configured programs we can run

4 declarations
datadata ProgramDb
#

The configuration is a collection of information about programs. It contains information both about configured programs and also about programs that we are yet to configure.

The idea is that we start from a collection of unconfigured programs and one by one we try to configure them at which point we move them into the configured collection. For unconfigured programs we record not just the Program but also any user-provided arguments and location for the program.

Instances4Read, Show, Binary, Structured

Query and manipulate the program db

valueuserSpecifyPath
  1. :: String

    Program name

  2. -> FilePath

    user-specified path to the program

  3. -> ProgramDb
  4. -> ProgramDb
#

User-specify this path. Basically override any path information for this program in the configuration. If it's not a known program ignore it.

valueuserSpecifyArgs
  1. :: String

    Program name

  2. -> [ProgArg]

    user-specified args

  3. -> ProgramDb
  4. -> ProgramDb
#

User-specify the arguments for this program. Basically override any args information for this program in the configuration. If it's not a known program, ignore it..

Query and manipulate the program db

Try to configure a specific program. If the program is already included in the collection of unconfigured programs then we use any user-supplied location and arguments. If the program gets configured successfully it gets added to the configured collection.

Note that it is not a failure if the program cannot be configured. It's only a failure if the user supplied a location and the program could not be found at that location.

The reason for it not being a failure at this stage is that we don't know up front all the programs we will need, so we try to configure them all. To verify that a program was actually successfully configured use requireProgram.

Check that a program is configured and available to be run.

Additionally check that the program version number is suitable and return it. For example you could require AnyVersion or orLaterVersion (Version [1,0] [])

It returns the configured program, its version number and a possibly updated ProgramDb. If the program could not be configured or the version is unsuitable, it returns an error value.