Proposal: Bounded instance for IntSet (ticket #1953)
Henning Thielemann
lemming at henning-thielemann.de
Mon Dec 3 06:10:04 EST 2007
Fax +49 - 345 - 55 27033
On Mon, 3 Dec 2007 kahl at cas.mcmaster.ca wrote:
> On Sun, 2 Dec 2007, at 23:53:36 +0000, Ross Paterson wrote:
> >
> > On Sun, Dec 02, 2007 at 03:45:40PM -0800, David Benbennick wrote:
> > > 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
> >
> > These are the minimum and maximum under the Ord instance (also for Set),
> > but what is the intuition behind that ordering?
>
> In my opinion, the class ``Ord'' is not particularly heavy on intuition;
> it just provides an interface to ``the standard linear ordering''
> for each of its types,
> so that these types can be used for keys in Data.Map's, etc.
>
> Not many types are naturally understood as linearly ordered,
> but most of those types should still be usable for keys in maps.
I already told about by scepticism about using Ord for keys of maps and
sets:
http://www.haskell.org/pipermail/libraries/2007-April/007411.html
More information about the Libraries
mailing list