Skip to content

Commit 50cc986

Browse files
committed
Change set terminology of elt to value
Second diff of rescript-lang#2536, pulled out
1 parent 2f3e494 commit 50cc986

23 files changed

+407
-407
lines changed

jscomp/others/belt_HashSet.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ let has h key =
160160

161161

162162

163-
let make (type elt) (type identity) ~hintSize ~(id: (elt, identity) id)=
163+
let make (type value) (type identity) ~hintSize ~(id: (value, identity) id)=
164164
let module M = (val id) in
165165
C.make ~hintSize ~hash:M.hash ~eq:M.eq
166166

jscomp/others/belt_MutableSet.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ type ('k, 'id) id = ('k, 'id) Belt_Id.comparable
3535
type ('key, 'id ) cmp = ('key, 'id) Belt_Id.cmp
3636

3737
module S = struct
38-
type ('elt,'id) t =
38+
type ('value,'id) t =
3939
{
40-
cmp: ('elt, 'id) cmp;
41-
mutable data: 'elt N.t
40+
cmp: ('value, 'id) cmp;
41+
mutable data: 'value N.t
4242
} [@@bs.deriving abstract]
4343
end
4444

@@ -189,7 +189,7 @@ let mergeMany d xs =
189189
S.dataSet d (addArrayMutate (S.data d) xs ~cmp:(S.cmp d))
190190

191191

192-
let make (type elt) (type identity) ~(id : (elt, identity) id) =
192+
let make (type value) (type identity) ~(id : (value, identity) id) =
193193
let module M = (val id) in
194194
S.t ~cmp:M.cmp ~data:N.empty
195195

@@ -220,15 +220,15 @@ let toList d =
220220
let toArray d =
221221
N.toArray (S.data d)
222222

223-
let ofSortedArrayUnsafe (type elt) (type identity) xs ~(id : (elt,identity) id) : _ t =
223+
let ofSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id) : _ t =
224224
let module M = (val id) in
225225
S.t ~data:(N.ofSortedArrayUnsafe xs) ~cmp:M.cmp
226226

227227
let checkInvariantInternal d =
228228
N.checkInvariantInternal (S.data d)
229229

230230

231-
let ofArray (type elt) (type identity) data ~(id : (elt,identity) id) =
231+
let ofArray (type value) (type identity) data ~(id : (value,identity) id) =
232232
let module M = (val id) in
233233
let cmp = M.cmp in
234234
S.t ~cmp ~data:(N.ofArray ~cmp data)

jscomp/others/belt_MutableSet.mli

+41-41
Original file line numberDiff line numberDiff line change
@@ -87,88 +87,88 @@ type ('k,'id) t
8787

8888
type ('k, 'id) id = ('k, 'id) Belt_Id.comparable
8989

90-
val make: id:('elt, 'id) id -> ('elt, 'id) t
90+
val make: id:('value, 'id) id -> ('value, 'id) t
9191

