tel / purescript-intmaps

Big-endian Patricia tree IntMap implementation in Purescript.
7 stars 7 forks source link

IntMap.insert unexpected behaviour #6

Closed clinuxrulz closed 8 years ago

clinuxrulz commented 8 years ago

When we use IntMap.insert on a key that already exists in the IntMap, I would of expected the value at the key to be replaced by the new value, but instead it was retained.

If this is a bug I think the following

insert :: forall a . Int -> a -> IntMap a -> IntMap a
insert = insertWithKey (\_ a _ -> a) 

Needs to be changed to

insert :: forall a . Int -> a -> IntMap a -> IntMap a
insert = insertWithKey (\_ _ a -> a) 
tel commented 8 years ago

Beautiful, thanks.

tel commented 8 years ago

That is the fix—I miswrote it because I was thinking "second argument" and forgot the "key" argument.