At last, an issue that I understand a bit.

Phil Wadler writes:

   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.

Apart from making what was an illegal program legal, how does adding
extra type declarations change the meaning?  Do you mean that an added
class declaration might bring the instance declaration within the
scope of the added class declaration, rather than the old one?  If so,
it is a specific instance of a very general problem, inherited
whenever you allow name hiding in general (consider a type defined in
terms of another type).

Unfortunately, whenever you allow name hiding and the insertion of a
declaration that hides a more global one "inbetween" the global
declaration and a function declaration that uses it, this problem is
going to exist.  The global instance property is very limited in this
sense, and yields (to my mind) very little benefit.

When compared with the inability to declare a user type in my own
scope, and an instance of a global class for that user type, there is
no contest in my mind.  The lack of this truly hurts.  Therefore, I am
in favor of relaxing the restriction.

                                        Dave Barton
                                        [EMAIL PROTECTED]


Reply via email to