ModuleCabal-3.16.0.0Haskell2010
Distribution.Simple.SetupHooks.Rule
Internal module that defines fine-grained rules for setup hooks.
Users should import Distribution.Simple.SetupHooks instead.
- 25 types
- 15 values
- PackageCabal-3.16.0.0
- Exports43
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceRule.hs
Rules
0 declarationsRule
A rule consists of:
an action to run to execute the rule,
a description of the rule inputs and outputs.
Use staticRule or dynamicRule to construct a rule, overriding specific fields, rather than directly using the Rule constructor.
Constructors
RulePlease use the staticRule or dynamicRule smart constructors instead of this constructor, in order to avoid relying on internal implementation details.
ruleCommands :: !RuleCmds scopeTo run this rule, which Commands should we execute?
staticDependencies :: ![Dependency]Static dependencies of this rule.
results :: !NonEmpty LocationResults of this rule.
Instances8Eq, Show, Generic, Binary, Rep, …
Show RuleBinaryDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleTrimmed down Show instance, mostly for error messages.
Eq (RuleData 'System)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleEq (RuleData 'User)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow (RuleData 'User)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleGeneric (RuleData scope)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary (RuleData 'System)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary (RuleData 'User)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Ruletype Rep (RuleData scope) = D1 ('MetaDataDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule"RuleData"
"Distribution.Simple.SetupHooks.Rule"
"Cabal-3.16.0.0-2669"
'False) (C1 ('MetaCons"Rule"
'PrefixI 'True) (S1 ('MetaSel ('Just"ruleCommands"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (RuleCmds scope)) :*: (S1 ('MetaSel ('Just"staticDependencies"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Dependency]) :*: S1 ('MetaSel ('Just"results"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty Location)))))
A unique identifier for a Rule.
Constructors
RuleIdruleNameSpace :: !RulesNameSpaceruleName :: !ShortText
Instances7Eq, Ord, Show, Generic, Binary, Structured, …
Eq RuleIdDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleOrd RuleIdDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow RuleIdDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleGeneric RuleIdDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary RuleIdDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleStructured RuleIdDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Ruletype Rep RuleId = D1 ('MetaDataDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule"RuleId"
"Distribution.Simple.SetupHooks.Rule"
"Cabal-3.16.0.0-2669"
'False) (C1 ('MetaCons"RuleId"
'PrefixI 'True) (S1 ('MetaSel ('Just"ruleNameSpace"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RulesNameSpace) :*: S1 ('MetaSel ('Just"ruleName"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 ShortText)))
A rule with static dependencies.
Prefer using this smart constructor instead of Rule whenever possible.
A rule with dynamic dependencies.
Prefer using this smart constructor instead of Rule whenever possible.
Commands
data RuleCommands (scope :: Scope) (deps :: Scope -> Type -> Type -> Type) (ruleCmd :: Scope -> Type -> Type -> Type) whereCommands to execute a rule:
for a rule with static dependencies, a single command,
for a rule with dynamic dependencies, a command for computing dynamic dependencies, and a command for executing the rule.
Constructors
StaticRuleCommand :: If (scope == 'System) (arg ~ ByteString) () => !ruleCmd scope arg (IO ()) -> !If (scope == 'System) SomeTypeRep (TypeRep arg) -> RuleCommands scope deps ruleCmdA rule with statically-known dependencies.
staticRuleCommand :: !ruleCmd scope arg (IO ())The command to execute the rule.
staticRuleArgRep :: !If (scope == 'System) SomeTypeRep (TypeRep arg)A TypeRep for
arg.
DynamicRuleCommands :: If (scope == 'System) (depsArg ~ ByteString, depsRes ~ ByteString, arg ~ ByteString) () => !Static scope (Dict (Binary depsRes, Show depsRes, Eq depsRes)) -> !deps scope depsArg depsRes -> !ruleCmd scope arg (depsRes -> IO ()) -> !If (scope == 'System) SomeTypeRep (TypeRep (depsArg, depsRes, arg)) -> RuleCommands scope deps ruleCmddynamicRuleInstances :: !Static scope (Dict (Binary depsRes, Show depsRes, Eq depsRes))A rule with dynamic dependencies, which consists of two parts:
a dynamic dependency computation, that returns additional edges to be added to the build graph together with an additional piece of data,
the command to execute the rule itself, which receives the additional piece of data returned by the dependency computation.
dynamicDeps :: !deps scope depsArg depsResA dynamic dependency computation. The resulting dependencies will be injected into the build graph, and the result of the computation will be passed on to the command that executes the rule.
dynamicRuleCommand :: !ruleCmd scope arg (depsRes -> IO ())The command to execute the rule. It will receive the result of the dynamic dependency computation.
dynamicRuleTypeRep :: !If (scope == 'System) SomeTypeRep (TypeRep (depsArg, depsRes, arg))A TypeRep for the triple
(depsArg,depsRes,arg).
Instances5Eq, Show, Binary
(forall arg res. Eq (ruleCmd 'User arg res), forall depsArg depsRes. Eq depsRes => Eq (deps 'User depsArg depsRes)) => Eq (RuleCommands 'User deps ruleCmd)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule(forall res. Eq (ruleCmd 'System ByteString res), Eq (deps 'System ByteString ByteString)) => Eq (RuleCommands 'System deps ruleCmd)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule(forall arg res. Show (ruleCmd 'User arg res), forall depsArg depsRes. Show depsRes => Show (deps 'User depsArg depsRes)) => Show (RuleCommands 'User deps ruleCmd)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule(forall arg res. Binary (ruleCmd 'User arg res), forall depsArg depsRes. Binary depsRes => Binary (deps 'User depsArg depsRes)) => Binary (RuleCommands 'User deps ruleCmd)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule(forall res. Binary (ruleCmd 'System ByteString res), Binary (deps 'System ByteString ByteString)) => Binary (RuleCommands 'System deps ruleCmd)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule
A command consists of a statically-known action together with a (possibly dynamic) argument to that action.
For example, the action can consist of running an executable
(such as happy or c2hs), while the argument consists of the variable
component of the command, e.g. the specific file to run happy on.
Internal datatype used for commands, both for the Hooks API (Command) and for the build system.
Constructors
CommandactionPtr :: !Static scope (arg -> res)The (statically-known) action to execute.
actionArg :: !ScopedArgument scope argThe (possibly dynamic) argument to pass to the action.
cmdInstances :: !Static scope (Dict (Binary arg, Show arg))Static evidence that the argument can be serialised and deserialised.
Instances5Eq, Show, Binary
Eq (CommandData 'User arg res)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rulearg ~ ByteString => Eq (CommandData 'System arg res)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow (CommandData 'User arg res)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary (CommandData 'User arg res)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rulearg ~ ByteString => Binary (CommandData 'System arg res)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule
Run a Command.
Construct a command.
Prefer using this smart constructor instead of Command whenever possible.
Helpers for executing commands
Both the rule command and the (optional) dynamic dependency command.
Only the (optional) dynamic dependency command.
The rule command together with the result of the (optional) dynamic dependency computation.
A dynamic dependency command.
Constructors
DynDepsCmddynDepsCmd :: CommandData scope depsArg (IO ([Dependency], depsRes))
Instances5Eq, Show, Binary
Eq (DynDepsCmd 'User depsArg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule(arg ~ ByteString, depsRes ~ ByteString) => Eq (DynDepsCmd 'System arg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow (DynDepsCmd 'User depsArg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary (DynDepsCmd 'User depsArg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule(arg ~ ByteString, depsRes ~ ByteString) => Binary (DynDepsCmd 'System arg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule
The result of a dynamic dependency computation.
Instances4Eq, Ord, Show, Binary
Eq depsRes => Eq (DepsRes scope depsArg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleOrd depsRes => Ord (DepsRes scope depsArg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow depsRes => Show (DepsRes scope depsArg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary (ScopedArgument scope depsRes) => Binary (DepsRes scope depsArg depsRes)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule
Project out the (optional) dependency computation command, so that it can be serialised without serialising anything else.
Obtain the (optional) IO action that computes dynamic dependencies.
Project out the command for running the rule, passing in the result of the dependency computation if there was one.
Obtain the IO action that executes a rule.
Collections of rules
A collection of Rules.
Use the rules smart constructor instead of directly using the Rules constructor.
Rules are registered using
registerRule,Monitored files or directories are declared using
addRuleMonitors; a change in these will trigger the recomputation of all rules.
The env type parameter represents an extra argument, which usually
consists of information known to Cabal such as LocalBuildInfo and
ComponentLocalBuildInfo.
A dependency of a rule.
Constructors
RuleDependency !RuleOutputA dependency on an output of another rule.
FileDependency !LocationA direct dependency on a file at a particular location on disk.
This should not be used for files that are generated by other rules; use RuleDependency instead.
Instances7Eq, Ord, Show, Generic, Binary, Structured, …
Eq DependencyDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleOrd DependencyDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow DependencyDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleGeneric DependencyDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary DependencyDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleStructured DependencyDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Ruletype Rep Dependency = D1 ('MetaDataDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule"Dependency"
"Distribution.Simple.SetupHooks.Rule"
"Cabal-3.16.0.0-2669"
'False) (C1 ('MetaCons"RuleDependency"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RuleOutput)) :+: C1 ('MetaCons"FileDependency"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Location)))
A reference to an output of another rule.
Constructors
RuleOutputoutputOfRule :: !RuleIdwhich rule's outputs are we referring to?
outputIndex :: !Wordwhich particular output of that rule?
Instances7Eq, Ord, Show, Generic, Binary, Structured, …
Eq RuleOutputDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleOrd RuleOutputDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow RuleOutputDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleGeneric RuleOutputDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary RuleOutputDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleStructured RuleOutputDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Ruletype Rep RuleOutput = D1 ('MetaDataDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule"RuleOutput"
"Distribution.Simple.SetupHooks.Rule"
"Cabal-3.16.0.0-2669"
'False) (C1 ('MetaCons"RuleOutput"
'PrefixI 'True) (S1 ('MetaSel ('Just"outputOfRule"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RuleId) :*: S1 ('MetaSel ('Just"outputIndex"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Word)))
rules Construct a collection of rules with a given label.
A label for the rules can be constructed using the static keyword,
using the StaticPointers extension.
NB: separate calls to rules should have different labels.
Example usage:
myRules :: Rules env
myRules = rules (static ()) $ \ env -> do { .. } -- use the monadic API hereAn empty collection of rules.
Rule inputs/outputs
A (fully resolved) location of a dependency or result of a rule, consisting of a base directory and of a file path relative to that base directory path.
In practice, this will be something like Location dir (,
where:moduleNameSymbolicPath mod . "hs")
for a file dependency,
diris one of the Cabal search directories,for an output,
diris a directory such asautogenComponentModulesDirorcomponentBuildDir.
Constructors
Location :: !SymbolicPath Pkg ('Dir baseDir) -> !RelativePath baseDir 'File -> LocationlocationBaseDir :: !SymbolicPath Pkg ('Dir baseDir)Base directory.
locationRelPath :: !RelativePath baseDir 'FileFile path relative to base directory (including file extension).
Instances5Eq, Ord, Show, Binary, Structured
Eq LocationDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleOrd LocationDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow LocationDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary LocationDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleStructured LocationDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule
Get a (relative or absolute) un-interpreted path to a Location.
File/directory monitoring
A description of a file (or set of files) to monitor for changes.
Where file paths are relative they are relative to a common directory (e.g. project root), not necessarily the process current directory.
Instances6Eq, Show, Generic, Binary, Structured, Rep
Eq MonitorFilePathDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesShow MonitorFilePathDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesGeneric MonitorFilePathDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesBinary MonitorFilePathDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesStructured MonitorFilePathDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.Typestype Rep MonitorFilePath = D1 ('MetaDataDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.Types"MonitorFilePath"
"Distribution.Simple.FileMonitor.Types"
"Cabal-3.16.0.0-2669"
'False) (C1 ('MetaCons"MonitorFile"
'PrefixI 'True) (S1 ('MetaSel ('Just"monitorKindFile"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MonitorKindFile) :*: (S1 ('MetaSel ('Just"monitorKindDir"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MonitorKindDir) :*: S1 ('MetaSel ('Just"monitorPath"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FilePath))) :+: C1 ('MetaCons"MonitorFileGlob"
'PrefixI 'True) (S1 ('MetaSel ('Just"monitorKindFile"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MonitorKindFile) :*: (S1 ('MetaSel ('Just"monitorKindDir"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MonitorKindDir) :*: S1 ('MetaSel ('Just"monitorPathGlob"
) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RootedGlob))))
Instances6Eq, Show, Generic, Binary, Structured, Rep
Eq MonitorKindFileDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesShow MonitorKindFileDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesGeneric MonitorKindFileDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesBinary MonitorKindFileDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesStructured MonitorKindFileDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.Typestype Rep MonitorKindFile = D1 ('MetaDataDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.Types"MonitorKindFile"
"Distribution.Simple.FileMonitor.Types"
"Cabal-3.16.0.0-2669"
'False) ((C1 ('MetaCons"FileExists"
'PrefixI 'False) U1 :+: C1 ('MetaCons"FileModTime"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"FileHashed"
'PrefixI 'False) U1 :+: C1 ('MetaCons"FileNotExists"
'PrefixI 'False) U1))
Instances6Eq, Show, Generic, Binary, Structured, Rep
Eq MonitorKindDirDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesShow MonitorKindDirDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesGeneric MonitorKindDirDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesBinary MonitorKindDirDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.TypesStructured MonitorKindDirDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.Typestype Rep MonitorKindDir = D1 ('MetaDataDefined in Cabal-3.16.0.0 · Distribution.Simple.FileMonitor.Types"MonitorKindDir"
"Distribution.Simple.FileMonitor.Types"
"Cabal-3.16.0.0-2669"
'False) (C1 ('MetaCons"DirExists"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"DirModTime"
'PrefixI 'False) U1 :+: C1 ('MetaCons"DirNotExists"
'PrefixI 'False) U1))
Monadic API for generation of ActionId
Monad for constructing rules.
Monad transformer for defining rules. Usually wraps the IO monad,
allowing IO actions to be performed using liftIO.
Instances6MonadTrans, Monad, Functor, MonadFix, Applicative, MonadIO
MonadTrans RulesTDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleMonad m => Monad (RulesT m)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleFunctor m => Functor (RulesT m)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleMonadFix m => MonadFix (RulesT m)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleMonad m => Applicative (RulesT m)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleMonadIO m => MonadIO (RulesT m)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Rule
The environment within the monadic API.
Constructors
RulesEnvrulesEnvVerbosity :: !VerbosityrulesEnvNameSpace :: !RulesNameSpace
Internals
9 declarationsA static pointer (in user scope) or its key (in system scope).
Instances10Eq, Ord, Show, Binary, Static, …
Eq (Static 'System fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleEq (Static 'User fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleOrd (Static 'System fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleOrd (Static 'User fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow (Static 'System fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleShow (Static 'User fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary (Static 'System fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.RuleBinary (Static 'User fnTy)Defined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Ruledata Static 'SystemDefined in Cabal-3.16.0.0 · Distribution.Simple.SetupHooks.Ruledata Static 'UserUserStaticuserStaticPtr :: StaticPtr fnTy
Fields
Fields
userStaticPtr :: StaticPtr fnTy