-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Utilities for parsing and evaluating mathematical expressions.
--
-- ParserFunction provides utilities for parsing and evaluating
-- mathematical expressions. The central parsing function in this package
-- is stringToExpr, which parses a string-expression (e.g.
-- "3*x+2") and returns a Maybe expression tree of type Expr (e.g. Just
-- (Add (Mul (Num 3.0) (Var 'x')) (Num 2.0))). This type is suitable for
-- performing symbolic logic. Expressions can then be evaluated using the
-- function evaluate (e.g. evaluate (fromAscList
-- [("x",2)]) (Add (Mul (Num 3.0) (Var 'x'))) (Num 2.0) would give 8.0).
-- If you wish to evaluate a string-expression without any intermediate
-- symbolic logic operations, simply use the function
-- evaluateExpression (e.g. evaluateExpression "3*x+2"
-- [('x',4)] gives 14.0). More examples of these functions can be found
-- by viewing the source code for this package.
@package ParserFunction
@version 0.0.6
module Text.ParserCombinators.Parsec.ParserFunction
-- | The Expr data type provides a basis for ordering mathematical
-- operations.
data Expr
-- | evaluateExpression evaluates a mathematical expression s
-- using the variable map m.
evaluateExpression :: String -> [(Char, Double)] -> Double
-- | stringToExpr parses an expression and returns an expression
-- tree of type Expr.
stringToExpr :: String -> Maybe Expr
buildExpr :: Parser Expr
expressionTable :: [[Operator Char st Expr]]
factor :: Parser Expr
variables :: Parser Expr
number :: Parser Expr
-- | evaluate takes a map and expression tree to produce a
-- numerical value.
evaluate :: Map String Double -> Expr -> Double
instance Show Expr
instance Eq Expr
instance Ord Expr