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

Copyright | (c) 2008-2014 Twan van Laarhoven
License | BSD-style
Maintainer | twanvl@gmail.com
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell98

Debug.SimpleReflect.Expr

Contents

- Construction
- Evaluating

Description

Simple reflection of haskell expressions containing variables.

Synopsis

- data Expr
- class FromExpr a where
  - fromExpr :: Expr -> a
- var :: String -> Expr
- fun :: FromExpr a => String -> a
- data Associativity
  - = InfixL
  - | Infix
  - | InfixR
- op :: Associativity -> Int -> String -> Expr -> Expr -> Expr
- expr :: Expr -> Expr
- reduce :: Expr -> Expr
- reduction :: Expr -> [Expr]

# Construction

data Expr Source #

A reflected expression

#### Instances

Instances details

Monoid Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods mempty :: Expr Source # mappend :: Expr -> Expr -> Expr Source # mconcat :: [Expr] -> Expr Source #
Semigroup Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods (<>) :: Expr -> Expr -> Expr Source # sconcat :: NonEmpty Expr -> Expr Source # stimes :: Integral b => b -> Expr -> Expr Source #
Bounded Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods minBound :: Expr Source # maxBound :: Expr Source #
Enum Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods succ :: Expr -> Expr Source # pred :: Expr -> Expr Source # toEnum :: Int -> Expr Source # fromEnum :: Expr -> Int Source # enumFrom :: Expr -> [Expr] Source # enumFromThen :: Expr -> Expr -> [Expr] Source # enumFromTo :: Expr -> Expr -> [Expr] Source # enumFromThenTo :: Expr -> Expr -> Expr -> [Expr] Source #
Floating Expr Source # |

Instance details

Defined in Debug.SimpleReflect.Expr

Methods

pi :: Expr Source #

exp :: Expr -> Expr Source #

log :: Expr -> Expr Source #

sqrt :: Expr -> Expr Source #

(**) :: Expr -> Expr -> Expr Source #

logBase :: Expr -> Expr -> Expr Source #

sin :: Expr -> Expr Source #

cos :: Expr -> Expr Source #

tan :: Expr -> Expr Source #

asin :: Expr -> Expr Source #

acos :: Expr -> Expr Source #

atan :: Expr -> Expr Source #

sinh :: Expr -> Expr Source #

cosh :: Expr -> Expr Source #

tanh :: Expr -> Expr Source #

asinh :: Expr -> Expr Source #

acosh :: Expr -> Expr Source #

atanh :: Expr -> Expr Source #

log1p :: Expr -> Expr Source #

expm1 :: Expr -> Expr Source #

log1pexp :: Expr -> Expr Source #

log1mexp :: Expr -> Expr Source #

Num Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods (+) :: Expr -> Expr -> Expr Source # (-) :: Expr -> Expr -> Expr Source # (*) :: Expr -> Expr -> Expr Source # negate :: Expr -> Expr Source # abs :: Expr -> Expr Source # signum :: Expr -> Expr Source # fromInteger :: Integer -> Expr Source #
Fractional Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods (/) :: Expr -> Expr -> Expr Source # recip :: Expr -> Expr Source # fromRational :: Rational -> Expr Source #
Integral Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods quot :: Expr -> Expr -> Expr Source # rem :: Expr -> Expr -> Expr Source # div :: Expr -> Expr -> Expr Source # mod :: Expr -> Expr -> Expr Source # quotRem :: Expr -> Expr -> (Expr, Expr) Source # divMod :: Expr -> Expr -> (Expr, Expr) Source # toInteger :: Expr -> Integer Source #
Real Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods toRational :: Expr -> Rational Source #
Show Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods showsPrec :: Int -> Expr -> ShowS Source # show :: Expr -> String Source # showList :: [Expr] -> ShowS Source #
Eq Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods (==) :: Expr -> Expr -> Bool Source # (/=) :: Expr -> Expr -> Bool Source #
Ord Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods compare :: Expr -> Expr -> Ordering Source # (<) :: Expr -> Expr -> Bool Source # (<=) :: Expr -> Expr -> Bool Source # (>) :: Expr -> Expr -> Bool Source # (>=) :: Expr -> Expr -> Bool Source # max :: Expr -> Expr -> Expr Source # min :: Expr -> Expr -> Expr Source #
FromExpr Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods fromExpr :: Expr -> Expr Source #

class FromExpr a where Source #

Conversion from `Expr` to other types

Methods

fromExpr :: Expr -> a Source #

#### Instances

Instances details

FromExpr Expr Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods fromExpr :: Expr -> Expr Source #
(Show a, FromExpr b) => FromExpr (a -> b) Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods fromExpr :: Expr -> a -> b Source #

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

Instances details

Eq Associativity Source # |
Instance details Defined in Debug.SimpleReflect.Expr Methods (==) :: Associativity -> Associativity -> Bool Source # (/=) :: Associativity -> Associativity -> Bool Source #

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.