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

Export initialState #449

Closed
kirelagin opened this issue Apr 25, 2021 · 3 comments · Fixed by #539
Closed

Export initialState #449

kirelagin opened this issue Apr 25, 2021 · 3 comments · Fixed by #539

Comments

@kirelagin
Copy link

kirelagin commented Apr 25, 2021

One useful feature that megaparsec has compared to parsec is the ability to get the remainder of the input. In fact, I think it is so useful that it would make sense to expose this functionality explicitly.

In the meantime, it is accessible via runParser', however it is not easy to use given that this function requires the initial state, which is pretty tricky and boilerplate-y to construct. I think, it would be helpful to export initialState used by runParser in order to:

  1. Better support the use case of getting the remaining input.
  2. In general, simplify the initial state creation to allow the user to just override the fields in the default state that they want.
@mrkkrp
Copy link
Owner

mrkkrp commented Apr 25, 2021

Why not. Would you like to open a PR for that?

@mrkkrp
Copy link
Owner

mrkkrp commented Apr 29, 2021

Although there is a problem: hspec-megaparsec already exports a very similar function called initialState. If we export initialState from Megaparsec it may break existing code. Perhaps we could call it differently though.

@olafklinke
Copy link
Contributor

+1 for this request. It makes little sense to export runParserT' without a no-boilerplate way for the user to construct a State input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants