Fergus Henderson wrote:

> 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.

Well, I'm not sure I buy my argument either....

So, let's assume that overlaps should always apply consistently across modules,
regardless of the visibility of the overlap, so that the programmer doesn't get
surprises by changing an import list somewhere.  I think that it is possible to
enforce this, with some extra bookkeeping.  The compiler would need to keep
track of what context reductions were applied in each module.  Then, if any
program loaded two modules with inconsistent context reductions, a `link error'
would occur (or maybe just a warning).  I'd be more concrete, except that it is
late ;-)

--Jeff

Reply via email to