@@ -29,9 +29,15 @@ true = Bool.true;
29
29
false = Bool.false;
30
30
not = Bool.not;
31
31
32
- (==) 'a (x : a) (y : a) = primitive "==" a (x, y);
33
- (<>) 'a (x : a) (y : a) = not (x == y);
32
+ PolyEq (type t) = {
33
+ (==) (x : t) (y : t) = primitive "==" t (x, y);
34
+ (<>) (x : t) (y : t) = not (x == y);
35
+ };
34
36
37
+ Bool = {
38
+ include Bool;
39
+ include PolyEq t;
40
+ };
35
41
36
42
;; Int
37
43
49
55
(<=) l r = primitive "Int.<=" (l, r);
50
56
(>=) l r = primitive "Int.>=" (l, r);
51
57
print = primitive "Int.print";
58
+ include PolyEq t;
52
59
};
53
60
type int = Int.t;
54
61
(+) = Int.+;
@@ -60,6 +67,7 @@ type int = Int.t;
60
67
(>) = Int.>;
61
68
(<=) = Int.<=;
62
69
(>=) = Int.>=;
70
+ (==) = Int.==;
63
71
64
72
65
73
;; Char
71
79
toInt = primitive "Char.toInt";
72
80
fromInt = primitive "Char.fromInt";
73
81
print = primitive "Char.print";
82
+ include PolyEq t;
74
83
};
75
84
type char = Char.t;
76
85
90
99
sub t i = primitive "Text.sub" (t, i);
91
100
fromChar c = primitive "Text.fromChar" c;
92
101
print = primitive "Text.print";
102
+ include PolyEq t;
93
103
};
94
104
type text = Text.t;
95
105
(++) = Text.++;
@@ -186,7 +196,7 @@ List :> LIST =
186
196
filter xs f = foldr xs nil (fun x ys => if f x then cons x ys else ys);
187
197
nth xs n =
188
198
(foldr xs (length xs - 1, none) (fun x (p : (_, _)) =>
189
- (p.1 - 1, if p.1 == n then some x else p.2)
199
+ (p.1 - 1, if Int.== p.1 n then some x else p.2)
190
200
) ).2;
191
201
};
192
202
@@ -215,6 +225,7 @@ type SET =
215
225
Set (Elem : ORD) :> SET with (elem = Elem.t) =
216
226
{
217
227
type elem = Elem.t;
228
+ (==) x y = let include Elem in (x <= y) and (y <= x);
218
229
type set = (int, elem -> bool);
219
230
type t = set;
220
231
empty = (0, fun (x : elem) => false);
@@ -241,6 +252,7 @@ type MAP =
241
252
Map (Key : ORD) :> MAP with (key = Key.t) =
242
253
{
243
254
type key = Key.t;
255
+ (==) x y = let include Key in (x <= y) and (y <= x);
244
256
type map a = key -> opt a;
245
257
t = map;
246
258
empty x = none;
0 commit comments