After getting Dr. Wadler to correct a mistaken belief I had concerning
types, I have thought about this some more.  The example was:

  Consider the following (currently illegal in Haskell):
  ----------------------------------------------------
  module One (Problematic)

  class Problematic a where
    difficult :: a -> a
  ----------------------------------------------------
  module Two (trouble)

  imports One (Problematic)

  instance Problematic Int where
    difficult n = n+1

  trouble n = difficult (difficult n)
  ----------------------------------------------------
  module Three (confused)

  imports One (Problematic)
  imports Two (trouble)

  instance Problematic Int where
    difficult n = 2*n

  confused :: Int -> Int
  confused =  trouble
  ----------------------------------------------------

  If the overloading of `trouble' is resolved in
  module Two, then `confused' adds two to a number,
  if it is resolved in module Three, then `confused'
  multiplies a number by four.  As it stands, it
  appears the overloading must be resolved in Module
  Three; but adding the declaration

          trouble :: Int -> Int

  allows the overloading to be resolved in module Two.

I am a little confused about the example, still (even though I am
willing to expose this ignorance to the world, unlike my type
ignorance so graciously corrected).  Trouble is not overloaded; there
is a single definition for this named value.  It would not occur to me
to resolve this overloading in any context other than that in which it
is declared.  This example does not even strike me as confusing, since
the value of trouble is not even in module Three, and therefore both
intuitively and correctly (to my mind) the intervening instance
declaration has nothing to do with things.

This may be an extension of the Gofer heresy (note I said extension
and not implication), which does all this as staticly as possible.  At
any rate, resolving overloading at the point of declaration seems to
me the natural definition of all this.

This explains why I stated (before) that this is yet another version
of the "generalized hiding principle" which causes confusion in other,
similar cases.  I was assuming resolution at point of declaration,
which means I was assuming too much (given that it is a point of
contention, above).

By the way, has anyone suggested modifying the Haskell type resolution
to conform to Gofer's, now that we have tried both?  If not, I
(respectfully) suggest we consider it for 1.3 (or perhaps 2.0, if that
is too fundamental a change).

                                        Dave Barton
                                        [EMAIL PROTECTED]

Reply via email to