35
35
36
36
37
37
38
- type ('a, 'id) hash
38
+ type ('a, 'id) hash = 'a -> int [ @ bs]
39
39
(* * [('a, 'id) hash]
40
40
41
41
Its runtime represenation is a [hash] function, but signed with a
42
42
type parameter, so that different hash functions type mismatch
43
43
*)
44
44
45
- type ('a, 'id) eq
45
+ type ('a, 'id) eq = 'a -> 'a -> bool [ @ bs]
46
46
(* * [('a, 'id) eq]
47
47
48
48
Its runtime represenation is an [eq] function, but signed with a
49
49
type parameter, so that different hash functions type mismatch
50
50
*)
51
51
52
- type ('a, 'id) cmp
52
+ type ('a, 'id) cmp = 'a -> 'a -> int [ @ bs]
53
53
(* * [('a,'id) cmp]
54
54
55
55
Its runtime representation is a [cmp] function, but signed with a
56
56
type parameter, so that different hash functions type mismatch
57
57
*)
58
-
59
58
module type Comparable = sig
60
59
type identity
61
60
type t
@@ -75,6 +74,28 @@ type ('key, 'id) comparable =
75
74
mismatch if they use different comparison function
76
75
*)
77
76
77
+ module MakeComparableU :
78
+ functor (M : sig
79
+ type t
80
+ val cmp : t -> t -> int [@ bs]
81
+ end ) ->
82
+ sig
83
+ type identity
84
+ type t = M .t
85
+ val cmp : M .t -> M .t -> int [@ bs]
86
+ end
87
+
88
+ module MakeComparable :
89
+ functor (M : sig
90
+ type t
91
+ val cmp : t -> t -> int
92
+ end ) ->
93
+ sig
94
+ type identity
95
+ type t = M .t
96
+ val cmp : M .t -> M .t -> int [@ bs]
97
+ end
98
+
78
99
val comparableU :
79
100
('a -> 'a -> int [@ bs]) ->
80
101
(module Comparable with type t = 'a )
@@ -84,11 +105,11 @@ val comparable:
84
105
(module Comparable with type t = 'a )
85
106
86
107
module type Hashable = sig
87
- type identity
88
- type t
89
- val hash : (t ,identity) hash
90
- val eq : (t ,identity) eq
91
- end
108
+ type identity
109
+ type t
110
+ val hash : (t , identity ) hash
111
+ val eq : (t , identity ) eq
112
+ end
92
113
93
114
type ('key, 'id) hashable =
94
115
(module Hashable with type t = 'key and type identity = 'id )
@@ -105,13 +126,13 @@ type ('key, 'id) hashable =
105
126
106
127
107
128
108
- val hashableU :
129
+ val hashableU :
109
130
hash :('a -> int [@ bs]) ->
110
131
eq :('a -> 'a -> bool [@ bs]) ->
111
132
(module Hashable with type t = 'a )
112
133
113
- val hashable :
114
- hash :('a -> int ) ->
134
+ val hashable :
135
+ hash :('a -> int ) ->
115
136
eq :('a -> 'a -> bool ) ->
116
137
(module Hashable with type t = 'a )
117
138
0 commit comments