@@ -82,16 +82,18 @@ module String = Belt_MapString
82
82
module Dict = Belt_MapDict
83
83
84
84
85
- type ('key,'value,'identity) t
85
+ type ('key, 'value, 'identity) t
86
86
(* * [('key, 'identity) t]
87
87
88
- ['key] is the element type
88
+ ['key] is the field type
89
+
90
+ ['value] is the element type
89
91
90
92
['identity] the identity of the collection
91
93
*)
92
94
93
95
94
- type ('key, 'id ) id = ('key , 'id ) Belt_Id .comparable
96
+ type ('key, 'id) id = ('key , 'id ) Belt_Id .comparable
95
97
(* * The identity needed for making an empty map*)
96
98
97
99
@@ -118,7 +120,7 @@ type ('key, 'id ) id = ('key, 'id) Belt_Id.comparable
118
120
should only export [Belt_Id.t] or [Belt_Id.cmp] instead *)
119
121
120
122
121
- val make : id :('k , 'id ) id -> ('k , 'a , 'id ) t
123
+ val make : id :('k , 'id ) id -> ('k , 'v , 'id ) t
122
124
(* * [make ~id]
123
125
124
126
@example {[
@@ -137,7 +139,7 @@ val isEmpty: _ t -> bool
137
139
]}
138
140
*)
139
141
140
- val has : ('k , 'a , 'id ) t -> 'k -> bool
142
+ val has : ('k , 'v , 'id ) t -> 'k -> bool
141
143
(* * [has s k]
142
144
143
145
@example {[
@@ -164,22 +166,22 @@ val cmp:
164
166
*)
165
167
166
168
val eqU :
167
- ('k , 'a , 'id ) t ->
168
- ('k , 'a , 'id ) t ->
169
- ('a -> 'a -> bool [@ bs]) ->
169
+ ('k , 'v , 'id ) t ->
170
+ ('k , 'v , 'id ) t ->
171
+ ('v -> 'v -> bool [@ bs]) ->
170
172
bool
171
173
val eq :
172
- ('k , 'a , 'id ) t ->
173
- ('k , 'a , 'id ) t ->
174
- ('a -> 'a -> bool ) ->
174
+ ('k , 'v , 'id ) t ->
175
+ ('k , 'v , 'id ) t ->
176
+ ('v -> 'v -> bool ) ->
175
177
bool
176
178
(* * [eq m1 m2 veq] tests whether the maps [m1] and [m2] are
177
179
equal, that is, contain equal keys and associate them with
178
180
equal data. [veq] is the equality predicate used to compare
179
181
the data associated with the keys. *)
180
182
181
- val forEachU : ('k , 'a , 'id ) t -> ('k -> 'a -> unit [@ bs]) -> unit
182
- val forEach : ('k , 'a , 'id ) t -> ('k -> 'a -> unit ) -> unit
183
+ val forEachU : ('k , 'v , 'id ) t -> ('k -> 'v -> unit [@ bs]) -> unit
184
+ val forEach : ('k , 'v , 'id ) t -> ('k -> 'v -> unit ) -> unit
183
185
(* * [forEach m f] applies [f] to all bindings in map [m].
184
186
[f] receives the 'k as first argument, and the associated value
185
187
as second argument. The bindings are passed to [f] in increasing
@@ -197,8 +199,8 @@ val forEach: ('k, 'a, 'id) t -> ('k -> 'a -> unit) -> unit
197
199
]}
198
200
*)
199
201
200
- val reduceU : ('k , 'a , 'id ) t -> 'b -> ( 'b -> 'k -> 'a -> 'b [@ bs]) -> 'b
201
- val reduce : ('k , 'a , 'id ) t -> 'acc -> ('acc -> 'k -> 'a -> 'acc ) -> 'acc
202
+ val reduceU : ('k , 'v , 'id ) t -> 'acc -> ( 'acc -> 'k -> 'v -> 'acc [@ bs]) -> 'acc
203
+ val reduce : ('k , 'v , 'id ) t -> 'acc -> ('acc -> 'k -> 'v -> 'acc ) -> 'acc
202
204
(* * [reduce m a f] computes [(f kN dN ... (f k1 d1 a)...)],
203
205
where [k1 ... kN] are the keys of all bindings in [m]
204
206
(in increasing order), and [d1 ... dN] are the associated data.
@@ -212,17 +214,17 @@ val reduce: ('k, 'a, 'id) t -> 'acc -> ('acc -> 'k -> 'a -> 'acc) -> 'acc
212
214
]}
213
215
*)
214
216
215
- val everyU : ('k , 'a , 'id ) t -> ('k -> 'a -> bool [@ bs]) -> bool
216
- val every : ('k , 'a , 'id ) t -> ('k -> 'a -> bool ) -> bool
217
+ val everyU : ('k , 'v , 'id ) t -> ('k -> 'v -> bool [@ bs]) -> bool
218
+ val every : ('k , 'v , 'id ) t -> ('k -> 'v -> bool ) -> bool
217
219
(* * [every m p] checks if all the bindings of the map
218
220
satisfy the predicate [p]. Order unspecified *)
219
221
220
- val someU : ('k , 'a , 'id ) t -> ('k -> 'a -> bool [@ bs]) -> bool
221
- val some : ('k , 'a , 'id ) t -> ('k -> 'a -> bool ) -> bool
222
+ val someU : ('k , 'v , 'id ) t -> ('k -> 'v -> bool [@ bs]) -> bool
223
+ val some : ('k , 'v , 'id ) t -> ('k -> 'v -> bool ) -> bool
222
224
(* * [some m p] checks if at least one binding of the map
223
225
satisfy the predicate [p]. Order unspecified *)
224
226
225
- val size : ('k , 'a , 'id ) t -> int
227
+ val size : ('k , 'v , 'id ) t -> int
226
228
(* * [size s]
227
229
228
230
@example {[
@@ -231,7 +233,7 @@ val size: ('k, 'a, 'id) t -> int
231
233
size (ofArray [2,"2"; 2,"1"; 3,"3"] ~id:(module IntCmp)) = 2 ;;
232
234
]}
233
235
*)
234
- val toArray : ('k , 'a , 'id ) t -> ('k * 'a ) array
236
+ val toArray : ('k , 'v , 'id ) t -> ('k * 'v ) array
235
237
(* * [toArray s]
236
238
237
239
@example {[
@@ -241,21 +243,21 @@ val toArray: ('k, 'a, 'id) t -> ('k * 'a) array
241
243
]}
242
244
243
245
*)
244
- val toList : ('k , 'a , 'id ) t -> ('k * 'a ) list
246
+ val toList : ('k , 'v , 'id ) t -> ('k * 'v ) list
245
247
(* * In increasing order
246
248
247
249
{b See} {!toArray}
248
250
*)
249
251
250
- val ofArray : ('k * 'a ) array -> id :('k ,'id ) id -> ('k ,'a ,'id) t
252
+ val ofArray : ('k * 'v ) array -> id :('k ,'id ) id -> ('k ,'v ,'id) t
251
253
(* * [ofArray kvs ~id]
252
254
@example {[
253
255
module IntCmp =
254
256
(val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));;
255
257
toArray (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [1,"1";2,"2";3,"3"]
256
258
]}
257
259
*)
258
- val keysToArray : ('k , 'a , 'id ) t -> 'k array
260
+ val keysToArray : ('k , 'v , 'id ) t -> 'k array
259
261
(* * [keysToArray s]
260
262
261
263
@example {[
@@ -265,7 +267,7 @@ val keysToArray: ('k, 'a, 'id) t -> 'k array
265
267
[|1;2;3|];;
266
268
]}
267
269
*)
268
- val valuesToArray : ('k , 'a , 'id ) t -> 'a array
270
+ val valuesToArray : ('k , 'v , 'id ) t -> 'v array
269
271
(* * [valuesToArray s]
270
272
271
273
@example {[
@@ -293,24 +295,24 @@ val maxKey: ('k, _, _) t -> 'k option
293
295
val maxKeyUndefined : ('k , _ , _ ) t -> 'k Js .undefined
294
296
(* * {b See} {!maxKey} *)
295
297
296
- val minimum : ('k , 'a , _ ) t -> ('k * 'a ) option
298
+ val minimum : ('k , 'v , _ ) t -> ('k * 'v ) option
297
299
(* * [minimum s]
298
300
@return thte minimum key value pair, None if not exist
299
301
*)
300
302
301
- val minUndefined : ('k , 'a , _ ) t -> ('k * 'a ) Js .undefined
303
+ val minUndefined : ('k , 'v , _ ) t -> ('k * 'v ) Js .undefined
302
304
(* * {b See} {!minimum} *)
303
305
304
- val maximum : ('k , 'a , _ ) t -> ('k * 'a ) option
306
+ val maximum : ('k , 'v , _ ) t -> ('k * 'v ) option
305
307
(* * [maximum s]
306
308
@return thte maximum key value pair, None if not exist
307
309
*)
308
310
309
- val maxUndefined :('k , 'a , _ ) t -> ('k * 'a ) Js .undefined
311
+ val maxUndefined :('k , 'v , _ ) t -> ('k * 'v ) Js .undefined
310
312
(* * {b See} {!maximum}
311
313
*)
312
314
313
- val get : ('k , 'a , 'id ) t -> 'k -> 'a option
315
+ val get : ('k , 'v , 'id ) t -> 'k -> 'v option
314
316
(* * [get s k]
315
317
316
318
@example {[
@@ -323,21 +325,21 @@ val get: ('k, 'a, 'id) t -> 'k -> 'a option
323
325
]}
324
326
*)
325
327
326
- val getUndefined : ('k , 'a , 'id ) t -> 'k -> 'a Js .undefined
328
+ val getUndefined : ('k , 'v , 'id ) t -> 'k -> 'v Js .undefined
327
329
(* * {b See} {!get}
328
330
329
331
@return [undefined] when not found
330
332
*)
331
333
val getWithDefault :
332
- ('k , 'a , 'id ) t -> 'k -> 'a -> 'a
334
+ ('k , 'v , 'id ) t -> 'k -> 'v -> 'v
333
335
(* * [getWithDefault s k default]
334
336
335
337
{b See} {!get}
336
338
337
339
@return [default] when [k] is not found
338
340
339
341
*)
340
- val getExn : ('k , 'a , 'id ) t -> 'k -> 'a
342
+ val getExn : ('k , 'v , 'id ) t -> 'k -> 'v
341
343
(* * [getExn s k]
342
344
343
345
{b See} {!getExn}
@@ -347,7 +349,7 @@ val getExn: ('k, 'a, 'id) t -> 'k -> 'a
347
349
348
350
(* ***************************************************************************)
349
351
350
- val remove : ('k , 'a , 'id ) t -> 'k -> ('k , 'a , 'id ) t
352
+ val remove : ('k , 'v , 'id ) t -> 'k -> ('k , 'v , 'id ) t
351
353
(* * [remove m x] when [x] is not in [m], [m] is returned reference unchanged.
352
354
353
355
@example {[
@@ -364,7 +366,7 @@ val remove: ('k, 'a, 'id) t -> 'k -> ('k, 'a, 'id) t
364
366
365
367
*)
366
368
367
- val removeMany : ('k , 'a , 'id ) t -> 'k array -> ('k , 'a , 'id ) t
369
+ val removeMany : ('k , 'v , 'id ) t -> 'k array -> ('k , 'v , 'id ) t
368
370
(* * [removeMany s xs]
369
371
370
372
Removing each of [xs] to [s], note unlike {!remove},
@@ -373,7 +375,7 @@ val removeMany: ('k, 'a, 'id) t -> 'k array -> ('k, 'a, 'id) t
373
375
*)
374
376
375
377
val set :
376
- ('k , 'a , 'id ) t -> 'k -> 'a -> ('k , 'a , 'id ) t
378
+ ('k , 'v , 'id ) t -> 'k -> 'v -> ('k , 'v , 'id ) t
377
379
(* * [set m x y ] returns a map containing the same bindings as
378
380
[m], with a new binding of [x] to [y]. If [x] was already bound
379
381
in [m], its previous binding disappears.
@@ -390,8 +392,8 @@ val set:
390
392
]}
391
393
*)
392
394
393
- val updateU : ('k , 'a , 'id ) t -> 'k -> ('a option -> 'a option [@ bs]) -> ('k , 'a , 'id ) t
394
- val update : ('k , 'a , 'id ) t -> 'k -> ('a option -> 'a option ) -> ('k , 'a , 'id ) t
395
+ val updateU : ('k , 'v , 'id ) t -> 'k -> ('v option -> 'v option [@ bs]) -> ('k , 'v , 'id ) t
396
+ val update : ('k , 'v , 'id ) t -> 'k -> ('v option -> 'v option ) -> ('k , 'v , 'id ) t
395
397
(* * [update m x f] returns a map containing the same bindings as
396
398
[m], except for the binding of [x].
397
399
Depending on the value of
@@ -402,7 +404,7 @@ val update: ('k, 'a, 'id) t -> 'k -> ('a option -> 'a option) -> ('k, 'a, 'id) t
402
404
*)
403
405
404
406
val mergeMany :
405
- ('k , 'a , 'id ) t -> ('k * 'a ) array -> ('k , 'a , 'id ) t
407
+ ('k , 'v , 'id ) t -> ('k * 'v ) array -> ('k , 'v , 'id ) t
406
408
(* * [mergeMany s xs]
407
409
408
410
Adding each of [xs] to [s], note unlike {!add},
@@ -411,49 +413,49 @@ val mergeMany:
411
413
*)
412
414
413
415
val mergeU :
414
- ('k , 'a , 'id ) t ->
415
- ('k , 'b , 'id) t ->
416
- ('k -> 'a option -> 'b option -> 'c option [@ bs]) ->
417
- ('k , 'c , 'id) t
416
+ ('k , 'v , 'id ) t ->
417
+ ('k , 'v2 , 'id ) t ->
418
+ ('k -> 'v option -> 'v2 option -> 'v3 option [@ bs]) ->
419
+ ('k , 'v3 , 'id ) t
418
420
val merge :
419
- ('k , 'a , 'id ) t ->
420
- ('k , 'b , 'id) t ->
421
- ('k -> 'a option -> 'b option -> 'c option ) ->
422
- ('k , 'c , 'id) t
421
+ ('k , 'v , 'id ) t ->
422
+ ('k , 'v2 , 'id ) t ->
423
+ ('k -> 'v option -> 'v2 option -> 'v3 option ) ->
424
+ ('k , 'v3 , 'id ) t
423
425
(* * [merge m1 m2 f] computes a map whose keys is a subset of keys of [m1]
424
426
and of [m2]. The presence of each such binding, and the corresponding
425
427
value, is determined with the function [f].
426
428
*)
427
429
428
430
429
431
val keepU :
430
- ('k , 'a , 'id ) t ->
431
- ('k -> 'a -> bool [@ bs]) ->
432
- ('k , 'a , 'id ) t
432
+ ('k , 'v , 'id ) t ->
433
+ ('k -> 'v -> bool [@ bs]) ->
434
+ ('k , 'v , 'id ) t
433
435
val keep :
434
- ('k , 'a , 'id ) t ->
435
- ('k -> 'a -> bool ) ->
436
- ('k , 'a , 'id ) t
436
+ ('k , 'v , 'id ) t ->
437
+ ('k -> 'v -> bool ) ->
438
+ ('k , 'v , 'id ) t
437
439
(* * [keep m p] returns the map with all the bindings in [m]
438
440
that satisfy predicate [p]. *)
439
441
440
442
val partitionU :
441
- ('k , 'a , 'id ) t ->
442
- ('k -> 'a -> bool [@ bs]) ->
443
- ('k , 'a , 'id ) t * ('k , 'a , 'id ) t
443
+ ('k , 'v , 'id ) t ->
444
+ ('k -> 'v -> bool [@ bs]) ->
445
+ ('k , 'v , 'id ) t * ('k , 'v , 'id ) t
444
446
val partition :
445
- ('k , 'a , 'id ) t ->
446
- ('k -> 'a -> bool ) ->
447
- ('k , 'a , 'id ) t * ('k , 'a , 'id ) t
447
+ ('k , 'v , 'id ) t ->
448
+ ('k -> 'v -> bool ) ->
449
+ ('k , 'v , 'id ) t * ('k , 'v , 'id ) t
448
450
(* * [partition m p] returns a pair of maps [(m1, m2)], where
449
451
[m1] contains all the bindings of [s] that satisfy the
450
452
predicate [p], and [m2] is the map with all the bindings of
451
453
[s] that do not satisfy [p].
452
454
*)
453
455
454
456
val split :
455
- ('k , 'a , 'id ) t -> 'k ->
456
- (('k , 'a , 'id ) t * ('k , 'a , 'id ) t )* 'a option
457
+ ('k , 'v , 'id ) t -> 'k ->
458
+ (('k , 'v , 'id ) t * ('k , 'v , 'id ) t )* 'v option
457
459
(* * [split x m] returns a tuple [(l r), data], where
458
460
[l] is the map with all the bindings of [m] whose 'k
459
461
is strictly less than [x];
@@ -463,16 +465,16 @@ val split:
463
465
or [Some v] if [m] binds [v] to [x].
464
466
*)
465
467
466
- val mapU : ('k , 'a , 'id ) t -> ('a -> 'b [@ bs]) -> ('k ,'b, 'id ) t
467
- val map : ('k , 'a , 'id ) t -> ('a -> 'b ) -> ('k ,'b, 'id ) t
468
+ val mapU : ('k , 'v , 'id ) t -> ('v -> 'v2 [@ bs]) -> ('k , 'v2 , 'id ) t
469
+ val map : ('k , 'v , 'id ) t -> ('v -> 'v2 ) -> ('k , 'v2 , 'id ) t
468
470
(* * [map m f] returns a map with same domain as [m], where the
469
471
associated value [a] of all bindings of [m] has been
470
472
replaced by the result of the application of [f] to [a].
471
473
The bindings are passed to [f] in increasing order
472
474
with respect to the ordering over the type of the keys. *)
473
475
474
- val mapWithKeyU : ('k , 'a , 'id ) t -> ('k -> 'a -> 'b [@ bs]) -> ('k , 'b , 'id ) t
475
- val mapWithKey : ('k , 'a , 'id ) t -> ('k -> 'a -> 'b ) -> ('k , 'b , 'id ) t
476
+ val mapWithKeyU : ('k , 'v , 'id ) t -> ('k -> 'v -> 'v2 [@ bs]) -> ('k , 'v2 , 'id ) t
477
+ val mapWithKey : ('k , 'v , 'id ) t -> ('k -> 'v -> 'v2 ) -> ('k , 'v2 , 'id ) t
476
478
(* * [mapWithKey m f]
477
479
478
480
The same as {!map} except that [f] is supplied with one more argument: the key
@@ -482,7 +484,7 @@ val mapWithKey: ('k, 'a, 'id) t -> ('k -> 'a -> 'b) -> ('k, 'b, 'id) t
482
484
483
485
484
486
485
- val getData : ('a , 'b , 'c ) t -> ('a , 'b , 'c ) Belt_MapDict .t
487
+ val getData : ('k , 'v , 'id ) t -> ('k , 'v , 'id ) Belt_MapDict .t
486
488
(* * [getData s0]
487
489
488
490
{b Advanced usage only}
@@ -492,15 +494,15 @@ val getData: ('a, 'b, 'c) t -> ('a, 'b, 'c) Belt_MapDict.t
492
494
without boxing
493
495
*)
494
496
495
- val getId : ('a , 'b , 'c ) t -> ('a , 'c ) id
497
+ val getId : ('k , 'v , 'id ) t -> ('k , 'id ) id
496
498
(* * [getId s0]
497
499
498
500
{b Advanced usage only}
499
501
500
502
@return the identity of [s0]
501
503
*)
502
504
503
- val packIdData : id :('a , 'b ) id -> data :('a , 'c , 'b ) Belt_MapDict .t -> ('a , 'c , 'b ) t
505
+ val packIdData : id :('k , 'id ) id -> data :('k , 'v , 'id ) Belt_MapDict .t -> ('k , 'v , 'id ) t
504
506
(* * [packIdData ~id ~data]
505
507
506
508
{b Advanced usage only}
0 commit comments