Safe Haskell | None |
---|---|
Language | Haskell2010 |
Postfix, or RPN, expression parsing.
This module parses RPN expressions where the operands are
predicates and the operators are one of and
, or
, or not
,
where and
and or
are binary and not
is unary.
- data RPNToken f a
- = TokOperand (PredM f a)
- | TokOperator Operator
- data Operator
- pushOperand :: PredM f a -> [PredM f a] -> [PredM f a]
- pushOperator :: (Monad m, Functor m) => Operator -> [PredM m a] -> Either Text [PredM m a]
- pushToken :: (Functor f, Monad f) => [PredM f a] -> RPNToken f a -> Either Text [PredM f a]
- parseRPN :: (Functor m, Monad m) => Foldable f => f (RPNToken m a) -> Either Text (PredM m a)
Documentation
TokOperand (PredM f a) | |
TokOperator Operator |
pushOperand :: PredM f a -> [PredM f a] -> [PredM f a] Source
parseRPN :: (Functor m, Monad m) => Foldable f => f (RPNToken m a) -> Either Text (PredM m a) Source
Parses an RPN expression and returns the resulting Pred
. Fails if
there are no operands left on the stack or if there are multiple
operands left on the stack; the stack must contain exactly one
operand in order to succeed.