[Haskell-cafe] Announce: EnumMap-0.0.1

Ketil Malde ketil at malde.org
Wed Aug 12 02:09:54 EDT 2009

Felipe Lessa <felipe.lessa at gmail.com> writes:

>> There are some funky Enum instances around:

> IMO it's implicit that keys overwrite eachother whenever their
> 'fromEnum' is equal, however that may be spoken in the docs.

I couldn't find anything explicit in the documentation.  I'd suggest a
clear note at the top, dismissing the (IMO natural) notion that
"EnumMap k v" behaves like "Map k v" (which was true for IntMap and
Map Int, I believe).  

And perhaps also note that you will get exceptions for values outside
the Enum range.

It strikes me that using Bits instead of Enum might be more likely to
be what people want in many cases - but perhaps that would be too slow?
Also that Enum really should map to Integer, but again, that's a speed

One could also question the sanity of using e.g. floating point values
as keys, but Map supports this, so who am I to judge.

(Also, a minor documentation niggle is that Haskell only guarantees 30
bits for an Int, it's GHC that uses Ints of 32 and 64 bits.  One could
argue that it is the report that should be fixed here, unless one can
imagine a program that depends on correct modulo arithmetic with an
unknown quotient.)


¹ This of course migth give the careless reader of the Report the
impression that the Haskell community values speed over correctness,
and thus that we actually are aiming for popularity and mainstream
recognition after all.
If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list