3 Dec 00:42
Proposal: Bounded instance for IntSet (ticket #1953)
From: David Benbennick <dbenbenn <at> gmail.com>
Subject: Proposal: Bounded instance for IntSet (ticket #1953)
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2007-12-02 23:45:40 GMT
Subject: Proposal: Bounded instance for IntSet (ticket #1953)
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2007-12-02 23:45:40 GMT
>From http://hackage.haskell.org/trac/ghc/ticket/1953 : I propose to add a Bounded instance to IntSet.hs. IntSet is in Ord, and there are only finitely many instances of IntSet. Therefore there is a min IntSet and a max IntSet. It turns out these bounds are very simple: instance Bounded IntSet where minBound = empty maxBound = singleton maxBound Suggested deadline: December 16, 2007.
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.

One could of course consider to put both instances
into a separate module Data.IntMap.Ord,
so you can choose not to import that
and roll your own instead.
Wolfram
RSS Feed