@@ -29,7 +29,7 @@ module A = Belt_Array
29
29
module S = Belt_SortArray
30
30
31
31
external return : 'a -> 'a option = " %identity"
32
- let empty = None
32
+
33
33
external unsafeCoerce : 'a option -> 'a = " %identity"
34
34
35
35
@@ -51,7 +51,7 @@ let create l x d r =
51
51
return { left = l ; key = x ; value = d ; right = r ; height = (if hl > = hr then hl + 1 else hr + 1 )}
52
52
53
53
let singleton x d =
54
- return { left = empty ; key = x; value = d; right = empty ; height = 1 }
54
+ return { left = None ; key = x; value = d; right = None ; height = 1 }
55
55
56
56
let heightGe l r =
57
57
match l, r with
@@ -198,7 +198,7 @@ let forEach n f = forEachU n (fun [@bs] a b -> f a b)
198
198
let rec mapU n f =
199
199
match n with
200
200
None ->
201
- empty
201
+ None
202
202
| Some n ->
203
203
let newLeft = n .left |. mapU f in
204
204
let newD = f n.value [@ bs] in
@@ -210,7 +210,7 @@ let map n f = mapU n (fun[@bs] a -> f a)
210
210
let rec mapWithKeyU n f =
211
211
match n with
212
212
None ->
213
- empty
213
+ None
214
214
| Some n ->
215
215
let key = n.key in
216
216
let newLeft = n .left |. mapWithKeyU f in
@@ -304,7 +304,7 @@ let concatOrJoin t1 v d t2 =
304
304
305
305
let rec keepSharedU n p =
306
306
match n with
307
- None -> empty
307
+ None -> None
308
308
| Some n ->
309
309
(* call [p] in the expected left-to-right order *)
310
310
let {key = v; value = d} = n in
@@ -317,7 +317,7 @@ let keepShared n p = keepSharedU n (fun [@bs] a b -> p a b)
317
317
318
318
let rec keepMapU n p =
319
319
match n with
320
- None -> empty
320
+ None -> None
321
321
| Some n ->
322
322
(* call [p] in the expected left-to-right order *)
323
323
let {key = v; value = d} = n in
@@ -332,7 +332,7 @@ let keepMap n p = keepMapU n (fun[@bs] a b -> p a b)
332
332
333
333
let rec partitionSharedU n p =
334
334
match n with
335
- None -> (empty, empty )
335
+ None -> (None , None )
336
336
| Some n ->
337
337
let {key; value } = n in
338
338
(* call [p] in the expected left-to-right order *)
@@ -499,12 +499,12 @@ let valuesToArray n =
499
499
500
500
let rec fromSortedArrayRevAux arr off len =
501
501
match len with
502
- | 0 -> empty
502
+ | 0 -> None
503
503
| 1 -> let k, v = (A. getUnsafe arr off) in singleton k v
504
504
| 2 ->
505
505
let (x0,y0),(x1,y1) = A. (getUnsafe arr off, getUnsafe arr (off - 1 ) )
506
506
in
507
- return { left = (singleton x0 y0); key = x1; value = y1; height = 2 ; right = empty }
507
+ return { left = (singleton x0 y0); key = x1; value = y1; height = 2 ; right = None }
508
508
| 3 ->
509
509
let (x0,y0),(x1,y1),(x2,y2) =
510
510
A. (getUnsafe arr off,
@@ -526,12 +526,12 @@ let rec fromSortedArrayRevAux arr off len =
526
526
527
527
let rec fromSortedArrayAux arr off len =
528
528
match len with
529
- | 0 -> empty
529
+ | 0 -> None
530
530
| 1 -> let k, v = (A. getUnsafe arr off) in singleton k v
531
531
| 2 ->
532
532
let (x0,y0),(x1,y1) = A. (getUnsafe arr off, getUnsafe arr (off + 1 ) )
533
533
in
534
- return {left = (singleton x0 y0); key = x1 ; value = y1; height = 2 ; right = empty }
534
+ return {left = (singleton x0 y0); key = x1 ; value = y1; height = 2 ; right = None }
535
535
| 3 ->
536
536
let (x0,y0),(x1,y1),(x2,y2) =
537
537
A. (getUnsafe arr off,
@@ -734,7 +734,7 @@ let rec updateMutate (t : _ t) x data ~cmp =
734
734
735
735
let fromArray (xs : _ array ) ~cmp =
736
736
let len = A. length xs in
737
- if len = 0 then empty
737
+ if len = 0 then None
738
738
else
739
739
let next =
740
740
ref (S. strictlySortedLengthU xs
0 commit comments