syntactic-3.2.1: Generic representation and manipulation of abstract syntax

Safe HaskellNone
LanguageHaskell2010

Language.Syntactic.TH

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], ")"]