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

Don Stewart dons at galois.com
Thu Nov 1 14:38:21 EDT 2007


And sounds like we need some QuickCheck properties too!

apa3a:
> 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 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries


More information about the Libraries mailing list