Cabal-3.10.3.0: A framework for packaging Haskell software
CopyrightIsaac Jones 2006 Duncan Coutts 2007-2009
Maintainercabal-devel@haskell.org
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Distribution.Simple.Program.Types

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

Program and functions for constructing them

data Program Source #

Represents a program which can be configured.

Note: rather than constructing this directly, start with simpleProgram and override any extra fields.

Constructors

Program 

Fields

Instances

Instances details
Show Program Source # 
Instance details

Defined in Distribution.Simple.Program.Types

type ProgramSearchPath = [ProgramSearchPathEntry] Source #

A search path to use when locating executables. This is analogous to the unix $PATH or win32 %PATH% but with the ability to use the system default method for finding executables (findExecutable which on unix is simply looking on the $PATH but on win32 is a bit more complicated).

The default to use is [ProgSearchPathDefault] but you can add extra dirs either before, after or instead of the default, e.g. here we add an extra dir to search after the usual ones.

['ProgramSearchPathDefault', 'ProgramSearchPathDir' dir]

We also use this path to set the environment when running child processes.

The ProgramDb is created with a ProgramSearchPath to which we appendProgramSearchPath to add the ones that come from cli flags and from configurations. Then each of the programs that are configured in the db inherits the same path as part of configureProgram.

data ProgramSearchPathEntry Source #

Constructors

ProgramSearchPathDir FilePath

A specific dir

ProgramSearchPathDefault

The system default

Instances

Instances details
Structured ProgramSearchPathEntry Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Generic ProgramSearchPathEntry Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Associated Types

type Rep ProgramSearchPathEntry :: Type -> Type Source #

Binary ProgramSearchPathEntry Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Eq ProgramSearchPathEntry Source # 
Instance details

Defined in Distribution.Simple.Program.Types

type Rep ProgramSearchPathEntry Source # 
Instance details

Defined in Distribution.Simple.Program.Types

type Rep ProgramSearchPathEntry = D1 ('MetaData "ProgramSearchPathEntry" "Distribution.Simple.Program.Types" "Cabal-3.10.3.0" 'False) (C1 ('MetaCons "ProgramSearchPathDir" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "ProgramSearchPathDefault" 'PrefixI 'False) (U1 :: Type -> Type))

Configured program and related functions

data ConfiguredProgram Source #

Represents a program which has been configured and is thus ready to be run.

These are usually made by configuring a Program, but if you have to construct one directly then start with simpleConfiguredProgram and override any extra fields.

Constructors

ConfiguredProgram 

Fields

  • programId :: String

    Just the name again

  • programVersion :: Maybe Version

    The version of this program, if it is known.

  • programDefaultArgs :: [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.

  • programOverrideArgs :: [String]

    Override command-line args for this program. These flags will appear last on the command line, so they override all earlier flags.

  • programOverrideEnv :: [(String, Maybe String)]

    Override environment variables for this program. These env vars will extend/override the prevailing environment of the current to form the environment for the new process.

  • programProperties :: Map String String

    A key-value map listing various properties of the program, useful for feature detection. Populated during the configuration step, key names depend on the specific program.

  • programLocation :: ProgramLocation

    Location of the program. eg. /usr/bin/ghc-6.4

  • programMonitorFiles :: [FilePath]

    In addition to the programLocation where the program was found, these are additional locations that were looked at. The combination of ths found location and these not-found locations can be used to monitor to detect when the re-configuring the program might give a different result (e.g. found in a different location).

Instances

Instances details
Structured ConfiguredProgram Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Generic ConfiguredProgram Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Associated Types

type Rep ConfiguredProgram :: Type -> Type Source #

Read ConfiguredProgram Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Show ConfiguredProgram Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Binary ConfiguredProgram Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Eq ConfiguredProgram Source # 
Instance details

Defined in Distribution.Simple.Program.Types

type Rep ConfiguredProgram Source # 
Instance details

Defined in Distribution.Simple.Program.Types

type Rep ConfiguredProgram = D1 ('MetaData "ConfiguredProgram" "Distribution.Simple.Program.Types" "Cabal-3.10.3.0" 'False) (C1 ('MetaCons "ConfiguredProgram" 'PrefixI 'True) (((S1 ('MetaSel ('Just "programId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "programVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Version))) :*: (S1 ('MetaSel ('Just "programDefaultArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [String]) :*: S1 ('MetaSel ('Just "programOverrideArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [String]))) :*: ((S1 ('MetaSel ('Just "programOverrideEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(String, Maybe String)]) :*: S1 ('MetaSel ('Just "programProperties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map String String))) :*: (S1 ('MetaSel ('Just "programLocation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ProgramLocation) :*: S1 ('MetaSel ('Just "programMonitorFiles") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [FilePath])))))

programPath :: ConfiguredProgram -> FilePath Source #

The full path of a configured program.

suppressOverrideArgs :: ConfiguredProgram -> ConfiguredProgram Source #

Suppress any extra arguments added by the user.

data ProgramLocation Source #

Where a program was found. Also tells us whether it's specified 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

FoundOnSystem

The program was found automatically.

Instances

Instances details
Structured ProgramLocation Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Generic ProgramLocation Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Associated Types

type Rep ProgramLocation :: Type -> Type Source #

Read ProgramLocation Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Show ProgramLocation Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Binary ProgramLocation Source # 
Instance details

Defined in Distribution.Simple.Program.Types

Methods

put :: ProgramLocation -> Put #

get :: Get ProgramLocation #

putList :: [ProgramLocation] -> Put #

Eq ProgramLocation Source # 
Instance details

Defined in Distribution.Simple.Program.Types

type Rep ProgramLocation Source # 
Instance details

Defined in Distribution.Simple.Program.Types

type Rep ProgramLocation = D1 ('MetaData "ProgramLocation" "Distribution.Simple.Program.Types" "Cabal-3.10.3.0" 'False) (C1 ('MetaCons "UserSpecified" 'PrefixI 'True) (S1 ('MetaSel ('Just "locationPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "FoundOnSystem" 'PrefixI 'True) (S1 ('MetaSel ('Just "locationPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)))

simpleConfiguredProgram :: String -> ProgramLocation -> ConfiguredProgram Source #

Make a simple ConfiguredProgram.

simpleConfiguredProgram "foo" (FoundOnSystem path)