-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
A parser built via buildExprParser supports chaining of infix operators, but does not support chaining prefix and postfix operators.
Consider the following parser:
word :: String -> Parser String String
word s = string s <* whiteSpace
bool :: Parser String Boolean
bool = (word "True" >>= \_ -> pure true) <|> (word "False" >>= \_ -> pure false)
parser :: Parser String Boolean
parser = buildExprParser
[ [ Prefix (word "not" >>= \_ -> pure not) ]
, [ Infix (word "and" >>= \_ -> pure (&&)) AssocLeft ]
]
bool
This successfully parses expressions like True and True and True, but fails to parse expressions such as not not True.
It would be nice if this was supported out-of-the-box, or if there is some way to enable it.
Metadata
Metadata
Assignees
Labels
No labels