3.2 Duplicate instances

Suppose two modules, M1 and M2 both contain an identical standalone deriving declaration

derivingShow T

Then, can you import M1 and M2 into another module X and use show on values of type T, or will you get an overlapping instance error? Since both instances are derived in the very same way, their code must be identical, so arguably we can choose either. (There is some duplicated code of course.)

This situation is expected to be common, as the main use of the standalone feature is to obtain derived instances that were omitted when the data type was defined.

But, that means whether or not an instance was derived is now part of the module's. Programs would be able to use this (mis)feature to perform a compile-time check and execute code differently depending on whether any given instance is derived or hand-coded:

module MA(A)wheredata A = A derivingShowmodule MB(B)wheredata B = B derivingShowmodule MC whereimport MA
import MB
-- verify that the A and B Show instances were derived-- (they need to be derived to ensure the output can-- be parsed in our non-Haskell code).derivinginstanceShow A
derivinginstanceShow B

The writer of MC already knows that MA and MB defined instances of Show for A and B. He just wants to ensure that nobody changes either module to use a non-derived instance; if someone does try to use a non-derived instance:

module MA(A)wheredata A = A
instanceShow A whereshow_="a"

then they will get an overlapping instance error in MC.

The result is that programs would be able to require, for any Class, not just that an instance of the class was defined for a type, but that a /derived/ instance was defined. Is this good?