HORIZON HASKELLDocslts/ghc-10.0.xaa25b892026-10-10Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · aa25b89 · 2026-10-10

ModuleCabal-3.18.1.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.18.1.0
  • Exports43
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceRule.hs

Rules

0 declarations

Rule

datadata RuleData (scope :: Scope)
#

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

Instances10Eq, Show, Generic, Binary, Structured, Rep, …
datadata RuleId
#

A unique identifier for a Rule.

Constructors

Instances7Eq, Ord, Show, Generic, Binary, Structured, …
valuedynamicRule
  1. :: (Typeable depsArg, Typeable depsRes, Typeable arg)
  2. => StaticPtr (Dict (Binary depsRes, Show depsRes, Eq depsRes))

    evidence that the result of the dynamic dependency command is serialisable

  3. -> Command depsArg (IO ([Dependency], depsRes))

    dynamic dependency computation, returning dynamic dependencies and an additional piece of data to be consumed by the main rule command

  4. -> Command arg (depsRes -> IO ())

    main rule command; takes in the piece of data returned by the dyn-deps command

  5. -> [Dependency]

    static dependencies of the rule

  6. -> NonEmpty Location

    rule results

  7. -> Rule
#

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.

Prefer using this smart constructor instead of Rule whenever possible.

Use staticRule if you do not have any dynamic dependencies.

Commands

datadata RuleCommands (scope :: Scope) (deps :: Scope -> Type -> Type -> Type) (ruleCmd :: Scope -> Type -> Type -> Type) where
#

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.

Prefer using staticRule and dynamicRule instead of the (internal) constructors of RuleCommands.

Constructors

Instances6Eq, Show, Binary, Structured
typetype Command = CommandData 'User
#

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.

datadata CommandData (scope :: Scope) arg res
#

Internal datatype used for commands, both for the Hooks API (Command) and for the build system.

Constructors

Instances5Eq, Show, Binary
datadata Dict (c :: Constraint) where
#

A wrapper used to pass evidence of a constraint as an explicit value.

Constructors

Helpers for executing commands

newtypenewtype DynDepsCmd (scope :: Scope) depsArg depsRes
#

A dynamic dependency command.

Constructors

Instances5Eq, Show, Binary
newtypenewtype DepsRes (scope :: Scope) (depsArg :: k) depsRes
#

The result of a dynamic dependency computation.

Constructors

Instances4Eq, Ord, Show, Binary
  • Eq depsRes => Eq (DepsRes scope depsArg depsRes)Defined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
  • Ord depsRes => Ord (DepsRes scope depsArg depsRes)Defined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
  • Show depsRes => Show (DepsRes scope depsArg depsRes)Defined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
  • Binary (ScopedArgument scope depsRes) => Binary (DepsRes scope depsArg depsRes)Defined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
valueruleDepsCmd :: RuleCmds scope -> RuleDynDepsCmd scope
#

Project out the (optional) dependency computation command, so that it can be serialised without serialising anything else.

Collections of rules

newtypenewtype Rules env
#

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.

Constructors

Instances2Semigroup, Monoid
  • Semigroup (Rules env)Defined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule

    Warning: this Semigroup instance is not commutative.

  • Monoid (Rules env)Defined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
datadata Dependency
#

A dependency of a rule.

Constructors

Instances7Eq, Ord, Show, Generic, Binary, Structured, …
datadata RuleOutput
#

A reference to an output of another rule.

Constructors

Instances7Eq, Ord, Show, Generic, Binary, Structured, …
valuerules
  1. :: StaticPtr label

    unique label for this collection of rules

  2. -> (env -> RulesM ())

    the computation of rules

  3. -> 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

datadata Location where
#

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 (moduleNameSymbolicPath mod . "hs"), where:

  • for a file dependency, dir is one of the Cabal search directories,

  • for an output, dir is a directory such as autogenComponentModulesDir or componentBuildDir.

Constructors

Instances5Eq, Ord, Show, Binary, Structured
  • Eq LocationDefined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
  • Ord LocationDefined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
  • Show LocationDefined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
  • Binary LocationDefined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule
  • Structured LocationDefined in Cabal-3.18.1.0 · Distribution.Simple.SetupHooks.Rule

File/directory monitoring

datadata MonitorFilePath
#

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
datadata MonitorKindFile
#
Instances6Eq, Show, Generic, Binary, Structured, Rep
datadata MonitorKindDir
#
Instances6Eq, Show, Generic, Binary, Structured, Rep

Monadic API for generation of ActionId

newtypenewtype RulesT (m :: Type -> Type) a
#

Monad transformer for defining rules. Usually wraps the IO monad, allowing IO actions to be performed using liftIO.

Instances6MonadTrans, Monad, Functor, MonadFix, Applicative, MonadIO

Internals

9 declarations
datadata Scope
#

Rules are defined with rich types by the package.

The build system only has a limited view of these; most data consists of opaque ByteStrings.

The Scope data-type describes which side of this divide we are on.

Constructors

  • User

    User space (with rich types).

  • System

    Build-system space (manipulation of raw data).

data familydata family Static (scope :: Scope) :: Type -> Type
#

A static pointer (in user scope) or its key (in system scope).

Instances10Eq, Ord, Show, Binary, Static, …