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))
(Project sub (AST sup), :<: sub sup) => sub :<: (AST sup) | |
Project sub sup => Project sub (AST sup) | |
(Project sub (AST sup), Sat (AST sup) a, InjectC sub sup a) => InjectC sub (AST sup) a | |
Equality dom => Equality (AST dom) | |
(Render (AST dom), ToTree dom) => ToTree (AST dom) | |
Render dom => Render (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 (AST dom a) | |
Syntactic (ASTF dom a) dom | |
(Syntactic 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
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
(Project expr1 (:+: expr2 expr3), :<: expr1 expr3) => expr1 :<: (:+: expr2 expr3) | |
Project expr1 (:+: expr1 expr2) => expr1 :<: (:+: expr1 expr2) | |
Project expr1 expr3 => Project expr1 (:+: expr2 expr3) | |
Project expr1 (:+: expr1 expr2) | |
(Project expr1 (:+: expr2 expr3), Sat (:+: expr2 expr3) a, InjectC expr1 expr3 a) => InjectC expr1 (:+: expr2 expr3) a | |
(Project expr1 (:+: expr1 expr2), Sat (:+: expr1 expr2) a) => InjectC expr1 (:+: expr1 expr2) a | |
(Equality expr1, Equality expr2) => Equality (:+: expr1 expr2) | |
(Render (:+: expr1 expr2), ToTree expr1, ToTree expr2) => ToTree (:+: expr1 expr2) | |
(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 (:+: (:|| Select p) dom2) p | |
TupleSat (:+: (:|| Tuple p) dom2) p | |
(AlphaEq subA1 subB1 dom env, AlphaEq subA2 subB2 dom env) => AlphaEq (:+: subA1 subA2) (:+: subB1 subB2) dom env | |
(Syntactic a (HODomain dom p pVar), Syntactic b (HODomain dom p pVar), p (Internal a -> Internal b), p (Internal a), pVar (Internal a)) => Syntactic (a -> b) (HODomain dom p pVar) | |
(Equality expr1, Equality expr2) => Eq (:+: expr1 expr2 a) | |
(Render expr1, Render expr2) => Show (:+: expr1 expr2 a) | |
(Syntactic a (HODomain dom Typeable pVar), InjectC (MONAD m) dom (m (Internal a)), Monad m, Typeable1 m, Typeable (Internal a), pVar (Internal a)) => Syntactic (Mon dom pVar m a) (HODomain dom Typeable 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)