-
Notifications
You must be signed in to change notification settings - Fork 3
/
hazelnut.re
142 lines (121 loc) · 2.39 KB
/
hazelnut.re
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
open Sexplib.Std;
// open Monad_lib.Monad; // Uncomment this line to use the maybe monad
let compare_string = String.compare;
let compare_int = Int.compare;
module Htyp = {
[@deriving (sexp, compare)]
type t =
| Arrow(t, t)
| Num
| Hole;
};
module Hexp = {
[@deriving (sexp, compare)]
type t =
| Var(string)
| Lam(string, t)
| Ap(t, t)
| Lit(int)
| Plus(t, t)
| Asc(t, Htyp.t)
| EHole
| NEHole(t);
};
module Ztyp = {
[@deriving (sexp, compare)]
type t =
| Cursor(Htyp.t)
| LArrow(t, Htyp.t)
| RArrow(Htyp.t, t);
};
module Zexp = {
[@deriving (sexp, compare)]
type t =
| Cursor(Hexp.t)
| Lam(string, t)
| LAp(t, Hexp.t)
| RAp(Hexp.t, t)
| LPlus(t, Hexp.t)
| RPlus(Hexp.t, t)
| LAsc(t, Htyp.t)
| RAsc(Hexp.t, Ztyp.t)
| NEHole(t);
};
module Child = {
[@deriving (sexp, compare)]
type t =
| One
| Two;
};
module Dir = {
[@deriving (sexp, compare)]
type t =
| Child(Child.t)
| Parent;
};
module Shape = {
[@deriving (sexp, compare)]
type t =
| Arrow
| Num
| Asc
| Var(string)
| Lam(string)
| Ap
| Lit(int)
| Plus
| NEHole;
};
module Action = {
[@deriving (sexp, compare)]
type t =
| Move(Dir.t)
| Construct(Shape.t)
| Del
| Finish;
};
module TypCtx = Map.Make(String);
type typctx = TypCtx.t(Htyp.t);
exception Unimplemented;
let erase_exp = (e: Zexp.t): Hexp.t => {
// Used to suppress unused variable warnings
// Okay to remove
let _ = e;
raise(Unimplemented);
};
let syn = (ctx: typctx, e: Hexp.t): option(Htyp.t) => {
// Used to suppress unused variable warnings
// Okay to remove
let _ = ctx;
let _ = e;
raise(Unimplemented);
}
and ana = (ctx: typctx, e: Hexp.t, t: Htyp.t): bool => {
// Used to suppress unused variable warnings
// Okay to remove
let _ = ctx;
let _ = e;
let _ = t;
raise(Unimplemented);
};
let syn_action =
(ctx: typctx, (e: Zexp.t, t: Htyp.t), a: Action.t)
: option((Zexp.t, Htyp.t)) => {
// Used to suppress unused variable warnings
// Okay to remove
let _ = ctx;
let _ = e;
let _ = t;
let _ = a;
raise(Unimplemented);
}
and ana_action =
(ctx: typctx, e: Zexp.t, a: Action.t, t: Htyp.t): option(Zexp.t) => {
// Used to suppress unused variable warnings
// Okay to remove
let _ = ctx;
let _ = e;
let _ = a;
let _ = t;
raise(Unimplemented);
};