@@ -757,7 +757,7 @@ insert' h0 k0 v0 m0 = go h0 k0 v0 0 m0
757
757
else Full (update16 ary i st')
758
758
where i = index h s
759
759
go h k x s t@ (Collision hy v)
760
- | h == hy = Collision h (updateOrSnocWith const k x v)
760
+ | h == hy = Collision h (updateOrSnocWith ( \ a _ -> ( # a # )) k x v)
761
761
| otherwise = go h k x s $ BitmapIndexed (mask hy s) (A. singleton t)
762
762
{-# INLINABLE insert' #-}
763
763
@@ -880,7 +880,7 @@ unsafeInsert k0 v0 m0 = runST (go h0 k0 v0 0 m0)
880
880
return t
881
881
where i = index h s
882
882
go h k x s t@ (Collision hy v)
883
- | h == hy = return $! Collision h (updateOrSnocWith const k x v)
883
+ | h == hy = return $! Collision h (updateOrSnocWith ( \ a _ -> ( # a # )) k x v)
884
884
| otherwise = go h k x s $ BitmapIndexed (mask hy s) (A. singleton t)
885
885
{-# INLINABLE unsafeInsert #-}
886
886
@@ -1026,7 +1026,7 @@ unsafeInsertWith f k0 v0 m0 = runST (go h0 k0 v0 0 m0)
1026
1026
return t
1027
1027
where i = index h s
1028
1028
go h k x s t@ (Collision hy v)
1029
- | h == hy = return $! Collision h (updateOrSnocWith f k x v)
1029
+ | h == hy = return $! Collision h (updateOrSnocWith ( \ a b -> ( # f a b # )) k x v)
1030
1030
| otherwise = go h k x s $ BitmapIndexed (mask hy s) (A. singleton t)
1031
1031
{-# INLINABLE unsafeInsertWith #-}
1032
1032
@@ -1394,10 +1394,10 @@ unionWithKey f = go 0
1394
1394
else collision h1 l1 l2
1395
1395
| otherwise = goDifferentHash s h1 h2 t1 t2
1396
1396
go s t1@ (Leaf h1 (L k1 v1)) t2@ (Collision h2 ls2)
1397
- | h1 == h2 = Collision h1 (updateOrSnocWithKey f k1 v1 ls2)
1397
+ | h1 == h2 = Collision h1 (updateOrSnocWithKey ( \ k a b -> ( # f k a b # )) k1 v1 ls2)
1398
1398
| otherwise = goDifferentHash s h1 h2 t1 t2
1399
1399
go s t1@ (Collision h1 ls1) t2@ (Leaf h2 (L k2 v2))
1400
- | h1 == h2 = Collision h1 (updateOrSnocWithKey (flip . f ) k2 v2 ls1)
1400
+ | h1 == h2 = Collision h1 (updateOrSnocWithKey (\ k a b -> ( # f k b a # ) ) k2 v2 ls1)
1401
1401
| otherwise = goDifferentHash s h1 h2 t1 t2
1402
1402
go s t1@ (Collision h1 ls1) t2@ (Collision h2 ls2)
1403
1403
| h1 == h2 = Collision h1 (updateOrConcatWithKey f ls1 ls2)
@@ -1932,12 +1932,12 @@ updateWith# f k0 ary0 = go k0 ary0 0 (A.length ary0)
1932
1932
| otherwise -> go k ary (i+ 1 ) n
1933
1933
{-# INLINABLE updateWith# #-}
1934
1934
1935
- updateOrSnocWith :: Eq k => (v -> v -> v ) -> k -> v -> A. Array (Leaf k v )
1935
+ updateOrSnocWith :: Eq k => (v -> v -> ( # v # ) ) -> k -> v -> A. Array (Leaf k v )
1936
1936
-> A. Array (Leaf k v )
1937
1937
updateOrSnocWith f = updateOrSnocWithKey (const f)
1938
1938
{-# INLINABLE updateOrSnocWith #-}
1939
1939
1940
- updateOrSnocWithKey :: Eq k => (k -> v -> v -> v ) -> k -> v -> A. Array (Leaf k v )
1940
+ updateOrSnocWithKey :: Eq k => (k -> v -> v -> ( # v # ) ) -> k -> v -> A. Array (Leaf k v )
1941
1941
-> A. Array (Leaf k v )
1942
1942
updateOrSnocWithKey f k0 v0 ary0 = go k0 v0 ary0 0 (A. length ary0)
1943
1943
where
@@ -1949,7 +1949,7 @@ updateOrSnocWithKey f k0 v0 ary0 = go k0 v0 ary0 0 (A.length ary0)
1949
1949
A. write mary n (L k v)
1950
1950
return mary
1951
1951
| otherwise = case A. index ary i of
1952
- (L kx y) | k == kx - > A. update ary i (L k (f k v y) )
1952
+ (L kx y) | k == kx, ( # v2 # ) <- f k v y - > A. update ary i (L k v2 )
1953
1953
| otherwise -> go k v ary (i+ 1 ) n
1954
1954
{-# INLINABLE updateOrSnocWithKey #-}
1955
1955
0 commit comments