Hascal is both a simple but extendable calculator library for Haskell
and a command-line program using it.
Also, its source code is a nice example for a minimalistic Haskell project.
operators is the default list of operators.
An operator consists of one character and a function with of type
CReal -> CReal -> CReal.
- addition, represented by
- subtraction, represented by
- multiplication, represented by
- division, represented by
- exponentiation, represented by
- logarithming (with flipped arguments, see below), represented by
such that these laws are held:
(a - b == c) == (a == b + c) (a / b == c) == (a == b * c) (a ? b == c) == (a == b ^ c)
eval gets a list of operators and a string containing a mathematical
expression/term which only uses those operators listed in the first
argument, and returns the result of that term.