prednote-0.26.0.2

Safe HaskellSafe-Inferred

Prednote.Expressions.RPN

Description

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.

Synopsis

Documentation

data Operator Source

Constructors

OpAnd 
OpOr 
OpNot 

Instances

Show Operator 

pushOperand :: Pred a -> [Pred a] -> [Pred a]Source

pushOperator :: Operator -> [Pred a] -> Either Text [Pred a]Source

pushToken :: [Pred a] -> RPNToken a -> Either Text [Pred a]Source

parseRPN :: Foldable f => f (RPNToken a) -> Either Text (Pred a)Source

Parses an RPN expression and returns the resulting Predbox. 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.