O'Haskell OOP Polymorphic Functions

Johan Nordlander nordland@cse.ogi.edu
Wed, 17 Jan 2001 16:07:14 -0800


Ashley Yakeley wrote:
> 
> OK, I've figured it out. In this O'Haskell statement,
> 
> > struct Derived < Base =
> >     value :: Int
> 
> ...Derived is not, in fact, a subtype of Base. Derived and Base are
> disjoint types, but an implicit map of type "Derived -> Base" has been
> defined.
> 
> --
> Ashley Yakeley, Seattle WA

Well, they are actually subtypes, as far as no implicit mapping needs to be
defined.  But since Derived and Base also are two distinct type constructors,
the overloading system treats them as completely unrelated types (which is fine,
in general).  To this the upcoming O'Hugs release adds the capability of using
an instance defined for a (unique, smallest) supertype of the inferred type, in
case an instance for the inferred type is missing.  This all makes a system that
is very similar to the overlapping instances extension that Tom mentioned.

-- Johan