author | wenzelm |
Thu, 19 Jul 2007 23:18:46 +0200 | |
changeset 23862 | b1861768d8f4 |
parent 23850 | f1434532a562 |
child 24421 | acfb2413faa3 |
permissions | -rw-r--r-- |
21190 | 1 |
structure Nat = |
21147 | 2 |
struct |
3 |
||
21190 | 4 |
datatype nat = Zero_nat | Suc of nat; |
21147 | 5 |
|
21190 | 6 |
end; (*struct Nat*) |
21147 | 7 |
|
8 |
structure Codegen = |
|
9 |
struct |
|
10 |
||
22386 | 11 |
type 'a null = {null : 'a}; |
12 |
fun null (A_:'a null) = #null A_; |
|
21147 | 13 |
|
22798 | 14 |
fun head B_ (x :: xs) = x |
15 |
| head B_ [] = null B_; |
|
21147 | 16 |
|
22188
a63889770d57
adjusted manual to improved treatment of overloaded constants
haftmann
parents:
21994
diff
changeset
|
17 |
val null_option : 'a option = NONE; |
21147 | 18 |
|
22386 | 19 |
fun null_optiona () = {null = null_option} : ('b option) null; |
21147 | 20 |
|
21190 | 21 |
val dummy : Nat.nat option = |
22 |
head (null_optiona ()) [SOME (Nat.Suc Nat.Zero_nat), NONE]; |
|
21147 | 23 |
|
24 |
end; (*struct Codegen*) |