[Haskell-cafe] Announce: EnumMap-0.0.1
John Van Enk
vanenkj at gmail.com
Wed Aug 12 13:03:55 EDT 2009
> EnumMap silently passes this responsibility to the user, without even a note in the documentation.
Like I've said, I made no modifications to the documentation other
than replacing IntMap with EnumMap. Should the community show more
interest in the EnumMap, such a change will show up in the docs.
On Wed, Aug 12, 2009 at 12:58 PM, David Menendez<dave at zednenem.com> wrote:
> On Wed, Aug 12, 2009 at 12:07 PM, John Van Enk<vanenkj at gmail.com> wrote:
>> On Wed, Aug 12, 2009 at 11:34 AM, David Menendez<dave at zednenem.com> wrote:
>>> On Wed, Aug 12, 2009 at 9:16 AM, John Van Enk<vanenkj at gmail.com> wrote:
>>>> On Wed, Aug 12, 2009 at 2:09 AM, Ketil Malde<ketil at malde.org> wrote:
>>>>> And perhaps also note that you will get exceptions for values outside
>>>>> the Enum range.
>>>> I'd think that part is obvious.
>>> That depends on what "outside the Enum range" means. You'll get an
>>> exception if you somehow get an Int key in the map which doesn't
>>> correspond to any value in the enum...
>> We should be protected by the type system against unmatched Int's in
>> the map as long as you have sane Enum instances.
> One would hope so.
>>> ... but you don't get an exception if
>>> you try to pass in, say, a large Integer.
>>> Prelude> fromEnum (2^32)
>>> In essence, you're using Enum as a hash function, but not making any
>>> provision for hash collisions.
>> Unless I'm mistaken, the Enum typeclass _is_ a hash function who's
>> keyspace is the range of Int that doesn't make any provisions for
> Hash functions traditionally map integers to integers, so I would
> describe fromEnum as "like" a hash function, but that's not important.
> And yes, hash functions collide, which is why hash tables employ
> various methods for distinguishing keys that hash to the same values.
> EnumMap silently passes this responsibility to the user, without even
> a note in the documentation.
> Dave Menendez <dave at zednenem.com>
More information about the Haskell-Cafe