Unordered map
Aaron Denney
wnoise at ofb.net
Fri Aug 1 05:00:41 EDT 2008
On 2008-07-29, Andrew Wagner <wagner.andrew at gmail.com> wrote:
> Well, it wouldn't need to literally implement Ord. It would just need
> to do the same operations as Data.Map does, except without the
> efficiency you get from Data.Map because you can assume an Ord
> instance. One way to do it is to simply internally store the data as
> an ordered [(a,k)], for example. Not efficient, but you get the same
> interface as Map.
Yes, but then you need to check tha you have the right one, which means
you need the context "Eq a". If you're going to make users write an
equality function, making them write an ordering adds little effort, and
a reasonable amount of gain. Usually.
--
Aaron Denney
-><-
More information about the Libraries
mailing list