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

Safe HaskellNone




Construct for decorating expressions with additional information



data Decor info expr sig whereSource

Decorating symbols with additional information

One usage of Decor is to decorate every node of a syntax tree. This is done simply by changing

 AST dom sig


 AST (Decor info dom) sig


Decor :: info (DenResult sig) -> expr sig -> Decor info expr sig 


decorInfo :: info (DenResult sig)
decorExpr :: expr sig


Project sub sup => Project sub (Decor info sup) 
Equality expr => Equality (Decor info expr) 
(Render (Decor info expr), ToTree expr) => ToTree (Decor info expr) 
Render expr => Render (Decor info expr) 
Eval expr => Eval (Decor info expr) 
Constrained expr => Constrained (Decor info expr) 
EvalBind dom => EvalBind (Decor info dom) 
AlphaEq sub sub dom env => AlphaEq (Decor info sub) (Decor info sub) dom env 

getInfo :: AST (Decor info dom) sig -> info (DenResult sig)Source

Get the decoration of the top-level node

updateDecor :: forall info dom a. (info a -> info a) -> ASTF (Decor info dom) a -> ASTF (Decor info dom) aSource

Update the decoration of the top-level node

liftDecor :: (expr s -> info (DenResult s) -> b) -> Decor info expr s -> bSource

Lift a function that operates on expressions with associated information to operate on an Decor expression. This function is convenient to use together with e.g. queryNodeSimple when the domain has the form (Decor info dom).

collectInfo :: (forall sig. info sig -> b) -> AST (Decor info dom) sig -> [b]Source

Collect the decorations of all nodes

toTreeDecor :: forall info dom a. (Render info, ToTree dom) => ASTF (Decor info dom) a -> Tree StringSource

Rendering of decorated syntax trees

showDecor :: (Render info, ToTree dom) => ASTF (Decor info dom) a -> StringSource

Show an decorated syntax tree using ASCII art

drawDecor :: (Render info, ToTree dom) => ASTF (Decor info dom) a -> IO ()Source

Print an decorated syntax tree using ASCII art

stripDecor :: AST (Decor info dom) sig -> AST dom sigSource

Strip decorations from an AST