Hello Malcolm,
Thursday, November 2, 2006, 12:46:43 AM, you wrote:
> instance Num (Bar z) where
> and
> instance Num (Bar z)
> The former declares that _no_ methods are defined (except for defaults),
> and the latter, with your proposal, that _all_ methods are defined. The
i join to this note. moreover, currently GHC supports "generics for
the masses" that may mean very subtle semantic changes between code generated by these two forms :))
Thank you guys for your responses.
Effectively, every class method has a default implementation: if the programmer does not supply a default implementation, then the the "default" default implementation is undefined.
But, does it make sense to create a class with default methods, but which is also derivable, such that the derived instance declarations are different than if the default implementations are chosen? When would it make sense to allow:
derive instance A B
and
instance A B
and have them both be valid (not at the same time, of course), but mean totally different things? I think it would be very confusing, especially for the innocent user who simply forgets the "derive" psudo-keyword.
Would it be possible to make deriving a special case of defaulting? That is, could we define every derivable class so that every method defaulted, instead of to undefined, to some "deriving magic," perhaps expressible in Template Haskell? Perhaps we could say that all classes that have all their methods defaulted are then derivable?
- Brian