syntactic-2.1: Generic representation and manipulation of abstract syntax

Safe HaskellNone
LanguageHaskell2010

Data.Syntactic.Decoration

Description

Construct for decorating symbols or expressions with additional information

Synopsis

Documentation

data (expr :&: info) sig where Source

Decorating symbols or expressions with additional information

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

AST sym sig

to

AST (sym :&: info) sig

Constructors

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

Fields

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

Instances

Project sub sup => Project sub ((:&:) sup info) 
Symbol sym => Symbol ((:&:) sym info) 
StringTree expr => StringTree ((:&:) expr info) 
Render expr => Render ((:&:) expr info) 
Equality expr => Equality ((:&:) expr info) 
Eval sym => Eval ((:&:) sym info) 
BindingDomain sym => BindingDomain ((:&:) sym i) 
EvalEnv sym env => EvalEnv ((:&:) sym info) env 

mapDecor :: (sym1 sig -> sym2 sig) -> (info1 (DenResult sig) -> info2 (DenResult sig)) -> (sym1 :&: info1) sig -> (sym2 :&: info2) sig Source

Map over a decoration

getDecor :: AST (sym :&: info) sig -> info (DenResult sig) Source

Get the decoration of the top-level node

updateDecor :: forall info sym a. (info a -> info a) -> ASTF (sym :&: info) a -> ASTF (sym :&: info) a Source

Update the decoration of the top-level node

liftDecor :: (expr s -> info (DenResult s) -> b) -> (expr :&: info) s -> b Source

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

stripDecor :: AST (sym :&: info) sig -> AST sym sig Source

Strip decorations from an AST

stringTreeDecor :: forall info sym a. StringTree sym => (forall a. info a -> String) -> ASTF (sym :&: info) a -> Tree String Source

Rendering of decorated syntax trees

showDecorWith :: StringTree sym => (forall a. info a -> String) -> ASTF (sym :&: info) a -> String Source

Show an decorated syntax tree using ASCII art

drawDecorWith :: StringTree sym => (forall a. info a -> String) -> ASTF (sym :&: info) a -> IO () Source

Print an decorated syntax tree using ASCII art