ParsleyHaskell icon indicating copy to clipboard operation
ParsleyHaskell copied to clipboard

Limited register rollback

Open j-mie6 opened this issue 3 years ago • 0 comments

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

j-mie6 avatar Jan 08 '21 11:01 j-mie6