Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Internal module that defines fine-grained rules for setup hooks.
Users should import SetupHooks
instead.
Synopsis
- type Rule = RuleData User
- data RuleData (scope :: Scope) = Rule {
- ruleCommands :: !(RuleCmds scope)
- staticDependencies :: ![Dependency]
- results :: !(NonEmpty Location)
- data RuleId = RuleId {
- ruleNameSpace :: !RulesNameSpace
- ruleName :: !ShortText
- staticRule :: forall arg. Typeable arg => Command arg (IO ()) -> [Dependency] -> NonEmpty Location -> Rule
- dynamicRule :: forall depsArg depsRes arg. (Typeable depsArg, Typeable depsRes, Typeable arg) => StaticPtr (Dict (Binary depsRes, Show depsRes, Eq depsRes)) -> Command depsArg (IO ([Dependency], depsRes)) -> Command arg (depsRes -> IO ()) -> [Dependency] -> NonEmpty Location -> Rule
- data RuleCommands (scope :: Scope) (deps :: Scope -> Type -> Type -> Type) (ruleCmd :: Scope -> Type -> Type -> Type) where
- StaticRuleCommand :: forall arg deps ruleCmd scope. If (scope == System) (arg ~ ByteString) (() :: Constraint) => {..} -> RuleCommands scope deps ruleCmd
- DynamicRuleCommands :: forall depsArg depsRes arg deps ruleCmd scope. If (scope == System) (depsArg ~ ByteString, depsRes ~ ByteString, arg ~ ByteString) (() :: Constraint) => {..} -> RuleCommands scope deps ruleCmd
- type Command = CommandData User
- data CommandData (scope :: Scope) (arg :: Type) (res :: Type) = Command {}
- runCommand :: Command args res -> res
- mkCommand :: forall arg res. StaticPtr (Dict (Binary arg, Show arg)) -> StaticPtr (arg -> res) -> arg -> Command arg res
- data Dict c where
- type RuleCmds scope = RuleCommands scope DynDepsCmd CommandData
- type RuleDynDepsCmd scope = RuleCommands scope DynDepsCmd NoCmd
- type RuleExecCmd scope = RuleCommands scope DepsRes CommandData
- newtype DynDepsCmd scope depsArg depsRes = DynDepsCmd {
- dynDepsCmd :: CommandData scope depsArg (IO ([Dependency], depsRes))
- newtype DepsRes (scope :: Scope) depsArg depsRes = DepsRes {
- depsRes :: ScopedArgument scope depsRes
- ruleDepsCmd :: RuleCmds scope -> RuleDynDepsCmd scope
- runRuleDynDepsCmd :: RuleDynDepsCmd User -> Maybe (IO ([Dependency], ByteString))
- ruleExecCmd :: SScope scope -> RuleCmds scope -> Maybe ByteString -> RuleExecCmd scope
- runRuleExecCmd :: RuleExecCmd User -> IO ()
- newtype Rules env = Rules {}
- data Dependency
- data RuleOutput = RuleOutput {
- outputOfRule :: !RuleId
- outputIndex :: !Word
- rules :: StaticPtr label -> (env -> RulesM ()) -> Rules env
- noRules :: RulesM ()
- data Location where
- location :: Location -> SymbolicPath Pkg File
- data MonitorFilePath
- data MonitorKindFile
- data MonitorKindDir
- type RulesM a = RulesT IO a
- newtype RulesT m a = RulesT {}
- data RulesEnv = RulesEnv {
- rulesEnvVerbosity :: !Verbosity
- rulesEnvNameSpace :: !RulesNameSpace
- computeRules :: Verbosity -> env -> Rules env -> IO (Map RuleId Rule, [MonitorFilePath])
- data Scope
- data SScope (scope :: Scope) where
- data family Static (scope :: Scope) :: Type -> Type
- type RuleBinary = RuleData System
- ruleBinary :: Rule -> RuleBinary
Rules
Rule
data RuleData (scope :: Scope) Source #
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.
Rule | Please use the |
|
Instances
A unique identifier for a Rule
.
RuleId | |
|
Instances
Structured RuleId Source # | |
Defined in Distribution.Simple.SetupHooks.Rule structure :: Proxy RuleId -> Structure structureHash' :: Tagged RuleId MD5 | |
Generic RuleId Source # | |
Show RuleId Source # | |
Binary RuleId Source # | |
Eq RuleId Source # | |
Ord RuleId Source # | |
type Rep RuleId Source # | |
Defined in Distribution.Simple.SetupHooks.Rule |
staticRule :: forall arg. Typeable arg => Command arg (IO ()) -> [Dependency] -> NonEmpty Location -> Rule Source #
A rule with static dependencies.
Prefer using this smart constructor instead of Rule
whenever possible.
dynamicRule :: forall depsArg depsRes arg. (Typeable depsArg, Typeable depsRes, Typeable arg) => StaticPtr (Dict (Binary depsRes, Show depsRes, Eq depsRes)) -> Command depsArg (IO ([Dependency], depsRes)) -> Command arg (depsRes -> IO ()) -> [Dependency] -> NonEmpty Location -> Rule Source #
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) where Source #
Commands 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.
StaticRuleCommand | A rule with statically-known dependencies. |
| |
DynamicRuleCommands | |
|
Instances
(forall arg res. Show (ruleCmd 'User arg res), forall depsArg depsRes. Show depsRes => Show (deps 'User depsArg depsRes)) => Show (RuleCommands 'User deps ruleCmd) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule | |
(forall res. Binary (ruleCmd 'System ByteString res), Binary (deps 'System ByteString ByteString)) => Binary (RuleCommands 'System deps ruleCmd) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule put :: RuleCommands 'System deps ruleCmd -> Put # get :: Get (RuleCommands 'System deps ruleCmd) # putList :: [RuleCommands 'System deps ruleCmd] -> Put # | |
(forall arg res. Binary (ruleCmd 'User arg res), forall depsArg depsRes. Binary depsRes => Binary (deps 'User depsArg depsRes)) => Binary (RuleCommands 'User deps ruleCmd) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule put :: RuleCommands 'User deps ruleCmd -> Put # get :: Get (RuleCommands 'User deps ruleCmd) # putList :: [RuleCommands 'User deps ruleCmd] -> Put # | |
(forall res. Eq (ruleCmd 'System ByteString res), Eq (deps 'System ByteString ByteString)) => Eq (RuleCommands 'System deps ruleCmd) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule (==) :: RuleCommands 'System deps ruleCmd -> RuleCommands 'System deps ruleCmd -> Bool # (/=) :: RuleCommands 'System deps ruleCmd -> RuleCommands 'System deps ruleCmd -> Bool # | |
(forall arg res. Eq (ruleCmd 'User arg res), forall depsArg depsRes. Eq depsRes => Eq (deps 'User depsArg depsRes)) => Eq (RuleCommands 'User deps ruleCmd) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule (==) :: RuleCommands 'User deps ruleCmd -> RuleCommands 'User deps ruleCmd -> Bool # (/=) :: RuleCommands 'User deps ruleCmd -> RuleCommands 'User deps ruleCmd -> Bool # |
type Command = CommandData User Source #
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.
data CommandData (scope :: Scope) (arg :: Type) (res :: Type) Source #
Internal datatype used for commands, both for the Hooks API (Command
)
and for the build system.
Command | |
|
Instances
runCommand :: Command args res -> res Source #
Run a Command
.
mkCommand :: forall arg res. StaticPtr (Dict (Binary arg, Show arg)) -> StaticPtr (arg -> res) -> arg -> Command arg res Source #
Construct a command.
Prefer using this smart constructor instead of Command
whenever possible.
A wrapper used to pass evidence of a constraint as an explicit value.
Helpers for executing commands
type RuleCmds scope = RuleCommands scope DynDepsCmd CommandData Source #
Both the rule command and the (optional) dynamic dependency command.
type RuleDynDepsCmd scope = RuleCommands scope DynDepsCmd NoCmd Source #
Only the (optional) dynamic dependency command.
type RuleExecCmd scope = RuleCommands scope DepsRes CommandData Source #
The rule command together with the result of the (optional) dynamic dependency computation.
newtype DynDepsCmd scope depsArg depsRes Source #
A dynamic dependency command.
DynDepsCmd | |
|
Instances
newtype DepsRes (scope :: Scope) depsArg depsRes Source #
The result of a dynamic dependency computation.
Instances
Show depsRes => Show (DepsRes scope depsArg depsRes) Source # | |
Binary (ScopedArgument scope depsRes) => Binary (DepsRes scope depsArg depsRes) Source # | |
Eq depsRes => Eq (DepsRes scope depsArg depsRes) Source # | |
Ord depsRes => Ord (DepsRes scope depsArg depsRes) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule compare :: DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes -> Ordering # (<) :: DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes -> Bool # (<=) :: DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes -> Bool # (>) :: DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes -> Bool # (>=) :: DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes -> Bool # max :: DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes # min :: DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes -> DepsRes scope depsArg depsRes # |
ruleDepsCmd :: RuleCmds scope -> RuleDynDepsCmd scope Source #
Project out the (optional) dependency computation command, so that it can be serialised without serialising anything else.
runRuleDynDepsCmd :: RuleDynDepsCmd User -> Maybe (IO ([Dependency], ByteString)) Source #
Obtain the (optional) IO
action that computes dynamic dependencies.
ruleExecCmd :: SScope scope -> RuleCmds scope -> Maybe ByteString -> RuleExecCmd scope Source #
Project out the command for running the rule, passing in the result of the dependency computation if there was one.
runRuleExecCmd :: RuleExecCmd User -> IO () Source #
Obtain the IO
action that executes a rule.
Collections of rules
A collection of Rule
s.
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
.
data Dependency Source #
A dependency of a rule.
RuleDependency !RuleOutput | A dependency on an output of another rule. |
FileDependency !Location | A 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 |
Instances
data RuleOutput Source #
A reference to an output of another rule.
RuleOutput | |
|
Instances
:: StaticPtr label | unique label for this collection of rules |
-> (env -> RulesM ()) | the computation of rules |
-> Rules env |
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 here
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
,
where:Location
dir (moduleNameSymbolicPath
mod . "hs")
- for a file dependency,
dir
is one of the Cabal search directories, - for an output,
dir
is a directory such asautogenComponentModulesDir
orcomponentBuildDir
.
Location | |
|
Instances
location :: Location -> SymbolicPath Pkg File Source #
Get a (relative or absolute) un-interpreted path to a Location
.
File/directory monitoring
data MonitorFilePath Source #
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.
Instances
data MonitorKindFile Source #
Instances
data MonitorKindDir Source #
Instances
Monadic API for generation of ActionId
Monad transformer for defining rules. Usually wraps the IO
monad,
allowing IO
actions to be performed using liftIO
.
Instances
MonadTrans RulesT Source # | |
Defined in Distribution.Simple.SetupHooks.Rule | |
MonadFix m => MonadFix (RulesT m) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule | |
MonadIO m => MonadIO (RulesT m) Source # | |
Defined in Distribution.Simple.SetupHooks.Rule | |
Monad m => Applicative (RulesT m) Source # | |
Functor m => Functor (RulesT m) Source # | |
Monad m => Monad (RulesT m) Source # | |
The environment within the monadic API.
RulesEnv | |
|
computeRules :: Verbosity -> env -> Rules env -> IO (Map RuleId Rule, [MonitorFilePath]) Source #
Internals
data family Static (scope :: Scope) :: Type -> Type Source #
A static pointer (in user scope) or its key (in system scope).
Instances
type RuleBinary = RuleData System Source #
ruleBinary :: Rule -> RuleBinary Source #