On Feb 8, 2010, at 5:18 PM, Simon Peyton-Jones wrote:

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.
Helium accepts them all as well, and also delivers the, for me, expected results.


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


Jurriaan


_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to