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

Safe HaskellNone



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.



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.


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

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.

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

Like rule, but lower priority, if no rule exists then defaultRule is checked. All default rules must be disjoint.

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

Add a rule to build a key, returning an appropriate Action. All rules must be disjoint. To define lower priority rules use defaultRule.

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 or defaultRule. 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.