When makeExprParser is given two infix operators at the same precedence level but with different associativit it stops before parsing the expression completely for some inputs.
Example:
operatorTable =
[ [ prefix "-" Negation
, prefix "+" id
]
, [ binaryR "^" Expo
, binaryL "*" Product
, binaryL "/" Division
]
, [ binaryL "+" Sum
, binaryL "-" Subtr
]
]
For the above slightly modified example from the tutorial the parser stops unexpectedly:
ghci> parseTest pExpr "2 ^ 2 * 3 ^ 2"
Expo (Int 2) (Int 2)
This is unexpected because documentation says it should work:
All operators in one list have the same precedence (but may have different associativity).
Looking at the code it seems like this could be fixed by adding recursion to addPrecLevel. But I am not sure this is a good idea so have not created a PR to fix this.
When
makeExprParseris given two infix operators at the same precedence level but with different associativit it stops before parsing the expression completely for some inputs.Example:
For the above slightly modified example from the tutorial the parser stops unexpectedly:
This is unexpected because documentation says it should work:
Looking at the code it seems like this could be fixed by adding recursion to
addPrecLevel. But I am not sure this is a good idea so have not created a PR to fix this.