Skip to content

Commit 6103685

Browse files
committed
tweak Belt_Id
Ideally (struct type xx include N end) should just generate N instead
1 parent fcfa9e4 commit 6103685

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

jscomp/others/belt_Id.ml

+10-14
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ module MakeComparableU (M : sig
4949
end) =
5050
struct
5151
type identity
52-
type t = M.t
53-
let cmp = M.cmp
52+
include M
5453
end
5554

5655
module MakeComparable (M : sig
@@ -69,11 +68,11 @@ let comparableU
6968
(type key)
7069
~cmp
7170
=
72-
let module N = MakeComparableU(struct
71+
(module MakeComparableU(struct
7372
type t = key
7473
let cmp = cmp
75-
end) in
76-
(module N : Comparable with type t = key)
74+
end)
75+
: Comparable with type t = key)
7776

7877
let comparable
7978
(type key)
@@ -101,9 +100,7 @@ module MakeHashableU (M : sig
101100
end) =
102101
struct
103102
type identity
104-
type t = M.t
105-
let hash = M.hash
106-
let eq = M.eq
103+
include M
107104
end
108105

109106
module MakeHashable (M : sig
@@ -121,12 +118,11 @@ struct
121118
end
122119

123120
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)
121+
(module MakeHashableU(struct
122+
type t = key
123+
let hash = hash
124+
let eq = eq
125+
end) : Hashable with type t = key)
130126

131127
let hashable (type key) ~hash ~eq =
132128
let module N = MakeHashable(struct

lib/js/belt_Id.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
var Curry = require("./curry.js");
44

55
function MakeComparableU(M) {
6-
var cmp = M[/* cmp */0];
7-
return /* module */[/* cmp */cmp];
6+
return /* module */[/* cmp */M[0]];
87
}
98

109
function MakeComparable(M) {
@@ -23,11 +22,9 @@ function comparable(cmp) {
2322
}
2423

2524
function MakeHashableU(M) {
26-
var hash = M[/* hash */0];
27-
var eq = M[/* eq */1];
2825
return /* module */[
29-
/* hash */hash,
30-
/* eq */eq
26+
/* hash */M[0],
27+
/* eq */M[1]
3128
];
3229
}
3330

0 commit comments

Comments
 (0)