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

Portabilityportable
Stabilityexperimental
Maintainertwanvl@gmail.com
Safe HaskellSafe-Infered

Debug.SimpleReflect.Expr

Contents

Description

Simple reflection of haskell expressions containing variables.

Synopsis

Construction

class FromExpr a where

Conversion from Expr to other types

Methods

fromExpr :: Expr -> a

Instances

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

var :: String -> Expr

A variable with the given name

fun :: FromExpr a => String -> a

A generic, overloaded, function variable

data Associativity

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

Constructors

InfixL 
Infix 
InfixR 

Instances

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

An infix operator with the given associativity, precedence and name

Evaluating

expr :: Expr -> Expr

Force something to be an expression.

reduce :: Expr -> Expr

Reduce (evaluate) an expression once.

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

reduction :: Expr -> [Expr]

Show all reduction steps when evaluating an expression.