algebraic-classes-0: Conversions between algebraic classes and F-algebras.

Portabilitynon-portable
Stabilityexperimental
Maintainersjoerd@w3future.com
Safe HaskellNone

Data.Algebra.TH

Contents

Description

 

Synopsis

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 Algebra f a, where f 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