Skip to content

Commit fe21e20

Browse files
authored
[Belt] Put comparable ~cmp label back (#2602)
See #2565 which removed it. #2589 deprecates comparable, so we can just put the label back to avoid unnecessary churn the next release
1 parent 5a37b34 commit fe21e20

File tree

8 files changed

+404
-404
lines changed

8 files changed

+404
-404
lines changed

jscomp/others/belt_Id.ml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
(* Copyright (C) 2017 Authors of BuckleScript
3-
*
3+
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU Lesser General Public License as published by
66
* the Free Software Foundation, either version 3 of the License, or
@@ -18,7 +18,7 @@
1818
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1919
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020
* GNU Lesser General Public License for more details.
21-
*
21+
*
2222
* You should have received a copy of the GNU Lesser General Public License
2323
* along with this program; if not, write to the Free Software
2424
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
@@ -27,7 +27,7 @@
2727
type ('a, 'id) hash = ('a -> int [@bs])
2828
type ('a, 'id) eq = ('a -> 'a -> bool [@bs])
2929
type ('a, 'id) cmp = ('a -> 'a -> int [@bs])
30-
30+
3131
external getHashInternal : ('a,'id) hash -> ('a -> int [@bs]) = "%identity"
3232
external getEqInternal : ('a, 'id) eq -> ('a -> 'a -> bool [@bs]) = "%identity"
3333
external getCmpInternal : ('a,'id) cmp -> ('a -> 'a -> int [@bs]) = "%identity"
@@ -61,39 +61,39 @@ struct
6161
type identity
6262
type t = M.t
6363
(* see https://github.com/BuckleScript/bucklescript/pull/2589/files/5ef875b7665ee08cfdc59af368fc52bac1fe9130#r173330825 *)
64-
let cmp =
64+
let cmp =
6565
let cmp = M.cmp in fun[@bs] a b -> cmp a b
6666
end
6767

6868
let comparableU
69-
(type key)
70-
cmp
69+
(type key)
70+
~cmp
7171
=
7272
let module N = MakeComparableU(struct
7373
type t = key
7474
let cmp = cmp
75-
end) in
75+
end) in
7676
(module N : Comparable with type t = key)
7777

7878
let comparable
79-
(type key)
80-
cmp
79+
(type key)
80+
~cmp
8181
=
8282
let module N = MakeComparable(struct
8383
type t = key
8484
let cmp = cmp
85-
end) in
85+
end) in
8686
(module N : Comparable with type t = key)
8787

88-
module type Hashable = sig
89-
type identity
90-
type t
88+
module type Hashable = sig
89+
type identity
90+
type t
9191
val hash: (t,identity) hash
9292
val eq: (t,identity) eq
9393
end
9494

9595
type ('key, 'id) hashable = (module Hashable with type t = 'key and type identity = 'id)
96-
96+
9797
module MakeHashableU (M : sig
9898
type t
9999
val hash : t -> int [@bs]
@@ -114,24 +114,24 @@ module MakeHashable (M : sig
114114
struct
115115
type identity
116116
type t = M.t
117-
let hash =
117+
let hash =
118118
let hash = M.hash in fun[@bs] a -> hash a
119-
let eq =
119+
let eq =
120120
let eq = M.eq in fun[@bs] a b -> eq a b
121121
end
122122

123-
let hashableU (type key) ~hash ~eq =
124-
let module N = MakeHashableU(struct
125-
type t = key
126-
let hash = hash
127-
let eq = eq
128-
end) in
129-
(module N : Hashable with type t = key)
130-
131-
let hashable (type key) ~hash ~eq =
132-
let module N = MakeHashable(struct
133-
type t = key
134-
let hash = hash
135-
let eq = eq
136-
end) in
137-
(module N : Hashable with type t = key)
123+
let hashableU (type key) ~hash ~eq =
124+
let module N = MakeHashableU(struct
125+
type t = key
126+
let hash = hash
127+
let eq = eq
128+
end) in
129+
(module N : Hashable with type t = key)
130+
131+
let hashable (type key) ~hash ~eq =
132+
let module N = MakeHashable(struct
133+
type t = key
134+
let hash = hash
135+
let eq = eq
136+
end) in
137+
(module N : Hashable with type t = key)

jscomp/others/belt_Id.mli

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
(* Copyright (C) 2017 Authors of BuckleScript
3-
*
3+
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU Lesser General Public License as published by
66
* the Free Software Foundation, either version 3 of the License, or
@@ -18,18 +18,18 @@
1818
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1919
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020
* GNU Lesser General Public License for more details.
21-
*
21+
*
2222
* You should have received a copy of the GNU Lesser General Public License
2323
* along with this program; if not, write to the Free Software
2424
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2525

2626

2727
(** {!Belt.Id}
28-
29-
Provide utiliites to create identified comparators or hashes for
30-
data structures used below.
31-
32-
It create a unique identifer per module of functions so that different data structures with slightly different
28+
29+
Provide utiliites to create identified comparators or hashes for
30+
data structures used below.
31+
32+
It create a unique identifer per module of functions so that different data structures with slightly different
3333
comparison functions won't mix.
3434
*)
3535

@@ -38,21 +38,21 @@
3838
type ('a, 'id) hash
3939
(** [('a, 'id) hash]
4040
41-
Its runtime represenation is a [hash] function, but signed with a
41+
Its runtime represenation is a [hash] function, but signed with a
4242
type parameter, so that different hash functions type mismatch
43-
*)
43+
*)
4444

4545
type ('a, 'id) eq
4646
(** [('a, 'id) eq]
47-
48-
Its runtime represenation is an [eq] function, but signed with a
47+
48+
Its runtime represenation is an [eq] function, but signed with a
4949
type parameter, so that different hash functions type mismatch
50-
*)
50+
*)
5151

5252
type ('a, 'id) cmp
5353
(** [('a,'id) cmp]
54-
55-
Its runtime representation is a [cmp] function, but signed with a
54+
55+
Its runtime representation is a [cmp] function, but signed with a
5656
type parameter, so that different hash functions type mismatch
5757
*)
5858
module type Comparable = sig
@@ -66,39 +66,39 @@ type ('key, 'id) comparable =
6666
(** [('key, 'id) cmparable] is a module of functions, here it only includes [cmp].
6767
6868
Unlike normal functions, when created, it comes with a unique identity (guaranteed
69-
by the type system).
70-
71-
It can be created using function {!comparableU} or{!comparable}.
72-
73-
The idea of a unique identity when created is that it makes sure two sets would type
69+
by the type system).
70+
71+
It can be created using function {!comparableU} or{!comparable}.
72+
73+
The idea of a unique identity when created is that it makes sure two sets would type
7474
mismatch if they use different comparison function
7575
*)
7676

77-
module MakeComparableU :
78-
functor (M : sig
79-
type t
80-
val cmp : t -> t -> int [@bs]
81-
end) ->
77+
module MakeComparableU :
78+
functor (M : sig
79+
type t
80+
val cmp : t -> t -> int [@bs]
81+
end) ->
8282
Comparable with type t = M.t
8383

84-
module MakeComparable :
85-
functor (M : sig
86-
type t
87-
val cmp : t -> t -> int
84+
module MakeComparable :
85+
functor (M : sig
86+
type t
87+
val cmp : t -> t -> int
8888
end) ->
8989
Comparable with type t = M.t
9090

9191
val comparableU:
92-
('a -> 'a -> int [@bs]) ->
92+
cmp:('a -> 'a -> int [@bs]) ->
9393
(module Comparable with type t = 'a)
9494
[@@ocaml.deprecated "Use the MakeComparableU functor API instead"]
9595

9696
val comparable:
97-
('a -> 'a -> int) ->
97+
cmp:('a -> 'a -> int) ->
9898
(module Comparable with type t = 'a)
9999
[@@ocaml.deprecated "Use the MakeComparable functor API instead"]
100-
101-
module type Hashable = sig
100+
101+
module type Hashable = sig
102102
type identity
103103
type t
104104
val hash : (t, identity) hash
@@ -108,27 +108,27 @@ end
108108
type ('key, 'id) hashable =
109109
(module Hashable with type t = 'key and type identity = 'id)
110110
(** [('key, 'id) hashable] is a module of functions, here it only includes [hash], [eq].
111-
111+
112112
Unlike normal functions, when created, it comes with a unique identity (guaranteed
113-
by the type system).
114-
113+
by the type system).
114+
115115
It can be created using function {!hashableU} or {!hashable}.
116116
117-
The idea of a unique identity when created is that it makes sure two hash sets would type
117+
The idea of a unique identity when created is that it makes sure two hash sets would type
118118
mismatch if they use different comparison function
119119
*)
120120

121-
module MakeHashableU :
122-
functor (M : sig
123-
type t
121+
module MakeHashableU :
122+
functor (M : sig
123+
type t
124124
val hash : t -> int [@bs]
125125
val eq : t -> t -> bool [@bs]
126126
end) ->
127127
Hashable with type t = M.t
128128

129-
module MakeHashable :
130-
functor (M : sig
131-
type t
129+
module MakeHashable :
130+
functor (M : sig
131+
type t
132132
val hash : t -> int
133133
val eq : t -> t -> bool
134134
end) ->

0 commit comments

Comments
 (0)