doc-src/IsarAdvanced/Codegen/Thy/examples/monotype.ML
author wenzelm
Tue, 18 Mar 2008 20:34:26 +0100
changeset 26318 967323f93c67
parent 25731 b3e415b0cf5c
child 26513 6f306c8c2c54
permissions -rw-r--r--
updated generated files;
     1 structure Nat = 
     2 struct
     3 
     4 datatype nat = Suc of nat | Zero_nat;
     5 
     6 fun eqop_nat Zero_nat Zero_nat = true
     7   | eqop_nat (Suc m) (Suc n) = eqop_nat m n
     8   | eqop_nat Zero_nat (Suc a) = false
     9   | eqop_nat (Suc a) Zero_nat = false;
    10 
    11 end; (*struct Nat*)
    12 
    13 structure List = 
    14 struct
    15 
    16 fun null (x :: xs) = false
    17   | null [] = true;
    18 
    19 fun list_all2 p (x :: xs) (y :: ys) = p x y andalso list_all2 p xs ys
    20   | list_all2 p xs [] = null xs
    21   | list_all2 p [] ys = null ys;
    22 
    23 end; (*struct List*)
    24 
    25 structure Codegen = 
    26 struct
    27 
    28 datatype monotype = Mono of Nat.nat * monotype list;
    29 
    30 fun eqop_monotype (Mono (tyco1, typargs1)) (Mono (tyco2, typargs2)) =
    31   Nat.eqop_nat tyco1 tyco2 andalso
    32     List.list_all2 eqop_monotype typargs1 typargs2;
    33 
    34 end; (*struct Codegen*)