Theorems for ParseIt.Basic
For finite iterators, the only Progress proof from an iterator to itself is Progress.refl.
A spec for x started at the parse start it also holds when x is started at it with an
arbitrary parse start it₀, as long as the postcondition only depends on the current iterator.
Any x started at it (with parse start it₀) never moves backwards from it.
Generic specification of an arbitrary parser x started at it: on success the final state is
exactly what x it returns, and on failure the error is the one x it returns.
pure default succeeds without consuming input and returns default.
Lifting a pure Id value into ParserT succeeds without consuming input and returns that value.
p <|> q (starting with no input consumed): if p succeeds at the current position its result is
used, otherwise q is run from the same position.
p *> q satisfies post whenever running p and then q does; the result of p is discarded.
Evaluation of x *> pure default: run x and replace its result by default.
p <* q runs p and then q from where p stopped, returning the result of p; an error of
either parser is propagated.
Evaluation of pure default <* x: run x and return default instead of its result.
withSpan x behaves like x and additionally returns the positions of the start iterator it
and of the iterator after x.
Evaluation of getPos at it: succeed without consuming input and return the position of it.
getPos never fails: it succeeds without consuming input and returns the position of the
current iterator it.
throwUnexpected input always fails with Error.unexpected it input.
throwUnexpectedWithMessage input msg always fails with Error.unexpected it input annotated
with msg.
Evaluation of throwUnexpectedWithMessage input msg at it.
withErrorMessage msg x behaves like x on success; on failure the error e' of x is
annotated with msg at position it.
lookAhead x runs x without consuming input: on success the result of x is returned and the
position is reset to it.
notFollowedBy x succeeds without consuming input exactly when x fails at it; otherwise it
fails with Error.unexpected it none.
optionD x default never fails: it returns the result of x if x succeeds, and default
without consuming input otherwise.
optionD x default never fails: it returns the result of x if x succeeds, and default
without consuming input otherwise.
option! x never fails: it returns the result of x if x succeeds, and the Inhabited
default without consuming input otherwise.
option? x never fails: it returns some v if x succeeds with v, and none without
consuming input otherwise.
optional x never fails: it consumes what x consumes if x succeeds, and nothing otherwise.
first ps combine started at it succeeds exactly like the first parser of ps that succeeds
at it, after all parsers before it failed. When all parsers fail, the error is the fold of their
errors with combine, from left to right; when ps is empty, it is Error.unexpected it none.