You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Operator constructors used for building expression parsers are required to be pure functions wrapped in the ParsecT monad, i.e.:
Infix (ParsecT s u m (a -> a -> a)) AssocPrefix (ParsecT s u m (a -> a))
Postfix (ParsecT s u m (a -> a))
This however limits what can be done with the operators, for example it is not possible to perform additional checks of the parsed argument under the ParsecT monad and then fail using fail or unexpected, or build up new information in the complete term using the parsed sub-terms.
I would therefore like to ask for a feature request that allows taking more expressive functions where only the resulting term needs to be in the ParsecT monad. In order to not break backwards compatibility, one could imagine having an M postfix to each new constructor, so the following constructors are added:
InfixM (a -> a ->ParsecT s u m a) AssocPrefixM (a ->ParsecT s u m a)
PostfixM (a ->ParsecT s u m a)
The text was updated successfully, but these errors were encountered:
@ahmadsalim, this is interesting. We're considering replacing of old constructors with something like this in Megaparsec. You can discuss it here: mrkkrp/megaparsec#22.
Currently, the
Operator
constructors used for building expression parsers are required to be pure functions wrapped in theParsecT
monad, i.e.:This however limits what can be done with the operators, for example it is not possible to perform additional checks of the parsed argument under the
ParsecT
monad and then fail usingfail
orunexpected
, or build up new information in the complete term using the parsed sub-terms.I would therefore like to ask for a feature request that allows taking more expressive functions where only the resulting term needs to be in the
ParsecT
monad. In order to not break backwards compatibility, one could imagine having anM
postfix to each new constructor, so the following constructors are added:The text was updated successfully, but these errors were encountered: