@@ -215,11 +215,11 @@ module DataList = struct
215
215
let acc = h :: acc in
216
216
linear_merge_fwd (i - 1 ) l ~acc
217
217
| [] ->
218
- failwith " linear_merge_fwd "
218
+ invalid_arg " invalid index "
219
219
else
220
220
l, acc
221
221
222
- let rec linear_merge ?( acc = [] ) i0 p l =
222
+ let rec linear_merge i0 p l ~ acc =
223
223
let l, acc =
224
224
match p with
225
225
| (I (i , _ ) | R i | U (i , _ )) :: _ when i > i0 ->
@@ -229,34 +229,34 @@ module DataList = struct
229
229
in
230
230
match p, l with
231
231
| I (i , x ) :: p , _ ->
232
- linear_merge ~acc i p (x :: l)
232
+ linear_merge i p (x :: l) ~acc
233
233
| R i :: p , _ :: l ->
234
- linear_merge ~acc i p l
234
+ linear_merge i p l ~acc
235
235
| R _ :: _ , [] ->
236
- failwith " ReactiveData.RList.linear_merge: remove from empty "
236
+ invalid_arg " merge: invalid index "
237
237
| U (i , x ) :: p , _ :: l ->
238
- linear_merge ~acc i p (x :: l)
238
+ linear_merge i p (x :: l) ~acc
239
239
| U (_ , _ ) :: _ , [] ->
240
- failwith " ReactiveData.RList.linear_merge: update empty "
240
+ invalid_arg " merge: invalid index "
241
241
| [] , l ->
242
242
List. rev_append acc l
243
243
| X (_ , _ ) :: _ , _ ->
244
- failwith " ReactiveData.RList. linear_merge: X not supported"
244
+ failwith " linear_merge: X not supported"
245
245
246
- let rec linear_mergeable ?( n = 0 ) p =
246
+ let rec linear_mergeable p ~ n =
247
247
assert (n > = 0 );
248
248
match p with
249
249
| (I (i , _ ) | R i | U (i , _ )) :: p when i > = n ->
250
250
(* negative i's ruled out (among others) *)
251
- linear_mergeable ~n: i p
251
+ linear_mergeable p ~n: i
252
252
| _ :: _ ->
253
253
false
254
254
| [] ->
255
255
true
256
256
257
257
let merge p l =
258
- if linear_mergeable p then
259
- linear_merge 0 p l
258
+ if linear_mergeable p ~n: 0 then
259
+ linear_merge 0 p l ~acc: []
260
260
else
261
261
List. fold_left (fun l x -> merge_p x l) l p
262
262
0 commit comments