doc-src/Codegen/Thy/examples/class.ocaml
changeset 30209 2f4684e2ea95
parent 25182 64e3f45dc6f4
equal deleted inserted replaced
30202:2775062fd3a9 30209:2f4684e2ea95
       
     1 module Nat = 
       
     2 struct
       
     3 
       
     4 type nat = Suc of nat | Zero_nat;;
       
     5 
       
     6 end;; (*struct Nat*)
       
     7 
       
     8 module Codegen = 
       
     9 struct
       
    10 
       
    11 type 'a null = {null : 'a};;
       
    12 let null _A = _A.null;;
       
    13 
       
    14 let rec head _A = function x :: xs -> x
       
    15                   | [] -> null _A;;
       
    16 
       
    17 let rec null_option = None;;
       
    18 
       
    19 let null_optiona () = ({null = null_option} : ('a option) null);;
       
    20 
       
    21 let rec dummy
       
    22   = head (null_optiona ()) [Some (Nat.Suc Nat.Zero_nat); None];;
       
    23 
       
    24 end;; (*struct Codegen*)