Safe Haskell | None |
---|
Generic representation of typed syntax trees
For details, see: A Generic Abstract Syntax Model for Embedded Languages (ICFP 2012, http://www.cse.chalmers.se/~emax/documents/axelsson2012generic.pdf).
- data AST dom sig where
- type ASTF dom a = AST dom (Full a)
- newtype Full a = Full {
- result :: a
- newtype a :-> sig = Partial (a -> sig)
- size :: AST dom sig -> Int
- class ApplySym sig f dom | sig dom -> f, f -> sig dom where
- type family DenResult sig
- data (dom1 :+: dom2) a where
- class Project sub sup where
- class Project sub sup => sub :<: sup where
- inj :: sub a -> sup a
- appSym :: (ApplySym sig f dom, sym :<: AST dom) => sym sig -> f
- symType :: P sym -> sym sig -> sym sig
- prjP :: Project sub sup => P sub -> sup sig -> Maybe (sub sig)
Syntax trees
Generic abstract syntax tree, parameterized by a symbol domain
(
represents a partially applied (or unapplied)
symbol, missing at least one argument, while AST
dom (a :->
b))(
represents a fully applied symbol, i.e. a complete syntax tree.
AST
dom (Full
a))
:<: sub sup => sub :<: (AST sup) | |
Project sub sup => Project sub (AST sup) | |
InjectC sub sup a => InjectC sub (AST sup) a | |
Functor dom => Functor (AST dom) | |
Equality dom => Equality (AST dom) | |
Eval dom => Eval (AST dom) | |
Constrained dom => Constrained (AST dom) | |
ApplySym (Full a) (ASTF dom a) dom | |
Equality dom => Eq (AST dom a) | |
Render dom => Show (ASTF dom a) | |
Syntactic (ASTF dom a) | |
(Syntactic a, ~ (* -> *) (Domain a) dom, ~ * ia (Internal a), SyntacticN b ib) => SyntacticN (a -> b) (AST dom (Full ia) -> ib) | |
ApplySym sig f dom => ApplySym (:-> a sig) (ASTF dom a -> f) dom |
Signature of a fully applied symbol
Functor Full | |
Typeable1 Full | |
Eq a => Eq (Full a) | |
Show a => Show (Full a) | |
ApplySym (Full a) (ASTF dom a) dom | |
Render dom => Show (ASTF dom a) | |
Syntactic (ASTF dom a) | |
(Syntactic a, ~ (* -> *) (Domain a) dom, ~ * ia (Internal a), SyntacticN b ib) => SyntacticN (a -> b) (AST dom (Full ia) -> ib) | |
ApplySym sig f dom => ApplySym (:-> a sig) (ASTF dom a -> f) dom |
Signature of a partially applied (or unapplied) symbol
Partial (a -> sig) |
class ApplySym sig f dom | sig dom -> f, f -> sig dom whereSource
Class for the type-level recursion needed by appSym
Symbol domains
data (dom1 :+: dom2) a whereSource
Direct sum of two symbol domains
:<: expr1 expr3 => expr1 :<: (:+: expr2 expr3) | |
expr1 :<: (:+: expr1 expr2) | |
Project expr1 expr3 => Project expr1 (:+: expr2 expr3) | |
Project expr1 (:+: expr1 expr2) | |
InjectC expr1 expr3 a => InjectC expr1 (:+: expr2 expr3) a | |
InjectC expr1 (:+: expr1 expr2) a | |
(Functor dom1, Functor dom2) => Functor (:+: dom1 dom2) | |
(Equality expr1, Equality expr2) => Equality (:+: expr1 expr2) | |
(StringTree dom1, StringTree dom2) => StringTree (:+: dom1 dom2) | |
(Render expr1, Render expr2) => Render (:+: expr1 expr2) | |
(Eval expr1, Eval expr2) => Eval (:+: expr1 expr2) | |
Constrained (:+: sub1 sub2) | |
(EvalBind sub1, EvalBind sub2) => EvalBind (:+: sub1 sub2) | |
(Optimize sub1, Optimize sub2) => Optimize (:+: sub1 sub2) | |
TupleSat dom2 p => TupleSat (:+: dom1 dom2) p | |
TupleSat (:+: (:|| Tuple p) dom2) p | |
TupleSat (:+: (:|| Select p) dom2) p | |
(AlphaEq subA1 subB1 dom env, AlphaEq subA2 subB2 dom env) => AlphaEq (:+: subA1 subA2) (:+: subB1 subB2) dom env | |
(Equality expr1, Equality expr2) => Eq (:+: expr1 expr2 a) | |
IsHODomain (HODomain dom p pVar) p pVar |
class Project sub sup whereSource
Symbol projection
Project expr expr | |
Project sub sup => Project sub (AST sup) | |
Project expr1 expr3 => Project expr1 (:+: expr2 expr3) | |
Project expr1 (:+: expr1 expr2) | |
Project sub sup => Project sub (:|| sup pred) | |
Project sub sup => Project sub (:| sup pred) | |
Project sub sup => Project sub (Decor info sup) | |
Project sub sup => Project sub (SubConstr1 c sup p) | |
Project sub sup => Project sub (SubConstr2 c sup pa pb) |
appSym :: (ApplySym sig f dom, sym :<: AST dom) => sym sig -> fSource
Generic symbol application
appSym
has any type of the form:
appSym :: (expr :<: AST dom) => expr (a :-> b :-> ... :-> Full x) -> (ASTF dom a -> ASTF dom b -> ... -> ASTF dom x)