from micro-rant to macro-feature
Thu, 9 Aug 2001 16:00:42 -0700
> 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 * firstname.lastname@example.org =
> ^^ SYGNATURA ZAST=CAPCZA
I had either not realized, or forgotten, that unary minus could be used =
patterns, that is indeed an important feature. =20
Unary minus is indeed a confused beast. If it were considered a part =
numeric literals, it wouldn't be possible to apply it to expressions. =
if it were regarded as a normal function it would not be possible to =
against it in patterns. It might almost be considered a kind of =
(although not beginning with an upper case letter) but this would mean =
result of applying it would have to be a different type, and require
extracting the underlying value, or the use of conversion functions, =
combining its use with regular numeric types.
Considering it as a constructor, with an automatic conversion to =
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 =
could include a conversion function to the underlying type, and expand =
type checking system to automatically add calls to such a function when
needed, and change the syntax so that the constructor for 'newtype' =
limited to identifiers, and change the syntax some more so that new =
declarations were available to adjust the precedence levels of these =
constructors, it would be a piece of cake :-)