[Haskell-cafe] attoparsec and backtracking

Niklas Hambüchen mail at nh2.me
Sat Mar 16 04:49:29 CET 2013


Is it not possible to add an alternative (no pun intended) to <|> that
supports the semantics Evan wants?

I would agree that what attoparsec does for <|> of Alternative and mplus
for MonadPlus is correct since e.g. the mplus laws say that a failure
must be identity and therefore the following alternatives must be
considered. I also find it very convenient that attoparsec works this
way, and prefer it to what parsec does by default.

However, I do not see why attoparsec cannot have a function <||> that on
failure with consumed input does not evaluate the remaining alternatives.

On 16/03/13 01:54, Erik de Castro Lopo wrote:
> Evan Laforge wrote:
>> However, which error msg shows up depends on the order of the (<|>)
>> alternatives, and in general the global structure of the entire
>> parser, because I think it just backtracks and then picks the last
>> failing backtrack.
> 
> I'm not sure if what I've offered will help, but its worth a try.



More information about the Haskell-Cafe mailing list