[Haskell-cafe] A typeclass for Data.Map etc?

Mark Wotton mwotton at gmail.com
Thu Feb 19 08:46:16 EST 2009

On Thu, Feb 19, 2009 at 9:51 PM, Eugene Kirpichov <ekirpichov at gmail.com> wrote:
> Greetings,
> Is there a typeclass for mappings with a Data.Map-like interface, with
> stuff like: empty, insert, insertWithKey, unionWith etc. ?
> And, probably, a similar typeclass for mutable mappings like Data.Hashtable.
> Looks like such a thing would be useful; as for now, I see at least
> two applications: Data.Map and Data.Trie (bytestring-trie) - it's a
> pity that they have rather similar interfaces, but the latter lacks
> many methods and some are named in a different way. Also, Data.Map has
> some inconsistensies, too: for instance, it has an insertWith' but
> lacks a unionWith'. "One typeclass for all" would eliminate these
> inconsistencies.
> I'm asking mainly because I've been wondering why noone has yet
> written a mutable hashtable package with a MArray-like interface, I
> wrote a small thing myself and I am unsure as to what interface it
> should have.

Probably not adding anything terribly useful to this except to say
that it'd be useful to me too - I've written a binding to a perfect
hashing library (PerfectHash on hackage) which implements only
'fromList' and 'lookup', so a slightly more fine-grained type class
hierarchy would be nice. (This particular implementation is useful
when you have a lot of keys, but all known at run-time.)


A UNIX signature isn't a return address, it's the ASCII equivalent of a
black velvet clown painting. It's a rectangle of carets surrounding a
quote from a literary giant of weeniedom like Heinlein or Dr. Who.
        -- Chris Maeda

More information about the Haskell-Cafe mailing list