Token functions #
tokenMap f accepts token t with result x if f t = some x, otherwise fails reporting the
unexpected token.
Instances For
anyToken consumes and returns one token. Only fails at the end of the input.
Instances For
tokenFilter test accepts and returns token t if test t = true.
Instances For
token tk accepts and returns tk.
Instances For
tokenArray tks accepts the tokens of tks in order and returns the tokens read. Fails, reporting
the first unexpected token, if any token does not match.
Instances For
tokenList tks accepts the tokens of tks in order and returns the tokens read. Fails, reporting
the first unexpected token, if any token does not match.
Instances For
endOfInput succeeds only at the end of the input. Consumes no input.
Instances For
Folding #
foldlP f init p folds the parser function f from left to right using init as an initial value
and the parser p to generate inputs of type α. Folding ends as soon as the update parser
p >>= f y fails, or right after it succeeds without consuming input. This parser never fails.
Instances For
foldlM f init p folds the monadic function f from left to right using init as an initial
value and the parser p to generate inputs of type α. Folding ends as soon as p fails, or
right after p succeeds without consuming input. This parser never fails.
Instances For
foldl f init p folds the function f from left to right using init as an initial value and the
parser p to generate inputs of type α. Folding ends as soon as p fails, or right after p
succeeds without consuming input. This parser never fails.
Instances For
foldr f p q parses p repeatedly until it fails and then parses q, folding f from right to
left over the results, starting from the result of q. Repetition also ends right after p
succeeds without consuming input. If q fails after some occurrences of p then the parse is
retried with fewer occurrences.
Instances For
foldlN n f init p folds the function f from left to right using init as an initial value over
the results of exactly n occurrences of p. Fails if any occurrence of p fails.
Instances For
foldlUpTo n f init p folds the function f from left to right using init as an initial value
over the results of up to n occurrences of p. Folding ends early when p fails. This parser
never fails.
Instances For
foldlUntil f init stop p folds the function f from left to right using init as an initial
value over the results of zero or more occurrences of p until stop succeeds, and returns the
result of folding with the result of stop. If p fails before stop succeeds then the error from
p is reported. If p succeeds without consuming input then the error from stop is reported.
Instances For
takeMany p parses zero or more occurrences of p until it fails and returns the array of results.
This parser never fails.
Instances For
takeMany1 p parses one or more occurrences of p until it fails and returns the array of
results.
Instances For
takeManyN n p parses n or more occurrences of p until it fails and returns the array of
results.
Instances For
takeUntil stop p parses zero or more occurrences of p until stop succeeds, and returns the
array of results of p and the result of stop. If p fails before stop succeeds then the error
from p is reported. If p succeeds without consuming input then the error from stop is
reported.
Instances For
dropMany p parses zero or more occurrences of p until it fails, ignoring the results. This
parser never fails.
Instances For
dropMany1 p parses one or more occurrences of p until it fails, ignoring the results.
Instances For
dropManyN n p parses n or more occurrences of p until it fails, ignoring the results.
Instances For
dropUntil stop p parses zero or more occurrences of p until stop succeeds, and returns the
result of stop, ignoring the results of p. Errors are reported as for takeUntil.
Instances For
count p parses zero or more occurrences of p until it fails and returns the number of
successes. This parser never fails.
Instances For
countUntil stop p parses zero or more occurrences of p until stop succeeds, and returns the
number of occurrences of p and the result of stop. Errors are reported as for takeUntil.
Instances For
endBy sep p parses zero or more occurrences of p, each followed by sep, and returns the array
of results of p.
The optional strict parameter controls error reporting:
- If
strict = falsethen this parser never fails and returns the longest possible array. - If
strict = truethen this parser fails if there is a final occurrence ofpwithout a trailingsep. Then the error ofsepis reported.
Instances For
endBy1 sep p parses one or more occurrences of p, each followed by sep, and returns the array
of results of p. The optional strict parameter controls error reporting after the first
occurrence, as for endBy.
Instances For
sepBy sep p parses zero or more occurrences of p separated by sep, and returns the array of
results of p.
The optional strict parameter controls error reporting:
- If
strict = falsethen this parser never fails and returns the longest possible array. - If
strict = truethen this parser fails if there is a finalsepwithout a followingp. Then the error ofpis reported.
Instances For
sepBy1 sep p parses one or more occurrences of p separated by sep, and returns the array of
results of p. The optional strict parameter controls error reporting after the first
occurrence, as for sepBy.
Instances For
sepNoEndBy sep p parses zero or more occurrences of p separated by sep without a trailing
sep, and returns the array of results of p.
Instances For
sepNoEndBy1 sep p parses one or more occurrences of p separated by sep without a trailing
sep, and returns the array of results of p.
Instances For
sepEndBy sep p parses zero or more occurrences of p separated by sep with an optional
trailing sep, and returns the array of results of p. This parser never fails.
Instances For
sepEndBy1 sep p parses one or more occurrences of p separated by sep with an optional
trailing sep, and returns the array of results of p.