| Cabal-1.8.0.6: A framework for packaging Haskell software | Contents | Index

Distribution.Simple.Program.Types

Portability | portable
Maintainer | cabal-devel@haskell.org

Contents

Program and functions for constructing them
Configured program and related functions

Description

This provides an abstraction which deals with configuring and running programs. A `Program` is a static notion of a known program. A `ConfiguredProgram` is a `Program` that has been found on the current machine and is ready to be run (possibly with some user-supplied default args). Configuring a program involves finding its location and if necessary finding its version. There's reasonable default behavior for trying to find "foo" in PATH, being able to override its location, etc.

Synopsis

data Program = Program {

programName :: String
programFindLocation :: Verbosity -> IO (Maybe FilePath)
programFindVersion :: Verbosity -> FilePath -> IO (Maybe Version)
programPostConf :: Verbosity -> ConfiguredProgram -> IO [ProgArg]

}

simpleProgram :: String -> Program

data ConfiguredProgram = ConfiguredProgram {

programId :: String
programVersion :: Maybe Version
programArgs :: [String]
programLocation :: ProgramLocation

}

programPath :: ConfiguredProgram -> FilePath
type ProgArg = String

data ProgramLocation

= UserSpecified {

locationPath :: FilePath

}

| FoundOnSystem {

locationPath :: FilePath

}

Program and functions for constructing them
data Program

Represents a program which can be configured.
Constructors

Program |

programName :: String | The simple name of the program, eg. ghc
programFindLocation :: Verbosity -> IO (Maybe FilePath) | A function to search for the program if it's location was not specified by the user. Usually this will just be a
programFindVersion :: Verbosity -> FilePath -> IO (Maybe Version) | Try to find the version of the program. For many programs this is not possible or is not necessary so it's ok to return Nothing.
programPostConf :: Verbosity -> ConfiguredProgram -> IO [ProgArg] | A function to do any additional configuration after we have located the program (and perhaps identified its version). It is allowed to return additional flags that will be passed to the program on every invocation.

simpleProgram :: String -> Program

Make a simple named program.

By default we'll just search for it in the path and not try to find the version name. You can override these behaviours if necessary, eg:

     simpleProgram "foo" { programFindLocation = ... , programFindVersion ... }

Configured program and related functions
data ConfiguredProgram

Constructors

ConfiguredProgram |

programId :: String | Just the name again
programVersion :: Maybe Version | The version of this program, if it is known.
programArgs :: [String] | Default command-line args for this program. These flags will appear first on the command line, so they can be overridden by subsequent flags.
programLocation :: ProgramLocation | Location of the program. eg. `/usr/bin/ghc-6.4`

Instances

Eq ConfiguredProgram
Read ConfiguredProgram
Show ConfiguredProgram

programPath :: ConfiguredProgram -> FilePath
The full path of a configured program.
type ProgArg = String
data ProgramLocation

Where a program was found. Also tells us whether it's specifed by user or not. This includes not just the path, but the program as well.
Constructors

UserSpecified | The user gave the path to this program, eg. --ghc-path=/usr/bin/ghc-6.6

locationPath :: FilePath |

FoundOnSystem | The location of the program, as located by searching PATH.

locationPath :: FilePath |

Instances

Eq ProgramLocation
Read ProgramLocation
Show ProgramLocation

Produced by Haddock version 2.6.1