``Orphan instances'' should be avoided anyway.

Henning Thielemann lemming at henning-thielemann.de
Wed Aug 13 03:07:48 EDT 2008


On Wed, 13 Aug 2008, Yitzchak Gale wrote:

> Jonathan Cast wrote:
>> If there is no main instance, there should very likely be no instance at
>> all.  We already have named instances...
>> Confusing this with type classes seems mostly redundant to me.
>
> This argument, or something like it, is raised whenever someone
> mentions the need to define multiple instances of a class for the
> same type. And it is correct, theoretically.
>
> But in real life, you often need to write code against existing modules
> that you can't change. When an existing module exports an instance
> that is inconvenient, you can be in deep trouble.
>
> We are desperately in need of a solution to this problem. If not
> Wolfram's "named instances", then at least there must be some
> way to control the import and export of instances, just as we can
> now control the import and export of every other kind of symbol
> binding.

For me it's most often the case that an instance is missing. If there is 
no way to change existing instance definitions, then you must use 
'newtype'. Generalized newtype deriving simplifies to adapt the instances 
you want.


More information about the Libraries mailing list