Wanted: warning option for usages of unary minus

Simon Marlow simonmarhaskell at gmail.com
Mon May 14 05:19:07 EDT 2007

John Meacham wrote:
> On Wed, Apr 11, 2007 at 09:05:21AM +0100, Simon Marlow wrote:
>> I definitely think that -1# should be parsed as a single lexeme.  
>> Presumably it was easier at the time to do it the way it is, I don't 
>> remember exactly.
>> I'd support a warning for use of prefix negation, or alternatively you 
>> could implement the Haskell' proposal to remove prefix negation completely 
>> - treat the unary minus as part of a numeric literal in the lexer only.  
>> This would have to be optional for now, so that we can continue to support 
>> Haskell 98 of course.
> yes please! odd that I look forward to such a minor change in the big
> scheme of things, but the current treatment of negation has annoyed me
> more than any other misfeature I think.

Really?  I'm beginning to have second thoughts about the proposed change to 
negation for Haskell'.  The main reason, and this isn't pointed out as well as 
it should be on the wiki, is that "x-1" will cease to be an infix application of 
(-), it will parse as x applied to the literal (-1).  And this is different from 
"x - 1" (syntax in which whitespace matters should be avoided like the plague, 
IMO).  I think this would be worse than the current situation.


More information about the Glasgow-haskell-users mailing list