| ||||||||||
| ||||||||||
| ||||||||||
Description | ||||||||||
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. | ||||||||||
Synopsis | ||||||||||
The collection of configured programs we can run | ||||||||||
data ProgramDb | ||||||||||
| ||||||||||
emptyProgramDb :: ProgramDb | ||||||||||
defaultProgramDb :: ProgramDb | ||||||||||
restoreProgramDb :: [Program] -> ProgramDb -> ProgramDb | ||||||||||
The Read/Show instance does not preserve all the unconfigured Programs because Program is not in Read/Show because it contains functions. So to fully restore a deserialised ProgramDb use this function to add back all the known Programs.
| ||||||||||
Query and manipulate the program db | ||||||||||
addKnownProgram :: Program -> ProgramDb -> ProgramDb | ||||||||||
Add a known program that we may configure later | ||||||||||
addKnownPrograms :: [Program] -> ProgramDb -> ProgramDb | ||||||||||
lookupKnownProgram :: String -> ProgramDb -> Maybe Program | ||||||||||
knownPrograms :: ProgramDb -> [(Program, Maybe ConfiguredProgram)] | ||||||||||
userSpecifyPath | ||||||||||
| ||||||||||
userSpecifyPaths :: [(String, FilePath)] -> ProgramDb -> ProgramDb | ||||||||||
Like userSpecifyPath but for a list of progs and their paths. | ||||||||||
userMaybeSpecifyPath :: String -> Maybe FilePath -> ProgramDb -> ProgramDb | ||||||||||
userSpecifyArgs | ||||||||||
| ||||||||||
userSpecifyArgss :: [(String, [ProgArg])] -> ProgramDb -> ProgramDb | ||||||||||
Like userSpecifyPath but for a list of progs and their args. | ||||||||||
userSpecifiedArgs :: Program -> ProgramDb -> [ProgArg] | ||||||||||
Get any extra args that have been previously specified for a program. | ||||||||||
lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgram | ||||||||||
Try to find a configured program | ||||||||||
updateProgram :: ConfiguredProgram -> ProgramDb -> ProgramDb | ||||||||||
Update a configured program in the database. | ||||||||||
Query and manipulate the program db | ||||||||||
configureProgram :: Verbosity -> Program -> ProgramDb -> IO ProgramDb | ||||||||||
Try to configure a specific program. If the program is already included in the colleciton of unconfigured programs then we use any user-supplied location and arguments. If the program gets configured sucessfully 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 sucessfully configured use requireProgram. | ||||||||||
configureAllKnownPrograms :: Verbosity -> ProgramDb -> IO ProgramDb | ||||||||||
Try to configure all the known programs that have not yet been configured. | ||||||||||
reconfigurePrograms :: Verbosity -> [(String, FilePath)] -> [(String, [ProgArg])] -> ProgramDb -> IO ProgramDb | ||||||||||
reconfigure a bunch of programs given new user-specified args. It takes the same inputs as userSpecifyPath and userSpecifyArgs and for all progs with a new path it calls configureProgram. | ||||||||||
requireProgram :: Verbosity -> Program -> ProgramDb -> IO (ConfiguredProgram, ProgramDb) | ||||||||||
Check that a program is configured and available to be run. It raises an exception if the program could not be configured, otherwise it returns the configured program. | ||||||||||
requireProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (ConfiguredProgram, Version, ProgramDb) | ||||||||||
Check that a program is configured and available to be run. Additionally check that the version of the program number is suitable and return it. For example you could require AnyVersion or orLaterVersion (Version [1,0] []) It raises an exception if the program could not be configured or the version is unsuitable, otherwise it returns the configured program and its version number. | ||||||||||
Produced by Haddock version 2.6.0 |