Kent Karlsson says:
> Parsing Haskell list comprehensions deterministically ((LA)LR) is currently very
> hard, since both "pat <- exp" (or also "pat gd <- exp", as suggested by Thomas)
> and "exp" are allowed as qualifiers in a list comprehension. Patterns and
> expressions can look very much alike. Could one possibly expand "exp" to
> "if exp" in Haskell 1.3 list comprehensions? Only to make deterministic
> parsing easier...
In Id, we have "when exp" for predicates in list comprehension
qualifiers; it was introduced for just this reason (LALR parsing).
I, personally, did not like this design decision. I have frequently
been irritated by syntax decisions in Id (and other languages) that
are there only to make LALR parsing easy. As long as something is
easily parseable by the human reader, I think it's worth keeping it
simple by putting extra burden on the compiler's parser to handle it.
This extra effort in parser hacking is a small, one-time effort,
compared to the really hard stuff in the compiler!
(This opinion may not be shared by other Id programmers.)
Nikhil