Data.Map.updateAt problem

Andriy Palamarchuk apa3a at
Wed Jul 18 09:24:03 EDT 2007

I'm currently improving Data.Map documentation.
Behavior of updateAt in this module differs from what I would expect.

The documentation says:

     updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a
     O(log n). Update the element at index. Calls error when an invalid index is used.

So I expected this code:

    let m = fromList [(3,"b"),(5,"a")]
    let f k a = Just "x"
    updateAt f 1 m

to return

    fromList [(3,"b"),(5,"x")]

but it returns

    fromList [(5,"x")]

deleting the key 3.
I tested this using ghci 6.6.

Is this a bug or I missed something here?


Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. 

More information about the Libraries mailing list