updateLookupWithKey bug? Was: Data.Map, Data.IntMap documentation (1611)

Andriy Palamarchuk apa3a at yahoo.com
Thu Nov 1 14:37:17 EDT 2007

I started to update documentation for Data.IntMap. I
found a discrepancy between the modules'
updateLookupWithKey behavior right in the area brought
to my attention earlier:

--- Andriy Palamarchuk <apa3a at yahoo.com> wrote:

> * As per
> added following information to the description of
> updateLookupWithKey:
> The function returns changed value, if it is
> Returns the original key value if the map entry is

The test case:

> :m Data.Map
> let f k x = if x == "a" then Just ((show k) ++ ":new
a") else Nothing
> updateLookupWithKey f 5 (fromList [(5,"a"),

(Just "5:new a",fromList [(3,"b"),(5,"5:new a")])

> :m Data.IntMap
> updateLookupWithKey f 5 (fromList [(5,"a"),

(Just "a",fromList [(3,"b"),(5,"5:new a")])

The problem here is that Data.Map.updateLookupWithKey
returns the *updated* value, but
Data.IntMap.updateLookupWithKey returns the value
*before* update.

Please agree on the behavior, fix the bug and let me
know what to write in the docs.

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the Libraries mailing list