syntactic-0.5: Generic abstract syntax, and utilities for embedded languages



Annotations for syntax trees



data Ann info expr a whereSource

Annotating an expression with arbitrary information.

This can be used to annotate every node of a syntax tree, which is done by changing

 AST dom a


 AST (Ann info dom) a

Injection/projection of an annotated tree is done using injectAnn / projectAnn.


Ann :: info (EvalResult a) -> expr a -> Ann info expr a 


annInfo :: info (EvalResult a)
annExpr :: expr a


ExprEq expr => ExprEq (Ann info expr) 
ToTree expr => ToTree (Ann info expr) 
Render expr => Render (Ann info expr) 
Eval expr => Eval (Ann info expr) 

type AnnSTF info dom a = ASTF (Ann info dom) aSource

injectAnn :: (sub :<: sup, ConsType a) => info (EvalResult a) -> sub a -> AST (Ann info sup) aSource

projectAnn :: sub :<: sup => AST (Ann info sup) a -> Maybe (info (EvalResult a), sub a)Source

getInfo :: AST (Ann info dom) a -> info (EvalResult a)Source

Get the annotation of the top-level node

collectInfo :: (forall a. info a -> b) -> AST (Ann info dom) a -> [b]Source

Collect the annotations of all nodes