Maintainer | alexander@plaimi.net |
---|---|
Safe Haskell | Safe-Inferred |
Clac
Description
- data Opt = MkOpt {
- wantHelp :: Bool
- wantVerbose :: Bool
- getEquation :: [String]
- data StackItem a where
- data OpDesc = MkOpDesc {}
- data Op where
- optParser :: Parser Opt
- operators :: [(OpDesc, String)]
- buildStack :: String -> [StackItem Double] -> [StackItem Double]
- parseStack :: String -> Maybe (StackItem Double)
- stackTree :: [StackItem Double] -> Tree String
- solveStack :: [StackItem Double] -> [StackItem Double] -> Maybe Double
- solveAll :: [[String]] -> [(Maybe Double, String)]
- solveEquation :: String -> Maybe Double
Documentation
Holds information about the user passed options.
Constructors
MkOpt | |
Fields
|
An item on the calculator stack. Can either be a constant number, or an operator.
Operator-description binding.
The valid operator classes.
operators :: [(OpDesc, String)]Source
Predefined operator stack. This reflects the current program features.
Arguments
:: String | one equation item |
-> [StackItem Double] | prepend the result to this stack |
-> [StackItem Double] |
Build the calculator stack. Usually used in conjunction with foldr, to build the complete stack consecutively.
Parse an equation item.
stackTree :: [StackItem Double] -> Tree StringSource
Build a tree from a calculator stack, suitable for pretty printing.
Arguments
:: [StackItem Double] | stack to solve |
-> [StackItem Double] | stack used for zipping, initially empty |
-> Maybe Double | calculation result |
Solve a stack.
solveAll :: [[String]] -> [(Maybe Double, String)]Source
Solve multiple equations of an input list such as:
[["1","1","+"],["2","2","+"]]
This gives back a tuple for each equation where the first value is the result of the equation (if any) and the second one is a String representing the stackTree, suitable for printing.