Lennart says of superclass defaults:
> there is an ambiguity problem when there are several different
> defaults available. E.g.
> 
> class C a where
>     m :: a -> Int
> 
> class (C a) => C1 a where
>     m x = 1
> 
> class (C a) => C2 a where
>     m x = 2

> I guess you could "solve" it by forbidding this case.

Arguably this is the wrong behaviour, as the definitions are both
defaults, so it should be possible to override both, or one with the
other.  Granted, though, some quasi-arbitrary resolution of the
above, such as a textual order sensitive one, would be a little
inobvious to the casual reader, so perhaps in such cases (i.e.,
when instances for some type of both C1 and C2 are declared, or if
both occur in the same class context), it should be require that the
desired one be specified.

As in, say:

instance C T where
        m = 1

or:

class (C1 a, C2 a) => C12 a where
        m x = C1.m x

or some such notion.

Alex.




Reply via email to