megaparsec
megaparsec copied to clipboard
Export initialState
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:
- Better support the use case of getting the remaining input.
- In general, simplify the initial state creation to allow the user to just override the fields in the default state that they want.
Why not. Would you like to open a PR for that?
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.
+1 for this request. It makes little sense to export runParserT'
without a no-boilerplate way for the user to construct a State
input.