[Haskell-cafe] EnumSet and EnumMap

Yitzchak Gale gale at sefer.org
Sun Feb 25 18:00:43 EST 2007

Chris Kuklewicz wrote:
>>> There is a performance cost.

I wrote:
>> Are you sure?

> GHC's darcs repostory, at
> http://darcs.haskell.org/packages/base/GHC/Base.lhs

I am talking about Int, not Char. I am comparing standard
libs before and after, not what you can do by hand.

I think the standard libs comparison works out like this:

  No difference in performance, much better interface.

Other Enum instances, such as Char:
  Currently not available at all, you have to use Map
  and Set. So big performance gain.

>> In the meantime, your module are usable now, with
>> very little change to existing code.

> The (EnumMap Char) was not a real gain on
> (Map Char) until I made CharMap and
> added INLINE pragmas and avoided the List.map
> conversions to/from Char.

How about with INLINE but also with the map
conversions (the regular ones, not the unsafe ones).
That is what would be added to the standard libs, and
I would think it should be a gain over Man and Set.
Do you have any numbers?

>> It should certainly be added to the standard
>> libraries...
>> I personally would then stop using
>> IntMap/IntSet for new code...

> Then please enjoy EnumSet and EnumMap.

Thanks - they really are nice.

As a policy, I do try to stick to standard libraries
for stability.


More information about the Libraries mailing list