
Jason Dagit wrote:
reserved "units." <|> reserved "unit."
I always struggle with when I need to use 'try' with parsec.
My understanding is that if 'unit.' appears in the input the first parser will parse up to the '.' and then fail and consume the input up to that point, leaving the alternative with only the period as input so it will also fail.
So I'm wondering if someone could explain to me what is wrong with my understanding of parsec
Nothing at all. 'reserved' actually contains the necessary 'try', a 'notFollowedBy' in order not to swallow parts of longer identifiers and a useful error message. I tend to forget 'try', too, or add it in odd places. Actually, if ReadP hat better error reporting, I'd recommend that over Parsec. Udo. -- Time is an illusion. Lunchtime doubly so. -- Douglas Adams