9292
val ofArray: 'k array -> id:('k, 'id) id -> ('k, 'id) t
93-
val ofSortedArrayUnsafe: 'elt array -> id:('elt, 'id) id -> ('elt,'id) t
93+
val ofSortedArrayUnsafe: 'value array -> id:('value, 'id) id -> ('value,'id) t
9494
val copy: ('k, 'id) t -> ('k, 'id) t
9595
val isEmpty: _ t -> bool
96-
val has: ('elt, _) t -> 'elt -> bool
96+
val has: ('value, _) t -> 'value -> bool
9797

98-
val add: ('elt, 'id) t -> 'elt -> unit
98+
val add: ('value, 'id) t -> 'value -> unit
9999

100100
val addCheck:
101-
('elt, 'id) t -> 'elt -> bool
101+
('value, 'id) t -> 'value -> bool
102102

103103
val mergeMany:
104-
('elt, 'id) t -> 'elt array -> unit
104+
('value, 'id) t -> 'value array -> unit
105105

106-
val remove: ('elt, 'id) t -> 'elt -> unit
106+
val remove: ('value, 'id) t -> 'value -> unit
107107

108-
val removeCheck: ('elt, 'id) t -> 'elt -> bool
108+
val removeCheck: ('value, 'id) t -> 'value -> bool
109109
(* [b = removeCheck s e] [b] is true means one element removed *)
110110

111111
val removeMany:
112-
('elt, 'id) t -> 'elt array -> unit
112+
('value, 'id) t -> 'value array -> unit
113113

114-
val union: ('elt, 'id) t -> ('elt, 'id) t -> ('elt, 'id) t
115-
val intersect: ('elt, 'id) t -> ('elt, 'id) t -> ('elt, 'id) t
116-
val diff: ('elt, 'id) t -> ('elt, 'id) t -> ('elt, 'id) t
117-
val subset: ('elt, 'id) t -> ('elt, 'id) t -> bool
114+
val union: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t
115+
val intersect: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t
116+
val diff: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t
117+
val subset: ('value, 'id) t -> ('value, 'id) t -> bool
118118

119119
val cmp:
120-
('elt, 'id) t -> ('elt, 'id) t -> int
120+
('value, 'id) t -> ('value, 'id) t -> int
121121
val eq:
122-
('elt, 'id) t -> ('elt, 'id) t -> bool
122+
('value, 'id) t -> ('value, 'id) t -> bool
123123

124-
val forEachU: ('elt, 'id) t -> ('elt -> unit [@bs]) -> unit
125-
val forEach: ('elt, 'id) t -> ('elt -> unit) -> unit
124+
val forEachU: ('value, 'id) t -> ('value -> unit [@bs]) -> unit
125+
val forEach: ('value, 'id) t -> ('value -> unit) -> unit
126126
(** [forEach m f] applies [f] in turn to all elements of [m].
127127
In increasing order *)
128128

129-
val reduceU: ('elt, 'id) t -> 'a -> ('a -> 'elt -> 'a [@bs]) -> 'a
130-
val reduce: ('elt, 'id) t -> 'a -> ('a -> 'elt -> 'a) -> 'a
129+
val reduceU: ('value, 'id) t -> 'a -> ('a -> 'value -> 'a [@bs]) -> 'a
130+
val reduce: ('value, 'id) t -> 'a -> ('a -> 'value -> 'a) -> 'a
131131
(** In increasing order. *)
132132

133-
val everyU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> bool
134-
val every: ('elt, 'id) t -> ('elt -> bool) -> bool
133+
val everyU: ('value, 'id) t -> ('value -> bool [@bs]) -> bool
134+
val every: ('value, 'id) t -> ('value -> bool) -> bool
135135
(** [every s p] checks if all elements of the set
136136
satisfy the predicate [p]. Order unspecified *)
137137

138-
val someU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> bool
139-
val some: ('elt, 'id) t -> ('elt -> bool) -> bool
138+
val someU: ('value, 'id) t -> ('value -> bool [@bs]) -> bool
139+
val some: ('value, 'id) t -> ('value -> bool) -> bool
140140
(** [some p s] checks if at least one element of
141141
the set satisfies the predicate [p]. *)
142142

143-
val keepU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> ('elt, 'id) t
144-
val keep: ('elt, 'id) t -> ('elt -> bool) -> ('elt, 'id) t
143+
val keepU: ('value, 'id) t -> ('value -> bool [@bs]) -> ('value, 'id) t
144+
val keep: ('value, 'id) t -> ('value -> bool) -> ('value, 'id) t
145145
(** [keep s p] returns the set of all elements in [s]
146146
that satisfy predicate [p]. *)
147147

148-
val partitionU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> ('elt, 'id) t * ('elt, 'id) t
149-
val partition: ('elt, 'id) t -> ('elt -> bool) -> ('elt, 'id) t * ('elt, 'id) t
148+
val partitionU: ('value, 'id) t -> ('value -> bool [@bs]) -> ('value, 'id) t * ('value, 'id) t
149+
val partition: ('value, 'id) t -> ('value -> bool) -> ('value, 'id) t * ('value, 'id) t
150150
(** [partition p s] returns a pair of sets [(s1, s2)], where
151151
[s1] is the set of all the elements of [s] that satisfy the
152152
predicate [p], and [s2] is the set of all the elements of
153153
[s] that do not satisfy [p]. *)
154154

155155

156-
val size: ('elt, 'id) t -> int
157-
val toList: ('elt, 'id) t -> 'elt list
156+
val size: ('value, 'id) t -> int
157+
val toList: ('value, 'id) t -> 'value list
158158
(** In increasing order*)
159-
val toArray: ('elt, 'id) t -> 'elt array
159+
val toArray: ('value, 'id) t -> 'value array
160160

161-
val minimum: ('elt, 'id) t -> 'elt option
162-
val minUndefined: ('elt, 'id) t -> 'elt Js.undefined
163-
val maximum: ('elt, 'id) t -> 'elt option
164-
val maxUndefined: ('elt, 'id) t -> 'elt Js.undefined
161+
val minimum: ('value, 'id) t -> 'value option
162+
val minUndefined: ('value, 'id) t -> 'value Js.undefined
163+
val maximum: ('value, 'id) t -> 'value option
164+
val maxUndefined: ('value, 'id) t -> 'value Js.undefined
165165

166-
val get: ('elt, 'id) t -> 'elt -> 'elt option
167-
val getUndefined: ('elt, 'id) t -> 'elt -> 'elt Js.undefined
168-
val getExn: ('elt, 'id) t -> 'elt -> 'elt
166+
val get: ('value, 'id) t -> 'value -> 'value option
167+
val getUndefined: ('value, 'id) t -> 'value -> 'value Js.undefined
168+
val getExn: ('value, 'id) t -> 'value -> 'value
169169

170170

171-
val split: ('elt, 'id) t -> 'elt -> (('elt, 'id) t * ('elt, 'id) t) * bool
171+
val split: ('value, 'id) t -> 'value -> (('value, 'id) t * ('value, 'id) t) * bool
172172
(** [split s x] returns a triple [((l, r), present)], where
173173
[l] is the set of elements of [s] that are
174174
strictly less than [x];
@@ -187,8 +187,8 @@ val checkInvariantInternal: _ t -> unit
187187
(*
188188
[add0] was not exposed for various reasons:
189189
1. such api is dangerious
190-
[ cmp: ('elt,'id) Belt_Cmp.cmp ->
191-
('elt, 'id) t0 -> 'elt ->
192-
('elt, 'id) t0]
190+
[ cmp: ('value,'id) Belt_Cmp.cmp ->
191+
('value, 'id) t0 -> 'value ->
192+
('value, 'id) t0]
193193
2. It is not really significantly more *)
194194

jscomp/others/belt_MutableSetInt.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module S = Belt_SortArrayInt
3535
module N = Belt_internalAVLset
3636
module A = Belt_Array
3737

38-
type elt = I.elt
38+
type value = I.value
3939
(** The type of the set elements. *)
4040

4141

@@ -45,7 +45,7 @@ type t = {
4545
(** The type of sets. *)
4646

4747

48-
let rec remove0 nt (x : elt)=
48+
let rec remove0 nt (x : value)=
4949
let k = N.key nt in
5050
if x = k then
5151
let l,r = N.(left nt, right nt) in
@@ -98,7 +98,7 @@ let removeMany (d : t) xs =
9898
let len = A.length xs in
9999
dataSet d (removeMany0 nt xs 0 len)
100100

101-
let rec removeCheck0 nt (x : elt) removed =
101+
let rec removeCheck0 nt (x : value) removed =
102102
let k = N.key nt in
103103
if x = k then
104104
let () = removed := true in
@@ -139,7 +139,7 @@ let removeCheck (d : t) v =
139139
!removed
140140

141141

142-
let rec addCheck0 t (x : elt) added =
142+
let rec addCheck0 t (x : value) added =
143143
match N.toOpt t with
144144
| None ->
145145
added := true;

jscomp/others/belt_MutableSetInt.mli

+33-33
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434

3535
# 37
36-
type elt = int
36+
type value = int
3737
# 41
3838
(** The type of the set elements. *)
3939

@@ -43,18 +43,18 @@ type t
4343

4444
val make: unit -> t
4545

46-
val ofArray: elt array -> t
47-
val ofSortedArrayUnsafe: elt array -> t
46+
val ofArray: value array -> t
47+
val ofSortedArrayUnsafe: value array -> t
4848
val copy: t -> t
4949
val isEmpty: t -> bool
50-
val has: t -> elt -> bool
51-
52-
val add: t -> elt -> unit
53-
val addCheck: t -> elt -> bool
54-
val mergeMany: t -> elt array -> unit
55-
val remove: t -> elt -> unit
56-
val removeCheck: t -> elt -> bool
57-
val removeMany: t -> elt array -> unit
50+
val has: t -> value -> bool
51+
52+
val add: t -> value -> unit
53+
val addCheck: t -> value -> bool
54+
val mergeMany: t -> value array -> unit
55+
val remove: t -> value -> unit
56+
val removeCheck: t -> value -> bool
57+
val removeMany: t -> value array -> unit
5858

5959
val union: t -> t -> t
6060
val intersect: t -> t -> t
@@ -65,51 +65,51 @@ val cmp: t -> t -> int
6565
val eq: t -> t -> bool
6666

6767

68-
val forEachU: t -> (elt -> unit [@bs]) -> unit
69-
val forEach: t -> (elt -> unit ) -> unit
68+
val forEachU: t -> (value -> unit [@bs]) -> unit
69+
val forEach: t -> (value -> unit ) -> unit
7070
(** In increasing order*)
7171

72-
val reduceU: t -> 'a -> ('a -> elt -> 'a [@bs]) -> 'a
73-
val reduce: t -> 'a -> ('a -> elt -> 'a ) -> 'a
72+
val reduceU: t -> 'a -> ('a -> value -> 'a [@bs]) -> 'a
73+
val reduce: t -> 'a -> ('a -> value -> 'a ) -> 'a
7474
(** Iterate in increasing order. *)
7575

76-
val everyU: t -> (elt -> bool [@bs]) -> bool
77-
val every: t -> (elt -> bool) -> bool
76+
val everyU: t -> (value -> bool [@bs]) -> bool
77+
val every: t -> (value -> bool) -> bool
7878
(** [every p s] checks if all elements of the set
7979
satisfy the predicate [p]. Order unspecified. *)
8080

81-
val someU: t -> (elt -> bool [@bs]) -> bool
82-
val some: t -> (elt -> bool) -> bool
81+
val someU: t -> (value -> bool [@bs]) -> bool
82+
val some: t -> (value -> bool) -> bool
8383
(** [some p s] checks if at least one element of
8484
the set satisfies the predicate [p]. Oder unspecified. *)
8585

86-
val keepU: t -> (elt -> bool [@bs]) -> t
87-
val keep: t -> (elt -> bool) -> t
86+
val keepU: t -> (value -> bool [@bs]) -> t
87+
val keep: t -> (value -> bool) -> t
8888
(** [keep s p] returns a fresh copy of the set of all elements in [s]
8989
that satisfy predicate [p]. *)
9090

91-
val partitionU: t -> (elt -> bool [@bs]) -> t * t
92-
val partition: t -> (elt -> bool) -> t * t
91+
val partitionU: t -> (value -> bool [@bs]) -> t * t
92+
val partition: t -> (value -> bool) -> t * t
9393
(** [partition s p] returns a fresh copy pair of sets [(s1, s2)], where
9494
[s1] is the set of all the elements of [s] that satisfy the
9595
predicate [p], and [s2] is the set of all the elements of
9696
[s] that do not satisfy [p]. *)
9797

9898
val size: t -> int
99-
val toList: t -> elt list
99+
val toList: t -> value list
100100
(** In increasing order with respect *)
101-
val toArray: t -> elt array
101+
val toArray: t -> value array
102102

103103

104-
val minimum: t -> elt option
105-
val minUndefined: t -> elt Js.undefined
106-
val maximum: t -> elt option
107-
val maxUndefined: t -> elt Js.undefined
104+
val minimum: t -> value option
105+
val minUndefined: t -> value Js.undefined
106+
val maximum: t -> value option
107+
val maxUndefined: t -> value Js.undefined
108108

109-
val get: t -> elt -> elt option
110-
val getUndefined: t -> elt -> elt Js.undefined
111-
val getExn: t -> elt -> elt
112-
val split: t -> elt -> (t * t) * bool
109+
val get: t -> value -> value option
110+
val getUndefined: t -> value -> value Js.undefined
111+
val getExn: t -> value -> value
112+
val split: t -> value -> (t * t) * bool
113113
(**
114114
[split s key] return a fresh copy of each
115115
*)

jscomp/others/belt_MutableSetString.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module S = Belt_SortArrayString
3535
module N = Belt_internalAVLset
3636
module A = Belt_Array
3737

38-
type elt = I.elt
38+
type value = I.value
3939
(** The type of the set elements. *)
4040

4141

@@ -45,7 +45,7 @@ type t = {
4545
(** The type of sets. *)
4646

4747

48-
let rec remove0 nt (x : elt)=
48+
let rec remove0 nt (x : value)=
4949
let k = N.key nt in
5050
if x = k then
5151
let l,r = N.(left nt, right nt) in
@@ -98,7 +98,7 @@ let removeMany (d : t) xs =
9898
let len = A.length xs in
9999
dataSet d (removeMany0 nt xs 0 len)
100100

101-
let rec removeCheck0 nt (x : elt) removed =
101+
let rec removeCheck0 nt (x : value) removed =
102102
let k = N.key nt in
103103
if x = k then
104104
let () = removed := true in
@@ -139,7 +139,7 @@ let removeCheck (d : t) v =
139139
!removed
140140

141141

142-
let rec addCheck0 t (x : elt) added =
142+
let rec addCheck0 t (x : value) added =
143143
match N.toOpt t with
144144
| None ->
145145
added := true;

0 commit comments

Comments
 (0)