| Safe Haskell | None |
|---|
Data.Syntactic.Syntax
Description
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 sym sig where
- type ASTF sym a = AST sym (Full a)
- newtype Full a = Full {
- result :: a
- newtype a :-> sig = Partial (a -> sig)
- size :: AST sym sig -> Int
- type family DenResult sig
- data SigRep sig where
- class Signature sig where
- type family SmartFun sym sig
- type family SmartSig f
- type family SmartSym f :: * -> *
- smartSym' :: forall sig f sym. (Signature sig, f ~ SmartFun sym sig, sig ~ SmartSig f, sym ~ SmartSym f) => sym sig -> f
- data (sym1 :+: sym2) a where
- class Project sub sup where
- class Project sub sup => sub :<: sup where
- inj :: sub a -> sup a
- smartSym :: (Signature sig, f ~ SmartFun sup sig, sig ~ SmartSig f, sup ~ SmartSym f, sub :<: sup) => sub sig -> f
- data Empty
- data E e where
- liftE :: (forall a. e a -> b) -> E e -> b
- liftE2 :: (forall a b. e a -> e b -> c) -> E e -> E e -> c
- data EF e where
- liftEF :: (forall a. e (Full a) -> b) -> EF e -> b
- liftEF2 :: (forall a b. e (Full a) -> e (Full b) -> c) -> EF e -> EF e -> c
- symType :: Proxy sym -> sym sig -> sym sig
- prjP :: Project sub sup => Proxy 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 sym (a :-> b))(
represents a fully applied symbol, i.e. a complete syntax tree.
AST sym (Full a))
Constructors
| Sym :: sym sig -> AST sym sig | |
| :$ :: AST sym (a :-> sig) -> AST sym (Full a) -> AST sym sig |
Instances
| :<: sub sup => sub :<: (AST sup) | |
| Project sub sup => Project sub (AST sup) | |
| Functor sym => Functor (AST sym) | |
| Equality sym => Equality (AST sym) | |
| BindingDomain sym => BindingDomain (AST sym) | |
| Equality sym => Eq (AST sym a) | |
| Render sym => Show (ASTF sym a) | |
| Syntactic (ASTF sym a) | |
| (Syntactic a, ~ (* -> *) (Domain a) sym, ~ * ia (Internal a), SyntacticN f fi) => SyntacticN (a -> f) (AST sym (Full ia) -> fi) |
Signature of a fully applied symbol
Signature of a partially applied (or unapplied) symbol
Constructors
| Partial (a -> sig) |
Witness of the arity of a symbol signature
type family SmartFun sym sig Source
Maps a symbol signature to the type of the corresponding smart constructor:
SmartFun sym (a :-> b :-> ... :-> Full x) = ASTF sym a -> ASTF sym b -> ... -> ASTF sym x
Maps a smart constructor type to the corresponding symbol signature:
SmartSig (ASTF sym a -> ASTF sym b -> ... -> ASTF sym x) = a :-> b :-> ... :-> Full x
smartSym' :: forall sig f sym. (Signature sig, f ~ SmartFun sym sig, sig ~ SmartSig f, sym ~ SmartSym f) => sym sig -> fSource
Make a smart constructor of a symbol. smartSym has any type of the form:
smartSym
:: sym (a :-> b :-> ... :-> Full x)
-> (ASTF sym a -> ASTF sym b -> ... -> ASTF sym x)
Open symbol domains
data (sym1 :+: sym2) a whereSource
Direct sum of two symbol domains
Instances
| :<: sym1 sym3 => sym1 :<: (:+: sym2 sym3) | |
| sym1 :<: (:+: sym1 sym2) | |
| Project sym1 sym3 => Project sym1 (:+: sym2 sym3) | |
| Project sym1 (:+: sym1 sym2) | |
| (Functor sym1, Functor sym2) => Functor (:+: sym1 sym2) | |
| (Foldable sym1, Foldable sym2) => Foldable (:+: sym1 sym2) | |
| (Traversable sym1, Traversable sym2) => Traversable (:+: sym1 sym2) | |
| (StringTree sym1, StringTree sym2) => StringTree (:+: sym1 sym2) | |
| (Render sym1, Render sym2) => Render (:+: sym1 sym2) | |
| (Equality sym1, Equality sym2) => Equality (:+: sym1 sym2) | |
| (Eval s, Eval t) => Eval (:+: s t) | |
| (BindingDomain sym1, BindingDomain sym2) => BindingDomain (:+: sym1 sym2) | |
| (EvalEnv sym1 env, EvalEnv sym2 env) => EvalEnv (:+: sym1 sym2) env | |
| (Equality sym1, Equality sym2) => Eq (:+: sym1 sym2 a) |
smartSym :: (Signature sig, f ~ SmartFun sup sig, sig ~ SmartSig f, sup ~ SmartSym f, sub :<: sup) => sub sig -> fSource
Make a smart constructor of a symbol. smartSym has any type of the form:
smartSym :: (sub :<: AST sup)
=> sub (a :-> b :-> ... :-> Full x)
-> (ASTF sup a -> ASTF sup b -> ... -> ASTF sup x)
Empty symbol type
Can be used to make uninhabited AST types. It can also be used as a terminator in co-product
lists (e.g. to avoid overlapping instances):
(A :+: B :+: Empty)
Existential quantification
Existential quantification of Full-indexed type