On 16-Feb-2000, Jeffrey R. Lewis <[EMAIL PROTECTED]> wrote:
> To my mind, the biggest flaw with overlapping instances is the separate
> compilation issue: to whit, if the `instance Eq (Maybe String)' was in
> a different module, not imported by the module defining `f', then
> Marcin's definition of `f' (with context `Maybe a') would be fine, and
> would not `see' the overlap.   But in a way, this is arguably correct:
> since the designer of `f' didn't forsee the overlap, it shouldn't
> affect the meaning of the function he defined.

If Haskell had explicit imports and exports of instance declarations,
then I could perhaps buy this argument.  But it doesn't.  In Haskell,
all instance declarations defined in a module are always exported;
there's no way to hide instance declarations that are intended to
be private to the module:

| an instance declaration is in scope if and only if a chain of import
| declarations leads to the module containing the instance declaration.

So the user has very little control over which instance declarations
are visible, and a small change in one module, e.g. adding a new import
statement, can easily lead to effects in other modules.
So I don't think it is reasonable to expect that the designer of a function
will be able to forsee the overlap if the overlapping instance declarations
are visible.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to