Phil Wadler, quoting K. Claesson:
> > At the moment you make an instance of a class that has default definitions
> > for one of its superclasses, and there is no corresponding instance for
> > that class, we implicitly insert the specified default instance. If
> > there are more instances to choose from at that point, we report an error.
> If I read this properly, the intent is to make the meaning of the
> program depend on the order in which it is compiled.
I'm sure that wasn't what Koen intended, but I see Phil's point: it
seems to raise the question of what happens if some _later_ (in the
compilation order) instance declaration gives an explicit definition
of the much-defaulted method, which would of course be the one to
use, and not an error at all. For this reason, I'd guess that the
best that's possible is to report an error at link-time, or as is done
for definitionless methods at present (gah!), run-time.
However, it's at least possible to give a loud warning, or arguably
an error, for things like (Lennart's example):
> class (C1 a, C2 a) => C12 a
unless a new superclass default is given to override the other two.
(Talk about being spoilt for choice.) In this case, though, there's
the difficulty of needing some new notational convention to refer to
either C1's m or C2's m, if that's what one wanted to specify in the
C12 default, which may be wretched excess.
Slainte,
Alex.