| Copyright | Copyright (C) 2023 Yoo Chung |
|---|---|
| License | GPL-3.0-or-later |
| Maintainer | dev@chungyc.org |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Problems.Monads
Description
Supporting definitions for monad problems.
Documentation
Encodes an operator for a mathematical expression.
Constructors
| Negate | Encodes negation. Equivalent to an unary minus. Unary operator. |
| Add | Encodes duplication. Makes another copy of its operand. Unary operator. |
| Subtract | Encodes subtraction. Binary operator. |
| Multiply | Encodes multiplication. Binary operator. |
| Divide | Encodes division. Equivalent to |
| Modulo | Encodes a modulo operator. Equivalent to |
Instances
| Bounded Operator Source # | |
| Enum Operator Source # | |
| Show Operator Source # | |
| Eq Operator Source # | |
A single element within a mathematical expression. A list of these elements comprises an expression in postfix notation.
parsePostfix :: String -> [Element] Source #
Parses a string containing a mathematical expression in postfix notation. This can make it easier to write down an expression in a more conventional form.
For example,
>>>parsePostfix "3 4 2 - *"[Operand 3,Operand 4,Operand 2,Operator Subtract,Operator Multiply]
The operators are encoded as follows:
| Operator | String |
|---|---|
Negate | "negate" |
Add | "+" |
Subtract | "-" |
Multiply | "*" |
Divide | "/" |
Modulo | "%" |