[Haskell-cafe] Examples for the problem

Carl Howells chowells at janrain.com
Wed Mar 2 19:03:21 CET 2011

Actually, It's not <|> that's different, it's the string combinator.
In Parsec, string matches each character one at a time.  If the match
fails, any partial input it matched is consumed.  In attoparsec,
string matches either the entire thing or not, as a single step.  If
it fails to match, no input is consumed.


On Wed, Mar 2, 2011 at 9:51 AM, Stephen Tetley <stephen.tetley at gmail.com> wrote:
> Actually this is stranger than I thought - from testing it seems like
> Attoparsec's (<|>) is different to Parsec's. From what I'm seeing
> Attoparsec appears to do a full back track for (<|>) regardless of
> whether the string lexer is wrapped in try, whereas Parsec needs try
> to backtrack.
> On 2 March 2011 16:24, Stephen Tetley <stephen.tetley at gmail.com> wrote:
>> *try* means backtrack on failure, and try the next parser. So if you
>> want ill formed strings to throw an error if they aren't properly
>> enclosed in double quotes don't use try.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list