logoalt Hacker News

codebje • today at 12:07 PM • 1 reply • view on HN

    A parser for a thing
    Is a function from a string
    To a list of pairs
    Of strings and things.

Replies

mrkeen • today at 1:23 PM

If you use an Either instead of a List, then you can write an or combinator, which accepts two parsers and tries the second if the first fails. It branches on the Left/Right of the Either.

If it's a List, wouldn't you be forced to write the Cartesian product of two parsers instead?