ParsleyHaskell
ParsleyHaskell copied to clipboard
Limited register rollback
While rollback
allows the user to roll state back within a local computation if it failed, it only works if the parser in question does not consume input. There is no way to tightly rollback the state from the branch except for further up the parser where the input is rolled back. This isn't a disaster but is somewhat annoying.
A combinator like onFail :: Parser a -> Parser () -> Parser a
which unconditionally executes a pure parser on the failure of some other parser would allow users to perform stateful operations after a parser has failed. This wouldn't require any new instructions, but would require a new AST node to be introduced.
Using this it is possible to make local completely rollback local modifications with the local
combinator