doc-src/Codegen/Thy/examples/class.ML
author haftmann
Fri, 02 Mar 2012 18:26:54 +0100
changeset 46765 07f9eda810b3
parent 30226 2f4684e2ea95
permissions -rw-r--r--
tuned whitespace

structure Nat = 
struct

datatype nat = Suc of nat | Zero_nat;

end; (*struct Nat*)

structure Codegen = 
struct

type 'a null = {null : 'a};
fun null (A_:'a null) = #null A_;

fun head A_ (x :: xs) = x
  | head A_ [] = null A_;

val null_option : 'a option = NONE;

fun null_optiona () = {null = null_option} : ('a option) null;

val dummy : Nat.nat option =
  head (null_optiona ()) [SOME (Nat.Suc Nat.Zero_nat), NONE];

end; (*struct Codegen*)