-
Notifications
You must be signed in to change notification settings - Fork 6
/
test33.dats
79 lines (59 loc) · 1.35 KB
/
test33.dats
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(*
// HX-2105-12-29:
** For answering the following question:
** https://groups.google.com/forum/?fromgroups#!topic/ats-lang-users/k7qXXrCvmsA
*)
(* ****** ****** *)
typedef address = int
typedef data = int
typedef delay = int
typedef speed = int
(* ****** ****** *)
datasort cmdst = run | wait | composite
(* ****** ****** *)
datatype
command(cmdst) =
| RunFast(run) of (address, data)
| RunSlow(run) of (address, data, speed)
| WaitDelay(wait) of delay
| Composite(composite) of List0(command0)
where command0 = [k:cmdst] command(k)
(* ****** ****** *)
fun
execute_run : command(run) -> void = lam _ => ()
fun
execute_wait : command(wait) -> void = lam _ => ()
fun
execute_composite : command(composite) -> void = lam _ => ()
(* ****** ****** *)
fun
execute(cs: List0(command0)): void =
(
case+ cs of
| nil() => ()
| cons(c, cs) => let
val () =
(
case+ c of
| RunFast _ => execute_run(c)
| RunSlow _ => execute_run(c)
| WaitDelay _ => execute_wait(c)
| Composite _ => execute_composite(c)
)
in
execute(cs)
end
)
(* ****** ****** *)
val c =
Composite
(
$list{command0}(RunFast(0x90, 0x7765), WaitDelay(50))
)
val cs = $list{command0}(c, c, c)
(* ****** ****** *)
val () = execute(cs)
(* ****** ****** *)
implement main0() = ()
(* ****** ****** *)
(* end of [test33.dats] *)