
On 31/01/2006, at 9:31 PM, Simon Marlow wrote:
We must find *something* to throw away though! :-)
One small issue that I'd love to see thrown away is the special handling the the unary "-" operator in Haskell 98. It's been described as "embarrassing", "ugly", and even "inconvenient" I, for one, find myself creating sections of the form `+ (-x)` all the time, and it feels wrong. The proposal would be to remove the unary "-" altogether, and, instead, extend the lexical syntax of numeric constant to allow "+" and "-" prefix. Further, we would need to extend the prelude with an additional definition: negate :: Num a -> Num a negate x = 0 - x Pros: 1. Removes an embarrassing special case from the grammar. 2. Makes the section `- x` work as expected. 3. Expressions such as "-1" would not require paranthesizing. 4. Expressions such as "-1" would be permitted in k-patterns even if n+k patterns end up being thrown out. 5. You can say "negate $ 1 + 2" if you don't like parentheses. 6. The precedent of making an operator symbol behave differently when not separated from its argument by a space has already been made by the "." operator. Cons: 1. Expressions of the form "-x" (where "x" is not a constant) need to be rewritten as "negate x" (which, to me, looks much cleaner anyway, especially as, more often than not, "x" ends up being a complex expression anyway! 2. Possible confusion to the beginners (can write "-1" but cannot write "-x".) However, I think that the strange behaviour of sections and the need for parentheses around "-1" is already confusing enough to beginners, and therefore this chance would actually make Haskell *easier* to learn, not harder. "negate x" looks so much more like ordinary Haskell code! What do people think? - Pat.