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

Safe HaskellNone

Language.Syntactic.Constructs.Decoration

Contents

Description

Construct for decorating expressions with additional information

Synopsis

Decoration

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

to

 AST (Decor info dom) sig

Constructors

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

Fields

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

Instances

Project sub sup => Project sub (Decor info sup) 
Equality expr => Equality (Decor info expr) 
StringTree expr => StringTree (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

stringTreeDecor :: forall info dom a. StringTree dom => (forall a. info a -> String) -> ASTF (Decor info dom) a -> Tree StringSource

Rendering of decorated syntax trees

showDecorWith :: StringTree dom => (forall a. info a -> String) -> ASTF (Decor info dom) a -> StringSource

Show an decorated syntax tree using ASCII art

drawDecorWith :: StringTree dom => (forall a. info a -> String) -> 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