Relaxin the PVP with regards to adding instances

Henning Thielemann lemming at henning-thielemann.de
Tue Sep 11 21:10:07 CEST 2012


On Tue, 11 Sep 2012, Ian Lynagh wrote:

> On Tue, Sep 11, 2012 at 02:11:36PM -0400, Edward Kmett wrote:
>>
>> I often add instances for my own classes to my own types, and the need for
>> a major version bump can ripple through 20+ packages and then out into 3rd
>> party packages.
>
> If you're adding the instance at the same time as adding either the type
> or the class, then a major bump shouldn't be needed.
>
> However, if you often find that you need to add an instance for an
> existing class+type, then isn't it plausible that the authors of these
> 3rd party packages would find they need the instances first, so add
> orphan instances?

If a package user needs a new instance he should propose to add the 
instance the package author. Sometimes the package user and the package 
author find out this way that there is no unique natural instance. If this 
is the case or the package author does not respond fast enough then the 
package user should create a newtype wrapper. Adding an orphan instance is 
not a solution since it may not only clash with new instances in the 
original package but also with orphan instances from other packages.

Orphan instances are really only acceptable if there is an agreed natural 
instance but there is no package where to put it into naturally.

> A "no orphan instance" rule could work, but note that not only could you
> not use orphan instances yourself, but you also couldn't use any
> packages that contain orphan instances. I think that to make that work
> in practice we'd have to make orphan instances an error, unless either
> the type or the class is in the current package.

No rule of the PVP is currently enforced by the compiler, so why should 
orphan instances be an error? GHC warns about them, for me this is enough.



More information about the Libraries mailing list