doc-src/Codegen/Thy/examples/class.ocaml
author haftmann
Tue, 03 Mar 2009 11:00:51 +0100
changeset 30209 2f4684e2ea95
parent 25182 doc-src/IsarAdvanced/Codegen/Thy/examples/class.ocaml@64e3f45dc6f4
permissions -rw-r--r--
more canonical directory structure of manuals
     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*)