syntactic-3.2: Generic representation and manipulation of abstract syntax

Safe HaskellNone
LanguageHaskell2010

Language.Syntactic.Interpretation

Contents

Description

Equality and rendering of ASTs

Synopsis

Equality

class Equality e where Source

Higher-kinded equality

Minimal complete definition

Nothing

Methods

equal :: e a -> e b -> Bool Source

Higher-kinded equality

Comparing elements of different types is often needed when dealing with expressions with existentially quantified sub-terms.

hash :: e a -> Hash Source

Higher-kinded hashing. Elements that are equal according to equal must result in the same hash:

equal a b  ==>  hash a == hash b

Instances

Equality Empty Source 
Equality Let Source 
Equality BindingT Source

equal does strict identifier comparison; i.e. no alpha equivalence.

hash assigns the same hash to all variables and binders. This is a valid over-approximation that enables the following property:

alphaEq a b ==> hash a == hash b
Equality Binding Source

equal does strict identifier comparison; i.e. no alpha equivalence.

hash assigns the same hash to all variables and binders. This is a valid over-approximation that enables the following property:

alphaEq a b ==> hash a == hash b
Equality Construct Source 
Equality Literal Source 
Equality Tuple Source 
Equality sym => Equality (Typed sym) Source 
Equality sym => Equality (AST sym) Source 
Equality (MONAD m) Source 
(Equality sym1, Equality sym2) => Equality ((:+:) sym1 sym2) Source 
Equality expr => Equality ((:&:) expr info) Source 

Rendering

class Render sym where Source

Render a symbol as concrete syntax. A complete instance must define at least the renderSym method.

Minimal complete definition

renderSym

Methods

renderSym :: sym sig -> String Source

Show a symbol as a String

renderArgs :: [String] -> sym sig -> String Source

Render a symbol given a list of rendered arguments

renderArgsSmart :: Render sym => [String] -> sym a -> String Source

Implementation of renderArgs that handles infix operators

render :: forall sym a. Render sym => ASTF sym a -> String Source

Render an AST as concrete syntax

class Render sym => StringTree sym where Source

Convert a symbol to a Tree of strings

Minimal complete definition

Nothing

Methods

stringTreeSym :: [Tree String] -> sym a -> Tree String Source

Convert a symbol to a Tree given a list of argument trees

stringTree :: forall sym a. StringTree sym => ASTF sym a -> Tree String Source

Convert an AST to a Tree of strings

showAST :: StringTree sym => ASTF sym a -> String Source

Show a syntax tree using ASCII art

drawAST :: StringTree sym => ASTF sym a -> IO () Source

Print a syntax tree using ASCII art

writeHtmlAST :: StringTree sym => FilePath -> ASTF sym a -> IO () Source

Write a syntax tree to an HTML file with foldable nodes

Default interpretation

equalDefault :: Render sym => sym a -> sym b -> Bool Source

Default implementation of equal

hashDefault :: Render sym => sym a -> Hash Source

Default implementation of hash