Proposal: Bounded instance for IntSet (ticket #1953)

Henning Thielemann lemming at henning-thielemann.de
Mon Dec 3 07:19:40 EST 2007


On Mon, 3 Dec 2007, Yitzchak Gale wrote:

> David Benbennick wrote:
> > I propose to add a Bounded instance to IntSet.hs.
>
> I am opposed to this proposal, unless someone
> comes up with some important use cases.
>
> Unfortunately, there is still no way to control export
> of instances.

You can put instances into a separate module (and get GHC warnings about
that :-) But it is not sensible to have different instances for the same
type and class, because they will collide sooner or later.

> So libraries should avoid defining instances unless there is a
> compelling reason to do so. We need to be reasonably certain that the
> usefulness of the instance will overwhelm any unforeseen namespace
> pollution problems that it may cause.

I think there is no much sense in defining instances privately in code
that uses a class definition from a library, because the custom instance
in turn may break other modules. In the past it happened for me at each
GHC upgrade, that instances that I defined privately (like Show for
FiniteMap) collide with new instances defined in the imported standard
module.


More information about the Libraries mailing list