This module defines the concept of expressions and expression transformers.
An expression is a type constructor of kind
* -> * -> *
where the first argument denotes the "role" of the expression, and the second argument is the type of the value computed by the expression.
An expression transformer is a type constructor of kind
(* -> * -> *) -> (* -> * -> *)
i.e. a expression parameterized by an expression.
- data Empty role a
- class ExprEq expr where
- class Eval expr where
- eval :: expr role a -> a
- class ExprShow expr where
- printExpr :: ExprShow expr => expr role a -> IO ()
- exprCast :: forall expr ra a rb b. (Typeable ra, Typeable a, Typeable rb, Typeable b) => expr ra a -> Maybe (expr rb b)
Expression type with no constructors. Can be used to turn an expression transformer to an expression.
Equality for expressions. The difference between
ExprEq is that
ExprEq allows comparison of expressions with different role and value type.
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.
Evaluation of expressions