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

Copyright(c) 2008-2014 Twan van Laarhoven
LicenseBSD-style
Maintainertwanvl@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

Debug.SimpleReflect.Expr

Contents

Description

Simple reflection of haskell expressions containing variables.

Synopsis

Construction

class FromExpr a where Source

Conversion from Expr to other types

Methods

fromExpr :: Expr -> a Source

Instances

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

var :: String -> Expr Source

A variable with the given name

fun :: FromExpr a => String -> a Source

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 -> Expr Source

An infix operator with the given associativity, precedence and name

Evaluating

expr :: Expr -> Expr Source

Force something to be an expression.

reduce :: Expr -> Expr Source

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.