@@ -13,18 +13,18 @@ struct
13
13
let bind_var nm tp k =
14
14
Reader. scope (fun env -> Snoc (env, (nm, tp))) k
15
15
16
- let lookup ? loc nm =
16
+ let lookup nm =
17
17
let ctx = Reader. read () in
18
18
match Bwd. find_opt (fun (nm' , _ ) -> String. equal nm nm') ctx with
19
19
| Some (_ , tp ) -> tp
20
20
| None ->
21
- Reporter. fatalf ?loc ` UnboundVariable " variable '%s' is not in scope" nm
21
+ Reporter. fatalf UnboundVariable " variable '%s' is not in scope" nm
22
22
23
- let expected_connective ? loc conn tp =
24
- Reporter. fatalf ?loc ` TypeError " expected a %s, but got %a" conn pp_tp tp
23
+ let expected_connective conn tp =
24
+ Reporter. fatalf TypeError " expected a %s, but got %a" conn pp_tp tp
25
25
26
- let rec equate ? loc expected actual =
27
- Reporter. tracef ?loc " when equating terms" @@ fun () ->
26
+ let rec equate expected actual =
27
+ Reporter. trace " when equating terms" @@ fun () ->
28
28
match expected, actual with
29
29
| Fun (a0 , b0 ), Fun (a1 , b1 ) ->
30
30
equate a0 a1;
35
35
| Nat , Nat ->
36
36
()
37
37
| _ , _ ->
38
- Reporter. fatalf ?loc ` TypeError " expected type %a, but got %a" pp_tp expected pp_tp actual
38
+ Reporter. fatalf TypeError " expected type %a, but got %a" pp_tp expected pp_tp actual
39
39
40
40
let rec chk (tm : tm ) (tp : tp ) : unit =
41
41
Reporter. tracef ?loc:tm.loc " when checking it against %a" Syntax. pp_tp tp @@ fun () ->
@@ -44,53 +44,53 @@ struct
44
44
bind_var nm a @@ fun () ->
45
45
chk body b
46
46
| Lam (_ , _ ), _ ->
47
- expected_connective ?loc:tm.loc " function type" tp
47
+ expected_connective " function type" tp
48
48
| Pair (l , r ), Tuple (a , b ) ->
49
49
chk l a;
50
50
chk r b;
51
51
| Pair (_ , _ ), _ ->
52
- expected_connective ?loc:tm.loc " pair type" tp
52
+ expected_connective " pair type" tp
53
53
| Lit _ , Nat ->
54
54
()
55
55
| Lit _ , _ ->
56
- expected_connective ?loc:tm.loc " ℕ" tp
56
+ expected_connective " ℕ" tp
57
57
| Suc n , Nat ->
58
58
chk n Nat
59
59
| Suc _ , _ ->
60
- expected_connective ?loc:tm.loc " ℕ" tp
60
+ expected_connective " ℕ" tp
61
61
| _ ->
62
62
let actual_tp = syn tm in
63
- equate ?loc:tm.loc tp actual_tp
63
+ equate tp actual_tp
64
64
65
65
and syn (tm : tm ) : tp =
66
- Reporter. tracef ?loc:tm.loc " when synthesizing its type" @@ fun () ->
66
+ Reporter. trace ?loc:tm.loc " when synthesizing its type" @@ fun () ->
67
67
match tm.value with
68
68
| Var nm ->
69
- lookup ?loc:tm.loc nm
69
+ lookup nm
70
70
| Ap (fn , arg ) ->
71
71
begin
72
72
match syn fn with
73
73
| Fun (a , b ) ->
74
74
chk arg a;
75
75
b
76
76
| tp ->
77
- expected_connective ?loc:tm.loc " function type" tp
77
+ expected_connective " function type" tp
78
78
end
79
79
| Fst tm ->
80
80
begin
81
81
match syn tm with
82
82
| Tuple (l , _ ) ->
83
83
l
84
84
| tp ->
85
- expected_connective ?loc:tm.loc " pair type" tp
85
+ expected_connective " pair type" tp
86
86
end
87
87
| Snd tm ->
88
88
begin
89
89
match syn tm with
90
90
| Tuple (_ , r ) ->
91
91
r
92
92
| tp ->
93
- expected_connective ?loc:tm.loc " pair type" tp
93
+ expected_connective " pair type" tp
94
94
end
95
95
| NatRec (z , s , scrut ) ->
96
96
begin
@@ -100,7 +100,7 @@ struct
100
100
mot
101
101
end
102
102
| _ ->
103
- Reporter. fatalf ?loc:tm.loc ` TypeError " unable to infer its type"
103
+ Reporter. fatal TypeError " unable to infer its type"
104
104
end
105
105
106
106
module Driver =
@@ -111,12 +111,10 @@ struct
111
111
let (tm, tp) =
112
112
try Grammar. defn Lex. token lexbuf with
113
113
| Lex. SyntaxError tok ->
114
- Reporter. fatalf ~loc: (Asai.Range. of_lexbuf lexbuf) `LexingError " unrecognized token %S" tok
114
+ Reporter. fatalf ~loc: (Asai.Range. of_lexbuf lexbuf) ParsingError " unrecognized token %S" tok
115
115
| Grammar. Error ->
116
- Reporter. fatalf ~loc: (Asai.Range. of_lexbuf lexbuf) `LexingError " failed to parse"
117
- in
118
- Elab.Reader. run ~env: Emp @@ fun () ->
119
- Elab. chk tm tp
116
+ Reporter. fatal ~loc: (Asai.Range. of_lexbuf lexbuf) ParsingError " failed to parse"
117
+ in Elab.Reader. run ~env: Emp @@ fun () -> Elab. chk tm tp
120
118
121
119
let load mode filepath =
122
120
let display : Reporter.Message.t Asai.Diagnostic.t -> unit =
0 commit comments