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
>
http://www.haskell.org/pipermail/libraries/2007-March/007304.html
> added following information to the description of
> updateLookupWithKey:
> 
> The function returns changed value, if it is
updated.
> Returns the original key value if the map entry is
deleted.

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"),
(3,"b")])

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

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

(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.
Thanks,
Andriy


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Libraries mailing list