Theorems for ParseIt.Combinators
tokenMap f reads one token t and succeeds with a when f t = some a, consuming input.
It fails with Error.unexpected it none at end of input, or with Error.unexpected it (some t)
when f t = none.
anyToken reads and returns one token, consuming input; it fails with an unexpected error
at it.
tokenFilter test reads one token t and succeeds when test t holds, consuming input. It
fails at end of input or with Error.unexpected it (some t) when test t is false.
token tk succeeds with tk when the next token equals tk, consuming input. It fails at end
of input or with Error.unexpected it (some t) when the next token t differs from tk.
tokenArray tks succeeds with tks when the input starts with the tokens of tks, consuming
input if tks is non-empty; otherwise it fails with an unexpected error.
tokenList tks succeeds with tks when the input starts with the tokens of tks, consuming
input if tks is non-empty; otherwise it fails with an unexpected error.
endOfInput succeeds without consuming input; any failure is an unexpected error at it.
foldP never reports an error. If p always consumes input on success,
foldP advances whenever the accumulator changed
foldlM f init p never fails. Its result satisfies every invariant P that holds for init
and is preserved by f on the outputs of p, and if p always consumes input on success, it has
consumed input whenever the result differs from init.
Specs for the remaining combinators
A spec for x started at it from a description of x it: on success the final state is
exactly what x it returns and satisfies Q, and on failure the error satisfies E.
take n p returns exactly n outputs of p, consuming input when n > 0 and p always
consumes input; on failure the error is an error of p.
foldl f init p never fails. Its result satisfies every invariant P that holds for init
and is preserved by f on the outputs of p, and if p always consumes input on success, it has
consumed input whenever the result differs from init.
foldr f p q returns xs.foldr f y for outputs xs of p and an output y of q; on
failure the error is that of q at the start position it.
foldlN n f init p folds f over exactly n outputs of p, consuming input when n > 0
and p always consumes input; on failure the error is an error of p.
foldlUpTo n f init p never fails: it folds f over at most n outputs of p, consuming
input when it folded at least one and p always consumes input.
foldlUntil f init stop p folds f over outputs of p and pairs the result with an output
of stop; on failure the error is an error of p or of stop.
takeUpTo n p never fails: it returns at most n outputs of p, consuming input when the
result is non-empty and p always consumes input.
takeMany p never fails: it returns outputs of p, consuming input when the result is
non-empty and p always consumes input.
takeMany1 p returns a non-empty array of outputs of p, consuming input when p always
consumes input; on failure the error is that of the first p at it.
takeManyN n p returns at least n outputs of p, consuming input when n > 0 and p
always consumes input; on failure the error is an error of p.
takeUntil stop p returns outputs of p paired with an output of stop; on failure the
error is an error of p or of stop.
drop n p consumes input when n > 0 and p always consumes input; on failure the error
is an error of p.
dropUpTo n p never fails.
dropMany p never fails.
dropMany1 p consumes input when p always consumes input; on failure the error is that of
the first p at it.
dropManyN n p consumes input when n > 0 and p always consumes input; on failure the
error is an error of p.
dropUntil stop p returns an output of stop; on failure the error is an error of p or
of stop.
count p never fails, and consumes input when the count is non-zero and p always
consumes input.
countUpTo n p never fails: it returns a count of at most n, consuming input when the
count is non-zero and p always consumes input.
countUntil stop p pairs a count with an output of stop; on failure the error is an error
of p or of stop.
endBy sep p strict returns outputs of p, consuming input when the result is non-empty and
p always consumes input; it only fails when strict, with an error of sep.
endBy1 sep p strict returns a non-empty array of outputs of p, consuming input when p
always consumes input; on failure the error is that of the first p <* sep at it or, when
strict, an error of sep.
sepBy sep p strict returns outputs of p, consuming input when the result is non-empty and
p always consumes input; it only fails when strict, with an error of p.
sepBy1 sep p strict returns a non-empty array of outputs of p, consuming input when p
always consumes input; on failure the error is that of the first p at it or, when strict,
an error of p.
sepNoEndBy sep p returns outputs of p, consuming input when the result is non-empty and
p always consumes input; on failure the error is an error of p.
sepNoEndBy1 sep p returns a non-empty array of outputs of p, consuming input when p
always consumes input; on failure the error is an error of p.
sepEndBy sep p never fails: it returns outputs of p, consuming input when the result is
non-empty and p always consumes input.
sepEndBy1 sep p returns a non-empty array of outputs of p, consuming input when p
always consumes input; on failure the error is that of the first p at it.