Primitive types and Prelude shenanigans

Marcin 'Qrczak' Kowalczyk
16 Feb 2001 08:09:58 GMT

Thu, 15 Feb 2001 20:56:20 -0800, William Lee Irwin III <> pisze:

> 	literal "0" gets mapped to zero :: AdditiveMonoid t => t
> 	literal "1" gets mapped to one :: MultiplicativeMonoid t => t
> 	literal "5" gets mapped to (fromPositiveInteger 5)
> 	literal "-9" gets mapped to (fromNonZeroInteger -9)

Actually -9 gets mapped to negate (fromInteger 9). At least in theory,
because in ghc it's fromInteger (-9) AFAIK.

> The motivation behind this is so that some fairly typical
> mathematical objects (multiplicative monoid of nonzero integers,
> etc.) can be directly represented by numerical literals (and
> primitive types).

I am definitely against it, especially the zero and one case.
When one can write 1, he should be able to write 2 too obtaining the
same type. It's not hard to write zero and one.

What next: 0 for nullPtr and []?

Moreover, the situation where each integer literal means applied
fromInteger is simple to understand, remember and use. I don't want to
define a bunch of operations for the same thing. Please keep Prelude's
rules simple.

 __("<  Marcin Kowalczyk *
  ^^                      SYGNATURA ZASTĘPCZA