Second draft of the Haskell 2010 report available
Christian Maeder
Christian.Maeder at dfki.de
Tue Jul 6 08:17:04 EDT 2010
http://www.haskell.org/~simonmar/haskell-2010-draft-report-2/haskellch3.html
infixexp → lexp qop infixexp (infix operator application)
| - infixexp (prefix negation)
| lexp
This grammar rule describes a right associative nesting of (any) infix
operators "qop" and prefix negation as binding weaker than any infix.
Thus a parser would create from "- 1 /= 1 && a" the tree
"- (1 /= (1 && a))".
Would it not be better to give an ambiguous grammar and leave it to the
infix resolution algorithm to allow only the intended trees, rather than
letting the infix resolution algorithm correct a wrong tree?
My suggestion would be to change the rule to:
infixexp → infixexp qop infixexp (infix operator application)
| - infixexp (prefix negation)
| lexp
thus only replacing the first lexp by infixexp.
Cheers Christian
More information about the Haskell-prime
mailing list