Hi,

Am Samstag, den 04.06.2011, 14:23 +0200 schrieb Joachim Breitner:
> I was looking into using HashMap in a tool for the Debian Haskell Group
> that currently uses a somewhat large Map, but I found some functions
> missing that I was using:
>  * unions
>  * element
>  * unionWith
>  * mapWithKey

here are naive implementations using the current API, although I guess
better code can be created within unordered-container:

-- Functions from Data.Map missing in Data.HashMap
unions = foldl M.union M.empty
member k = isJust . M.lookup k
unionWith f m1 m2 = M.foldrWithKey (M.insertWith f) m1 m2
mapWithKey f = runIdentity . M.traverseWithKey (\k v -> Identity (f k v))

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
  mail: [email protected] | ICQ# 74513189 | GPG-Key: 4743206C
  JID: [email protected] | http://www.joachim-breitner.de/
  Debian Developer: [email protected]

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to