Ian Holyer and Will Partain have both argued that the interaction
between type classes and the module system could be improved.  I have
no doubt that they are right.

It may help to explain some of the motivation behind the current
system.  As Haskell is designed currently, the following property is
satisfied:

        GLOBAL INSTANCE PROPERTY: if an instance exists of a given
        class at a given type, this instance is in scope everywhere
        that the class and type are in scope.

If this was not the case, then the point at which overloading was
resolved (definition point or usage point) might change the meaning of
the program.   In my opinion, that would be a real disaster: adding
extra type declarations to a program could suddenly change its
meaning.  (As it stands now, I believe that cannot happen, so long as
defaults are not used; perhaps that's a good reason for getting rid of
defaults.  If defaults are used responsibly, i.e., all instances of a
defaulted class have compatible meanings, then the problem cannot arise
anyway.)

The current system was an attempt to remain simple, while
ensuring that the Global Instance Property held.  Understanding
this motivation may be helpful in any attempt to design a better
system.  Cheers,  -- P

-----------------------------------------------------------------------
Professor Philip Wadler                        [EMAIL PROTECTED]
Department of Computing Science                    tel: +44 41 330 4966
University of Glasgow                              fax: +44 41 330 4913
Glasgow G12 8QQ, SCOTLAND


Reply via email to