doc-src/Codegen/Thy/examples/class.ocaml
changeset 30209 2f4684e2ea95
parent 25182 64e3f45dc6f4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/doc-src/Codegen/Thy/examples/class.ocaml	Tue Mar 03 11:00:51 2009 +0100
     1.3 @@ -0,0 +1,24 @@
     1.4 +module Nat = 
     1.5 +struct
     1.6 +
     1.7 +type nat = Suc of nat | Zero_nat;;
     1.8 +
     1.9 +end;; (*struct Nat*)
    1.10 +
    1.11 +module Codegen = 
    1.12 +struct
    1.13 +
    1.14 +type 'a null = {null : 'a};;
    1.15 +let null _A = _A.null;;
    1.16 +
    1.17 +let rec head _A = function x :: xs -> x
    1.18 +                  | [] -> null _A;;
    1.19 +
    1.20 +let rec null_option = None;;
    1.21 +
    1.22 +let null_optiona () = ({null = null_option} : ('a option) null);;
    1.23 +
    1.24 +let rec dummy
    1.25 +  = head (null_optiona ()) [Some (Nat.Suc Nat.Zero_nat); None];;
    1.26 +
    1.27 +end;; (*struct Codegen*)