Num class

Tom Pledger Tom.Pledger@peace.com
Thu, 19 Oct 2000 16:25:02 +1300 (NZDT)


Mark P Jones writes:
 > [...]
 > 
 > Defaulting only kicks in if (a) at least one class is numeric, and
 > (b) all classes are standard.  [...]  Defaulting was designed to
 > work in this way so that (i) it would catch and deal with the most
 > common problems occurring with numeric literals, and (ii) it would
 > not be used too often; defaulting is in general undesirable because
 > it can silently change the semantics.  Again, defaulting is an
 > example of a compromise in the design of Haskell.  Ideally, you'd
 > do without it all together, but if you went that way, you'd end up
 > having to write more type information in your programs.  And again,
 > I don't suppose there is a universally satisfactory point on this
 > spectrum.

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 is a reprise of an airy suggestion I've posted before, hence the
move to the haskell-cafe list.  I'm still at the reading-about-
related-work stage of doing something more thorough about it.)

Regards,
Tom