Data.IntMap API

Jean-Philippe Bernardy jeanphilippe.bernardy at gmail.com
Tue Nov 29 03:42:38 EST 2005


On 11/28/05, Iavor Diatchki <iavor.diatchki at gmail.com> wrote:
> Hello,
> Data.IntMap (distributed with GHC 6.4.1) contains the following instance:
> Ord a => Monoid (IntMap a)
> The instance is defined with mempty = empty, and mappend = union,
> neither of which requires the Ord instances on the values in the map,
> so the 'Ord a' constraint appears unneccessary.

You're right, I seem to be guilty of careless cut and paste from the
corresponding code in Data.Map. I will fix that.

> -Iavor
> PS: Isn't picking union for the monoid class a little arbitrary?

Indeed. The problem is that Monoid is very general and classes have
global scope. Union seemed like a reasonable definition... If it
doesn't fit the algorithm at hand, one can resort to "explicit
dictionnary passing" for emulating local instances.

Cheers,
JP.


More information about the Libraries mailing list