john at repetae.net
Mon Feb 8 16:24:55 EST 2010
On Mon, Feb 08, 2010 at 04:18:07PM +0000, Simon Peyton-Jones wrote:
> Which of these definitions are correct Haskell?
> x1 = 4 + -5
> x2 = -4 + 5
> x3 = 4 - -5
> x4 = -4 - 5
> x5 = 4 * -5
> x6 = -4 * 5
> Ghc accepts x2, x4, x6 and rejects the others with a message like
> Precedence parsing error
> cannot mix `+' [infixl 6] and prefix `-' [infixl 6] in the same infix expression
> Hugs accepts them all.
> I believe that the language specifies that all should be rejected. http://haskell.org/onlinereport/syntax-iso.html
> I think that Hugs is right here. After all, there is no ambiguity in any of these expressions. And an application-domain user found this behaviour very surprising.
> I'm inclined to start a Haskell Prime ticket to fix this language definition bug. But first, can anyone think of a reason *not* to allow all the above?
What would be the actual change proposed? If it is something concrete
and not something like "negatives should be interpreted as unary minus
when otherwise it would lead to a parse error" then that wouldn't be
good. I have enough issues with the layout rule as is :)
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
More information about the Haskell-prime