Wanted: warning option for usages of unary minus

John Meacham john at repetae.net
Fri May 18 20:15:31 EDT 2007

On Mon, May 14, 2007 at 10:19:07AM +0100, Simon Marlow wrote:
> 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.

White space already matters when it comes to numbers quite a bit

0 x 123 vs 0x123
1.5 vs 1 . 5
3e4 vs 3 e 4


I think this change is more than worth it. I mean, having to write

(-4) everywhere is bad enough, but when writing polymorphic code,
(fromInteger (-4)) is horrific to embed everywhere. :)

another option would be to only count it as a negative if there is a
non-identifier character preceeding it. A little ugly. but still better
than the current situation IMHO.


John Meacham - ⑆repetae.net⑆john⑈

More information about the Haskell-prime mailing list