7 datatype nat = Zero_nat | Suc of nat;
9 fun eq_nat Zero_nat (Suc m) = false
10 | eq_nat (Suc n) Zero_nat = false
11 | eq_nat (Suc n) (Suc m) = eq_nat n m
12 | eq_nat Zero_nat Zero_nat = true;
14 fun plus_nat (Suc m) n = plus_nat m (Suc n)
15 | plus_nat Zero_nat n = n;
22 fun zip xs (y :: ys) =
23 (case xs of [] => [] | z :: zs => (z, y) :: zip zs ys)
26 fun null (x :: xs) = false
29 fun list_all p (x :: xs) = p x andalso list_all p xs
30 | list_all p [] = true;
32 fun size_list (a :: lista) =
33 Nat.plus_nat (size_list lista) (Nat.Suc Nat.Zero_nat)
34 | size_list [] = Nat.Zero_nat;
36 fun list_all2 p (x :: xs) (y :: ys) = p x y andalso list_all2 p xs ys
37 | list_all2 p xs [] = null xs
38 | list_all2 p [] ys = null ys
40 Nat.eq_nat (size_list xs) (size_list ys) andalso
41 list_all (fn a as (aa, b) => p aa b) (zip xs ys);
48 datatype monotype = Mono of Nat.nat * monotype list;
50 fun eq_monotype (Mono (tyco1, typargs1)) (Mono (tyco2, typargs2)) =
51 Nat.eq_nat tyco1 tyco2 andalso
52 List.list_all2 eq_monotype typargs1 typargs2;
54 end; (*struct Codegen*)