blob: 8041e8aa1f3f085db957ec6c223708c6f4cadae4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
default Order dec
$include <flow.sail>
val print = "print_endline" : string -> unit
val "print_int" : (string, int) -> unit
val "print_bits" : forall 'n. (string, bitvector('n, dec)) -> unit
union option ('a : Type) = {
None : unit,
Some : 'a
}
union soption ('a : Type) = {
sNone : unit,
sSome : 'a
}
val main : unit -> unit
function main () = {
let x : option(int) = Some(5);
let y : option(int) = None();
let z : option(bitvector(4, dec)) = Some(0xF);
match x {
Some(a) => print_int("a = ", 5),
None() => print("None")
};
match z {
Some(b) => print_bits("b = ", b),
None() => print("None")
};
let q : soption(bitvector(4, dec)) = sSome(0xA);
match q {
sSome(c) => print_bits("c = ", c)
}
}
|