Data.Map.mapKeys documentation differs from the actual behavior

Andriy Palamarchuk apa3a at yahoo.com
Fri Jun 29 17:51:17 EDT 2007


I'm currently improving documentation for Data.Map. mapKeys documentation says:

"The size of the result may be smaller if f maps two or more distinct keys to the same new key. In this case the value at the smallest of these keys is retained."

However the implementation retains the value of the *largest* key:

Prelude Data.Map> let map = fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]
Prelude Data.Map> mapKeys (\ _ -> 1) map
{1:="c"}
Prelude Data.Map> mapKeys (\ _ -> 3) map
{3:="c"}

See http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Map.html#v%3AmapKeys

Should I fix the documentation to confirm to the actual function behavior?

Thanks,
Andriy





       
____________________________________________________________________________________Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/


More information about the Libraries mailing list