Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more expressive functions to be given as input in operator tables for buildExpressionParser #32

Closed
ahmadsalim opened this issue Mar 22, 2015 · 2 comments

Comments

@ahmadsalim
Copy link

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)) Assoc    
Prefix (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) Assoc     
PrefixM (a -> ParsecT s u m a)   
PostfixM (a -> ParsecT s u m a)
@ahmadsalim
Copy link
Author

I would happily submit a PR if the feature request if there are not any major objections.

@mrkkrp
Copy link
Contributor

mrkkrp commented Aug 22, 2015

@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.

int-index pushed a commit to int-index/parsec that referenced this issue Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants