|
![](/i/fill.gif) |
>> xs <- many1 digit
>> if length xs > 3 then fail else return ()
>
> By the way, this also means you have backtracking
No it doesn't.
Parsec doesn't backtrack by default; you have to explicitly request it
(which I haven't).
If there are more than three digits, the above parser fails, and no
other alternatives are tried (i.e., no backtracking).
(As an aside, there are other Haskell libraries that work similarly to
Parsec, but where backtracking is the default and turning it off is
explicit. Apparently this is more intuitive to work with...)
Post a reply to this message
|
![](/i/fill.gif) |