21147
|
1 |
structure ROOT =
|
|
2 |
struct
|
|
3 |
|
|
4 |
structure Code_Generator =
|
|
5 |
struct
|
|
6 |
|
21452
|
7 |
type 'a eq = {op_eq_ : 'a -> 'a -> bool};
|
|
8 |
fun op_eq (A_:'a eq) = #op_eq_ A_;
|
21147
|
9 |
|
|
10 |
end; (*struct Code_Generator*)
|
|
11 |
|
|
12 |
structure Product_Type =
|
|
13 |
struct
|
|
14 |
|
21452
|
15 |
fun op_eq_prod (A_:'a Code_Generator.eq) (B_:'b Code_Generator.eq) (x1, y1)
|
|
16 |
(x2, y2) =
|
|
17 |
Code_Generator.op_eq A_ x1 x2 andalso Code_Generator.op_eq B_ y1 y2;
|
21147
|
18 |
|
|
19 |
end; (*struct Product_Type*)
|
|
20 |
|
|
21 |
structure Orderings =
|
|
22 |
struct
|
|
23 |
|
21190
|
24 |
type 'a ord = {less_eq_ : 'a -> 'a -> bool, less_ : 'a -> 'a -> bool};
|
|
25 |
fun less_eq (A_:'a ord) = #less_eq_ A_;
|
|
26 |
fun less (A_:'a ord) = #less_ A_;
|
21147
|
27 |
|
|
28 |
end; (*struct Orderings*)
|
|
29 |
|
|
30 |
structure Codegen =
|
|
31 |
struct
|
|
32 |
|
21190
|
33 |
fun less_prod (B_:'b Code_Generator.eq * 'b Orderings.ord)
|
|
34 |
(C_:'c Code_Generator.eq * 'c Orderings.ord) p1 p2 =
|
21147
|
35 |
let
|
|
36 |
val (x1a, y1a) = p1;
|
|
37 |
val (x2a, y2a) = p2;
|
|
38 |
in
|
21190
|
39 |
Orderings.less (#2 B_) x1a x2a orelse
|
21452
|
40 |
Code_Generator.op_eq (#1 B_) x1a x2a andalso
|
21190
|
41 |
Orderings.less (#2 C_) y1a y2a
|
21147
|
42 |
end;
|
|
43 |
|
21190
|
44 |
fun less_eq_prod (B_:'b Code_Generator.eq * 'b Orderings.ord)
|
|
45 |
(C_:'c Code_Generator.eq * 'c Orderings.ord) p1 p2 =
|
|
46 |
less_prod ((#1 B_), (#2 B_)) ((#1 C_), (#2 C_)) p1 p2 orelse
|
21452
|
47 |
Product_Type.op_eq_prod (#1 B_) (#1 C_) p1 p2;
|
21147
|
48 |
|
|
49 |
end; (*struct Codegen*)
|
|
50 |
|
|
51 |
end; (*struct ROOT*)
|