Num class

Tom Pledger
Thu, 19 Oct 2000 21:14:07 +1300 (NZDT)

Marcin 'Qrczak' Kowalczyk writes:
 > Thu, 19 Oct 2000 16:25:02 +1300 (NZDT), Tom Pledger <> pisze:
 > > A language extension for subtyping would be of some use there.  For
 > > example, if Int is set up as a subtype of Integer, meaning that an Int
 > > value is acceptable anywhere an Integer value is expected (with the
 > > typechecker inserting the conversion code), the literal 42 can
 > > unambiguously be assigned the type Int.
 > This disallows literals of a non-standard type Int8. Not good.

If you had such a non-standard type, I imagine you'd also declare
something like this:

    instance Subtype Int8  Int16 where ...
    instance Subtype Int16 Int24 where ...
    instance Subtype Int24 Int   where ...

and hence literals in the range -128 to 127 would be typed Int8, etc.