Skip to content

Data.Map.deleteAt broken with index 0

Take a look at this ghci session:

Prelude> :m Data.Map
Prelude Data.Map> Data.Map.deleteAt 0 (Data.Map.fromList [(0::Int, 0::Int), (1,1), (2, 2), (3, 3)])
fromList []
Prelude Data.Map> Data.Map.elemAt 0 (Data.Map.fromList [(0::Int, 0::Int), (1,1), (2, 2), (3, 3)])
(0,0)

In other words, deleteAt with index 0 deletes *everything* in the map, not just the first element in it.

Prelude Data.Map> Data.Map.deleteAt 1 (Data.Map.fromList [(0::Int, 0::Int), (1,1), (2, 2), (3, 3)])
fromList [(0,0),(2,2),(3,3)]

That appears to work as it should. It seems that there is something wrong with an index of 0.

Trac metadata
Trac field Value
Version 6.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC jgoerzen@complete.org
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information