packages with orphaned instances only

Christian Maeder Christian.Maeder at
Mon Jan 10 17:29:50 CET 2011

Am 09.01.2011 03:18, schrieb Gábor Lehel:
> 2011/1/9 Henning Thielemann <lemming at>:
>> Gábor Lehel schrieb:
>>> I wonder if it might be feasible to add some infrastructural support
>>> for this, e.g. so-called adapter packages, which get installed
>>> automatically when the packages they adapt between are both present?
>>> (Or, thinking further, perhaps even automatic importation of adapter
>>> modules at the language level?)
>> This would be analogous to automatic import of instances at a package level.
>> However the adapter package might import other heavyweight packages that
>> someone may not want to have.
> Yes, that's a good analogy. Basically a way to ensure consistent
> instances not just in a single program, but across all of Hackage
> (modulo opt-out capabilities).

Yes, some infrastructural support is certainly needed to ensure at most
one instance per type and class.

There may be some dispute about which instance to add or if there should
be no instance at all for certain combination (which is hard to enforce).

Changing an instances later could be a serious problem (by subtly
breaking code).

I'm not sure if imports should be automatic, though.

> Presumably the only dependencies for adapter packages would be the two
> packages they are adapting between in almost all cases? Either way,
> the criterium could be that it gets installed automatically if all of
> the dependencies are met. (Though to protect against mischief you'd
> need some safeguards like one of the authors of the adaptee packages
> having to approve it... or perhaps framing them as 'optional' parts of
> existing packages would be better? (Maybe that's already possible with
> cabal configurations / optional dependencies?))
> If we had adapter modules at the language level with automatic
> importation and banned orphan instances outside of them, it would
> solve the import-unsafeness of OverlappingInstances, but instead would
> present a problem for people who don't want an instance imported not
> because they want their own, but simply to prevent accidental usage.

Since instances are always re-exported it is not really possible to
prevent an accidental usage (except by asking the compiler what is used).

In case you're writing your own instances, you want to be warned if they
might clash with instances on hackage.

Cheers Christian

More information about the Libraries mailing list