Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Basic types and convenience functions for constructing your own terms and expression trees.
Synopsis
- data Term
- = Measured {
- numSigFigs :: Integer
- value :: BigDecimal
- | Constant Rational
- = Measured {
- data Op
- data Expr
- data Function
- measured :: Integer -> Rational -> Term
- constant :: Rational -> Term
- l :: Term -> Expr
- lMeasured :: Integer -> Rational -> Expr
- lConstant :: Rational -> Expr
- add :: [Expr] -> Expr
- sub :: [Expr] -> Expr
- mul :: [Expr] -> Expr
- div :: [Expr] -> Expr
- exp :: Expr -> Integer -> Expr
- apply :: Function -> Expr -> Expr
Documentation
The basic datatype to represent measurements, constant terms, and evaluation results
Measured | A measured value with a finite number of significant figures and an associated value |
| |
Constant Rational | A constant value with infinite significant figures |
The types of (infix) operators
A datatype to represent (not-yet-evaluated) expressions. Use parse
to create such an expression from text.
Leaf Term | Leaf of an expression |
Prec1 [(Op, Expr)] | Operation of "Precedence 1": addition and subtraction |
Prec2 [(Op, Expr)] | Operation of "Precedence 2": multiplication and division |
Exp Expr Integer | Exponentiation with a constant integer exponent |
Apply Function Expr | Application of a function to an expression argument |
A datatype representing the supported functions.
Creating Terms and Expression Trees
lMeasured :: Integer -> Rational -> Expr Source #
Create a leaf node and construct the Measured
value argument at the same time. Convenience function.
lConstant :: Rational -> Expr Source #
Create a leaf node and construct the Constant
value argument at the same time. Convenience function.