syntactic-3.8.1: Generic representation and manipulation of abstract syntax

Safe HaskellNone
LanguageHaskell2010

Language.Syntactic.TH

Contents

Synopsis

Documentation

conName :: Con -> (Name, Int) Source #

Get the name and arity of a constructor

data Method Source #

Description of class methods

Constructors

DefaultMethod Name Name

rhs = lhs

MatchingMethod Name (Con -> Int -> Name -> Int -> Clause) [Clause]
MatchingMethod methodName mkClause extraClauses

mkClause takes as arguments (1) a description of the constructor, (2) the constructor's index, (3) the constructor's name, and (4) its arity.

deriveClass Source #

Arguments

:: Cxt

Instance context

-> Name

Type constructor name

-> Type

Class head (e.g. Render Con)

-> [Method]

Methods

-> DecsQ 

General method for class deriving

deriveClassSimple Source #

Arguments

:: Name

Class name

-> Name

Type constructor name

-> [Method]

Methods

-> DecsQ 

General method for class deriving

deriveSymbol Source #

Arguments

:: Name

Type name

-> DecsQ 

Derive Symbol instance for a type

deriveEquality Source #

Arguments

:: Name

Type name

-> DecsQ 

Derive Equality instance for a type

equal Con1 Con1 = True
equal (Con2 a1 ... x1) (Con2 a2 ... x2) = and [a1==a2, ... x1==x2]
equal _ _ = False
hash Con1           = hashInt 0
hash (Con2 a ... x) = foldr1 combine [hashInt 1, hash a, ... hash x]

deriveRender Source #

Arguments

:: (String -> String)

Constructor name modifier

-> Name

Type name

-> DecsQ 

Derive Render instance for a type

renderSym Con1           = "Con1"
renderSym (Con2 a ... x) = concat ["(", unwords ["Con2", show a, ... show x], ")"]

Portability

instD Source #

Arguments

:: Cxt

Context

-> Type

Instance

-> [Dec]

Methods, etc.

-> Dec 

Construct an instance declaration

viewDataDef :: Info -> Maybe [Con] Source #

Get the constructors of a data type definition

eqPred :: Type -> Type -> Pred Source #

Portable method for constructing a Pred of the form (t1 ~ t2)

classPred Source #

Arguments

:: Name

Class name

-> (Name -> Type)

How to make a type for the class (typically ConT or VarT)

-> [Type]

Class arguments

-> Pred 

Portable method for constructing a Pred of the form SomeClass t1 t2 ...

tySynInst :: Name -> [Type] -> Type -> Dec Source #

Portable method for constructing a type synonym instances