Data and Typeable instances
duncan.coutts at worc.ox.ac.uk
Sun Apr 19 17:41:25 EDT 2009
On Sun, 2009-04-19 at 13:58 -0700, Ashley Yakeley wrote:
> I will not expose any private structure of types via instances of the
> Data class. I can't see what benefits SYB brings that it outweighs such
> loss of abstraction. And if someone else wants to shoot themselves in
> the foot by using standalone deriving, that's their problem.
It's ok, abstraction is preserved by standalone deriving. You can only
derive for types where you can import the constructors.
> However, this might not be an issue, as I believe all the constructors
> of all or almost all types in time are public. If it is possible for a
> user of time to hand-write instances of Data using only what time
> exposes, then it is safe to include those instances in the package.
Right, that seems like a sensible solution, that is to include Data
instances that preserve the abstraction. As you say, that can be tested
by initially writing the instances outside the package so that you can
be sure it's only using the public interface.
More information about the Libraries