shake-0.14.2: Build system library, like Make, but more accurate dependencies.

Safe HaskellNone

Development.Shake.Rule

Contents

Description

This module is used for defining new types of rules for Shake build systems. Most users will find the built-in set of rules sufficient.

Synopsis

Documentation

type ShakeValue a = (Show a, Typeable a, Eq a, Hashable a, Binary a, NFData a)Source

Define an alias for the six type classes required for things involved in Shake Rules. This alias is only available in GHC 7.4 and above, and requires the ConstraintKinds extension.

To define your own values meeting the necessary constraints it is convenient to use the extensions GeneralizedNewtypeDeriving and DeriveDataTypeable to write:

 newtype MyType = MyType (String, Bool) deriving (Show,Typeable,Eq,Hashable,Binary,NFData)

class (ShakeValue key, ShakeValue value) => Rule key value whereSource

Define a pair of types that can be used by Shake rules. To import all the type classes required see Development.Shake.Classes.

Methods

storedValue :: ShakeOptions -> key -> IO (Maybe value)Source

[Required] Retrieve the value associated with a key, if available.

As an example for filenames/timestamps, if the file exists you should return Just the timestamp, but otherwise return Nothing. For rules whose values are not stored externally, storedValue should return Nothing.

equalValue :: ShakeOptions -> key -> value -> value -> EqualCostSource

[Optional] Equality check, with a notion of how expensive the check was.

data EqualCost Source

An equality check and a cost.

Constructors

EqualCheap

The equality check was cheap.

EqualExpensive

The equality check was expensive, as the results are not trivially equal.

NotEqual

The values are not equal.

rule :: Rule key value => (key -> Maybe (Action value)) -> Rules ()Source

Add a rule to build a key, returning an appropriate Action. All rules at a given priority must be disjoint. Rules have priority 1 by default, but can be modified with priority.

apply :: Rule key value => [key] -> Action [value]Source

Execute a rule, returning the associated values. If possible, the rules will be run in parallel. This function requires that appropriate rules have been added with rule. All key values passed to apply become dependencies of the Action.

apply1 :: Rule key value => key -> Action valueSource

Apply a single rule, equivalent to calling apply with a singleton list. Where possible, use apply to allow parallelism.

trackUse :: ShakeValue key => key -> Action ()Source

Track that a key has been used by the action preceeding it.

trackChange :: ShakeValue key => key -> Action ()Source

Track that a key has been changed by the action preceeding it.

trackAllow :: ShakeValue key => (key -> Bool) -> Action ()Source

Allow any matching key to violate the tracking rules.

Deprecated

defaultRule :: Rule key value => (key -> Maybe (Action value)) -> Rules ()Source

Deprecated: Use rule with priority 0

A deprecated way of defining a low priority rule. Defined as:

 defaultRule = priority 0 . rule