| Safe Haskell | None |
|---|
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
- type ShakeValue a = (Show a, Typeable a, Eq a, Hashable a, Binary a, NFData a)
- class (ShakeValue key, ShakeValue value) => Rule key value where
- storedValue :: ShakeOptions -> key -> IO (Maybe value)
- equalValue :: ShakeOptions -> key -> value -> value -> EqualCost
- data EqualCost
- = EqualCheap
- | EqualExpensive
- | NotEqual
- rule :: Rule key value => (key -> Maybe (Action value)) -> Rules ()
- apply :: Rule key value => [key] -> Action [value]
- apply1 :: Rule key value => key -> Action value
- trackUse :: ShakeValue key => key -> Action ()
- trackChange :: ShakeValue key => key -> Action ()
- trackAllow :: ShakeValue key => (key -> Bool) -> Action ()
- defaultRule :: Rule key value => (key -> Maybe (Action value)) -> Rules ()
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 Rule s.
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 -> EqualCost Source
[Optional] Equality check, with a notion of how expensive the check was.
An equality check and a cost.
Constructors
The equality check was cheap.
The equality check was expensive, as the results are not trivially equal.
The values are not equal.
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.