I'm against removing it, even if compatibility was not an issue.
Yes, it's an irregularity. But it's convenient, readable, and it allows using negative constants in patterns.
-- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
I had either not realized, or forgotten, that unary minus could be used in patterns, that is indeed an important feature. Unary minus is indeed a confused beast. If it were considered a part of numeric literals, it wouldn't be possible to apply it to expressions. And if it were regarded as a normal function it would not be possible to match against it in patterns. It might almost be considered a kind of constructor (although not beginning with an upper case letter) but this would mean the result of applying it would have to be a different type, and require extracting the underlying value, or the use of conversion functions, when combining its use with regular numeric types. Considering it as a constructor, with an automatic conversion to regular numeric types via 'negate', seems to come closest to fitting all of its properties, except for its precedence level. Now if we only expanded the flexibility of 'newtype' declarations so that we could include a conversion function to the underlying type, and expand the type checking system to automatically add calls to such a function when needed, and change the syntax so that the constructor for 'newtype' wasn't limited to identifiers, and change the syntax some more so that new 'prefix' declarations were available to adjust the precedence levels of these new constructors, it would be a piece of cake :-) -- Gary
Hello,
[...] I had either not realized, or forgotten, that unary minus could be used in patterns, that is indeed an important feature.
Okay, that is right. Maybe it would be good to make the unary minus part of the numeric literal syntax and thus allowing only constants to be negated. This would allow pattern matching against negative constants. And for negating results of arbitrary expressions one could use the negate function. Well, this would still leave some problems with sections for example.
[...]
Wolfgang
participants (2)
-
Memovich, Gary -
Wolfgang Jeltsch