| Safe Haskell | Safe-Inferred |
|---|
Development.Shake.Classes
Description
This module reexports the six necessary type classes that every Rule type must support.
You can use this module to define new rules without depending on the binary, deepseq and hashable packages.
Synopsis
Documentation
class Show a where
Conversion of values to readable String s.
Minimal complete definition: showsPrec or show .
Derived instances of Show have the following properties, which
are compatible with derived instances of Read :
- The result of
showis a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrecwill produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
xis less thand(associativity is ignored). Thus, ifdis0then the result is never surrounded in parentheses; ifdis11it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
showwill produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show is equivalent to
instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Note that right-associativity of :^: is ignored. For example,
-
produces the stringshow(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)".
Methods
Arguments
the operator precedence of the enclosing
context (a number from 0 to 11).
Function application has precedence 10.
the value to be converted to a String
Convert a value to a readable String .
showsPrec should satisfy the law
showsPrec d x r ++ s == showsPrec d x (r ++ s)
Derived instances of Read and Show satisfy the following:
That is, readsPrec parses the string produced by
showsPrec , and delivers the value that showsPrec started with.
Instances
class Typeable a where
The class Typeable allows a concrete representation of a type to
be calculated.
Methods
class Eq a where
The Eq class defines equality (== ) and inequality (/= ).
All the basic datatypes exported by the Prelude are instances of Eq ,
and Eq may be derived for any datatype whose constituents are also
instances of Eq .
Instances
class Hashable a where
class Binary t where
Instances
class NFData a where
A class of types that can be fully evaluated.
Methods
rnf :: a -> ()
rnf should reduce its argument to normal form (that is, fully evaluate all sub-components), and then return '()'.
The default implementation of rnf is
rnf a = a `seq` ()
which may be convenient when defining instances for data types with no unevaluated fields (e.g. enumerations).
Instances
This instance is for convenience and consistency with seq .
This assumes that WHNF is equivalent to NF for functions.