prednote-0.36.0.4: Evaluate and display trees of predicates

Safe HaskellNone
LanguageHaskell2010

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 RPNToken f a Source

Constructors

TokOperand (PredM f a) 
TokOperator Operator 

data Operator Source

Constructors

OpAnd 
OpOr 
OpNot 

Instances

pushOperand :: PredM f a -> [PredM f a] -> [PredM f a] Source

pushOperator :: (Monad m, Functor m) => Operator -> [PredM m a] -> Either Text [PredM m a] Source

pushToken :: (Functor f, Monad f) => [PredM f a] -> RPNToken f a -> Either Text [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.