@@ -930,7 +930,7 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
930
930
-- branch vs. branch
931
931
go s ! sz (BitmapIndexed b1 ary1) (BitmapIndexed b2 ary2) =
932
932
let b' = b1 .|. b2
933
- ( dsz, ary') =
933
+ A. RunRes dsz ary' =
934
934
unionArrayByInternal sz
935
935
(go (s+ bitsPerSubkey))
936
936
b1
@@ -939,7 +939,7 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
939
939
ary2
940
940
in (dsz, bitmapIndexedOrFull b' ary')
941
941
go s ! sz (BitmapIndexed b1 ary1) (Full ary2) =
942
- let ( dsz, ary') =
942
+ let A. RunRes dsz ary' =
943
943
unionArrayByInternal sz
944
944
(go (s+ bitsPerSubkey))
945
945
b1
@@ -948,7 +948,7 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
948
948
ary2
949
949
in (dsz, Full ary')
950
950
go s ! sz (Full ary1) (BitmapIndexed b2 ary2) =
951
- let ( dsz, ary') =
951
+ let A. RunRes dsz ary' =
952
952
unionArrayByInternal sz
953
953
(go (s+ bitsPerSubkey))
954
954
fullNodeMask
@@ -957,7 +957,7 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
957
957
ary2
958
958
in (dsz, Full ary')
959
959
go s ! sz (Full ary1) (Full ary2) =
960
- let ( dsz, ary') =
960
+ let A. RunRes dsz ary' =
961
961
unionArrayByInternal sz
962
962
(go (s+ bitsPerSubkey))
963
963
fullNodeMask
@@ -970,8 +970,9 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
970
970
| b1 .&. m2 == 0 = let ary' = A. insert ary1 i t2
971
971
b' = b1 .|. m2
972
972
in (sz, bitmapIndexedOrFull b' ary')
973
- | otherwise = let (dsz, ary') = A. updateWithInternal' ary1 i $ \ st1 ->
974
- go (s+ bitsPerSubkey) sz st1 t2
973
+ | otherwise = let A. RunRes dsz ary' =
974
+ A. updateWithInternal' ary1 i $ \ st1 ->
975
+ go (s+ bitsPerSubkey) sz st1 t2
975
976
in (dsz, BitmapIndexed b1 ary')
976
977
where
977
978
h2 = leafHashCode t2
@@ -981,24 +982,25 @@ unionWithKeyInternal f hm1 (HashMap siz hm2) = go 0 siz hm1 hm2
981
982
| b2 .&. m1 == 0 = let ary' = A. insert ary2 i $! t1
982
983
b' = b2 .|. m1
983
984
in (sz, bitmapIndexedOrFull b' ary')
984
- | otherwise = let (dsz, ary') = A. updateWithInternal' ary2 i $ \ st2 ->
985
- go (s+ bitsPerSubkey) sz t1 st2
985
+ | otherwise = let A. RunRes dsz ary'=
986
+ A. updateWithInternal' ary2 i $ \ st2 ->
987
+ go (s+ bitsPerSubkey) sz t1 st2
986
988
in (dsz, BitmapIndexed b2 ary')
987
989
where
988
990
h1 = leafHashCode t1
989
991
m1 = mask h1 s
990
992
i = sparseIndex b2 m1
991
993
go s ! sz (Full ary1) t2 =
992
- let h2 = leafHashCode t2
993
- i = index h2 s
994
- ( dsz, ary') =
994
+ let h2 = leafHashCode t2
995
+ i = index h2 s
996
+ A. RunRes dsz ary' =
995
997
update16WithInternal' ary1 i $ \ st1 ->
996
998
go (s+ bitsPerSubkey) sz st1 t2
997
999
in (dsz, Full ary')
998
1000
go s ! sz t1 (Full ary2) =
999
- let h1 = leafHashCode t1
1000
- i = index h1 s
1001
- ( dsz, ary') =
1001
+ let h1 = leafHashCode t1
1002
+ i = index h1 s
1003
+ A. RunRes dsz ary' =
1002
1004
update16WithInternal' ary2 i $ \ st2 ->
1003
1005
go (s+ bitsPerSubkey) sz t1 st2
1004
1006
in (dsz, Full ary')
@@ -1053,7 +1055,7 @@ unionArrayByInternal
1053
1055
-> Bitmap
1054
1056
-> A. Array a
1055
1057
-> A. Array a
1056
- -> ( Int , A. Array a )
1058
+ -> A. RunResA a
1057
1059
unionArrayByInternal siz f b1 b2 ary1 ary2 = A. runInternal $ do
1058
1060
let b' = b1 .|. b2
1059
1061
mary <- A. new_ (popCount b')
@@ -1074,7 +1076,7 @@ unionArrayByInternal siz f b1 b2 ary1 ary2 = A.runInternal $ do
1074
1076
A. write mary i =<< A. indexM ary2 i2
1075
1077
go sz (i+ 1 ) (i1 ) (i2+ 1 ) (m `unsafeShiftL` 1 )
1076
1078
d <- go siz 0 0 0 (b' .&. negate b') -- XXX: b' must be non-zero
1077
- return (d, mary)
1079
+ return (A. RunRes d mary)
1078
1080
-- TODO: For the case where b1 .&. b2 == b1, i.e. when one is a
1079
1081
-- subset of the other, we could use a slightly simpler algorithm,
1080
1082
-- where we copy one array, and then update.
@@ -1508,10 +1510,10 @@ update16With' ary idx f = update16 ary idx $! f (A.index ary idx)
1508
1510
{-# INLINE update16With' #-}
1509
1511
1510
1512
-- | /O(n)/ Update the element at the given position in this array, by applying a function to it.
1511
- update16WithInternal' :: A. Array e -> Int -> (e -> (Int , e )) -> ( Int , A. Array e )
1513
+ update16WithInternal' :: A. Array e -> Int -> (e -> (Int , e )) -> A. RunResA e
1512
1514
update16WithInternal' ary idx f =
1513
1515
let (s, x) = f $! A. index ary idx
1514
- in (s, update16 ary idx x)
1516
+ in A. RunRes s ( update16 ary idx x)
1515
1517
{-# INLINE update16WithInternal' #-}
1516
1518
1517
1519
-- | Unsafely clone an array of 16 elements. The length of the input
0 commit comments