From e8fea177552a0032768a1a85e347cf2b8b5cf921 Mon Sep 17 00:00:00 2001
From: Bertram Felgenhauer <int-e@gmx.de>
Date: Wed, 18 Jul 2007 15:03:40 +0000
Subject: [PATCH] fix Data.Map.updateAt See
 http://haskell.org/pipermail/libraries/2007-July/007785.html for a piece of
 code triggering the bug. updateAt threw away parts of the tree making up the
 map.

---
 Data/Map.hs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Data/Map.hs b/Data/Map.hs
index 399f74c7..b8fcf717 100644
--- a/Data/Map.hs
+++ b/Data/Map.hs
@@ -523,8 +523,8 @@ updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a
 updateAt f i Tip  = error "Map.updateAt: index out of range"
 updateAt f i (Bin sx kx x l r)
   = case compare i sizeL of
-      LT -> updateAt f i l
-      GT -> updateAt f (i-sizeL-1) r
+      LT -> balance kx x (updateAt f i l) r
+      GT -> balance kx x l (updateAt f (i-sizeL-1) r)
       EQ -> case f kx x of
               Just x' -> Bin sx kx x' l r
               Nothing -> glue l r
-- 
GitLab