simple-reflect-0.3.2: Simple reflection of expressions containing variables

Portabilityportable
Stabilityexperimental
Maintainertwanvl@gmail.com
Safe HaskellSafe-Inferred

Debug.SimpleReflect.Expr

Contents

Description

Simple reflection of haskell expressions containing variables.

Synopsis

Construction

class FromExpr a whereSource

Conversion from Expr to other types

Methods

fromExpr :: Expr -> aSource

Instances

FromExpr Expr 
(Show a, FromExpr b) => FromExpr (a -> b) 

var :: String -> ExprSource

A variable with the given name

fun :: FromExpr a => String -> aSource

A generic, overloaded, function variable

data Associativity Source

This data type specifies the associativity of operators: left, right or none.

Constructors

InfixL 
Infix 
InfixR 

Instances

op :: Associativity -> Int -> String -> Expr -> Expr -> ExprSource

An infix operator with the given associativity, precedence and name

Evaluating

expr :: Expr -> ExprSource

Force something to be an expression.

reduce :: Expr -> ExprSource

Reduce (evaluate) an expression once.

For example reduce (1 + 2 + 3 + 4) == 3 + 3 + 4

reduction :: Expr -> [Expr]Source

Show all reduction steps when evaluating an expression.