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

Safe HaskellNone

Language.Syntactic.Interpretation.Equality

Synopsis

Documentation

class ExprEq expr whereSource

Equality for expressions. The difference between Eq and ExprEq is that ExprEq allows comparison of expressions with different value types. It is assumed that when the types differ, the expressions also differ. The reason for allowing comparison of different types is that this is convenient when the types are existentially quantified.

Methods

exprEq :: expr a -> expr b -> BoolSource

exprHash :: expr a -> HashSource

Computes a Hash for an expression. Expressions that are equal according to exprEq must result in the same hash:

exprEq a b  ==>  exprHash a == exprHash b

Instances

ExprEq Semantics 
ExprEq dom => ExprEq (AST dom) 
ExprEq (Condition ctx) 
ExprEq (Construct ctx) 
ExprEq (Identity ctx) 
ExprEq (Literal ctx) 
Monad m => ExprEq (MONAD m) 
ExprEq (Select ctx) 
ExprEq (Tuple ctx) 
ExprEq (Lambda ctx)

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

exprHash assigns the same hash to all Lambda bindings. This is a valid over-approximation that enables the following property:

alphaEq a b  ==>  exprHash a == exprHash b
ExprEq (Variable ctx)

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

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

alphaEq a b  ==>  exprHash a == exprHash b
(ExprEq expr1, ExprEq expr2) => ExprEq (:+: expr1 expr2) 
ExprEq expr => ExprEq (Decor info expr) 
ExprEq (Let ctxa ctxb)