Negation
Simon Peyton-Jones
simonpj at microsoft.com
Mon Feb 8 11:18:07 EST 2010
Folks
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
Foo.hs:4:7:
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?
Simon
More information about the Haskell-prime
mailing list