Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | sjoerd@w3future.com |
Safe Haskell | None |
- deriveInstance :: Q Type -> Q [Dec]
- deriveSignature :: Name -> Q [Dec]
- data SignatureTH = SignatureTH {
- signatureName :: Name
- typeVarName :: Name
- operations :: [OperationTH]
- data OperationTH = OperationTH {
- functionName :: Name
- operationName :: Name
- arguments :: [Type]
- getSignatureInfo :: Name -> Q SignatureTH
- buildSignatureDataType :: SignatureTH -> [Dec]
- signatureInstance :: Name -> SignatureTH -> [Dec]
Documentation
deriveInstance :: Q Type -> Q [Dec]Source
Derive an instance for an algebraic class. For example:
deriveInstance [t| (Num m, Num n) => Num (m, n) |]
To be able to derive an instance for a
of class c
, we need an instance of
,
where Algebra
f af
is the signature of c
.
deriveInstance
will generate a signature for the class if there is no signature in scope.
deriveSignature :: Name -> Q [Dec]Source
Derive a signature for an algebraic class. For exaple:
deriveSignature ''Num
deriveSignature
creates the signature data type and an instance for it of the
AlgebraSignature
class. DeriveFunctor
is used the generate the Functor
instance of the signature.
This will do nothing if there is already a signature for the class in scope.
Possibly useful internals
data SignatureTH Source
SignatureTH | |
|
data OperationTH Source
OperationTH | |
|
signatureInstance :: Name -> SignatureTH -> [Dec]Source