1
1
2
2
(* Copyright (C) 2017 Authors of BuckleScript
3
- *
3
+ *
4
4
* This program is free software: you can redistribute it and/or modify
5
5
* it under the terms of the GNU Lesser General Public License as published by
6
6
* the Free Software Foundation, either version 3 of the License, or
18
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
20
* GNU Lesser General Public License for more details.
21
- *
21
+ *
22
22
* You should have received a copy of the GNU Lesser General Public License
23
23
* along with this program; if not, write to the Free Software
24
24
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
25
25
26
26
27
27
(* * {!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
33
33
comparison functions won't mix.
34
34
*)
35
35
38
38
type ('a, 'id) hash
39
39
(* * [('a, 'id) hash]
40
40
41
- Its runtime represenation is a [hash] function, but signed with a
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
45
type ('a, 'id) eq
46
46
(* * [('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
49
49
type parameter, so that different hash functions type mismatch
50
- *)
50
+ *)
51
51
52
52
type ('a, 'id) cmp
53
53
(* * [('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
56
56
type parameter, so that different hash functions type mismatch
57
57
*)
58
58
module type Comparable = sig
@@ -66,39 +66,39 @@ type ('key, 'id) comparable =
66
66
(* * [('key, 'id) cmparable] is a module of functions, here it only includes [cmp].
67
67
68
68
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
74
74
mismatch if they use different comparison function
75
75
*)
76
76
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 ) ->
82
82
Comparable with type t = M. t
83
83
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
88
88
end ) ->
89
89
Comparable with type t = M. t
90
90
91
91
val comparableU :
92
- ('a -> 'a -> int [@ bs]) ->
92
+ cmp : ('a -> 'a -> int [@ bs]) ->
93
93
(module Comparable with type t = 'a )
94
94
[@@ ocaml.deprecated "Use the MakeComparableU functor API instead" ]
95
95
96
96
val comparable :
97
- ('a -> 'a -> int ) ->
97
+ cmp : ('a -> 'a -> int ) ->
98
98
(module Comparable with type t = 'a )
99
99
[@@ ocaml.deprecated "Use the MakeComparable functor API instead" ]
100
-
101
- module type Hashable = sig
100
+
101
+ module type Hashable = sig
102
102
type identity
103
103
type t
104
104
val hash : (t , identity ) hash
@@ -108,27 +108,27 @@ end
108
108
type ('key, 'id) hashable =
109
109
(module Hashable with type t = 'key and type identity = 'id )
110
110
(* * [('key, 'id) hashable] is a module of functions, here it only includes [hash], [eq].
111
-
111
+
112
112
Unlike normal functions, when created, it comes with a unique identity (guaranteed
113
- by the type system).
114
-
113
+ by the type system).
114
+
115
115
It can be created using function {!hashableU} or {!hashable}.
116
116
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
118
118
mismatch if they use different comparison function
119
119
*)
120
120
121
- module MakeHashableU :
122
- functor (M : sig
123
- type t
121
+ module MakeHashableU :
122
+ functor (M : sig
123
+ type t
124
124
val hash : t -> int [@ bs]
125
125
val eq : t -> t -> bool [@ bs]
126
126
end ) ->
127
127
Hashable with type t = M. t
128
128
129
- module MakeHashable :
130
- functor (M : sig
131
- type t
129
+ module MakeHashable :
130
+ functor (M : sig
131
+ type t
132
132
val hash : t -> int
133
133
val eq : t -> t -> bool
134
134
end ) ->
0 commit comments