This combinator implements choice. The parser
p <|> q
first applies
p. If it succeeds, the value of
p is
returned. If
p fails
without consuming any input,
parser
q is tried. This combinator is defined equal to the
mplus member of the
MonadPlus class and the
(
<|>) member of
Alternative.
The parser is called
predictive since
q is only tried
when parser
p didn't consume any input (i.e.. the look ahead
is 1). This non-backtracking behaviour allows for both an efficient
implementation of the parser combinators and the generation of good
error messages.