[Haskell-cafe] Strange subtract operator behavior

David Christensen dwc at dwci.net
Tue Oct 16 14:36:34 EDT 2007

>>> I think you should have to write negative numbers using the syntax
>>> 0-10, since currently having one single unary operator is ugly.
>> I think writing 0-10 is ugly.
> Ugly - yes. But very clear as to its meaning. How often do people
> actually write negative numeric literals? My guess is that -1 is the
> most common by a long way, but even that is quite rare. Of course,
> real statistics of real programs are the only answer.

If you were doing away with unary minus, I'd prefer going for it  
entirely and going for negate :: (Num a) => a -> a.  It could also be  
compile-time folded, so no performance impact obviously.

It also expresses intent without looking as ugly:

minusTen:: negate 10


More information about the Haskell-Cafe mailing list