@@ -42,8 +42,8 @@ let handle_external loc (x : string) : Parsetree.expression =
42
42
pexp_desc =
43
43
Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_expr" ]
44
44
~pval_type:
45
- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
46
- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
45
+ (Ast_helper.Typ. arrows
46
+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
47
47
(Ast_helper.Typ. any () ))
48
48
[str_exp];
49
49
}
@@ -71,8 +71,8 @@ let handle_debugger loc (payload : Ast_payload.t) =
71
71
| PStr [] ->
72
72
Ast_external_mk. local_external_apply loc ~pval_prim: [" %debugger" ]
73
73
~pval_type:
74
- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
75
- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
74
+ (Ast_helper.Typ. arrows
75
+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
76
76
(Ast_literal. type_unit () ))
77
77
[Ast_literal. val_unit ~loc () ]
78
78
| _ ->
@@ -98,8 +98,8 @@ let handle_raw ~kind loc payload =
98
98
pexp_desc =
99
99
Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_expr" ]
100
100
~pval_type:
101
- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
102
- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
101
+ (Ast_helper.Typ. arrows
102
+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
103
103
(Ast_helper.Typ. any () ))
104
104
[exp];
105
105
pexp_attributes =
@@ -125,20 +125,13 @@ let handle_ffi ~loc ~payload =
125
125
let wrap_type_constraint (e : Parsetree.expression ) =
126
126
let loc = e.pexp_loc in
127
127
let any = Ast_helper.Typ. any ~loc: e.pexp_loc () in
128
- let unit = Ast_literal. type_unit ~loc () in
129
- let rec arrow ~arity =
130
- if arity = 0 then
131
- Ast_helper.Typ. arrow ~arity: None ~loc
132
- {attrs = [] ; lbl = Nolabel ; typ = unit }
133
- any
134
- else if arity = 1 then
135
- Ast_helper.Typ. arrow ~arity: None ~loc
136
- {attrs = [] ; lbl = Nolabel ; typ = any}
137
- any
138
- else
139
- Ast_helper.Typ. arrow ~loc ~arity: None
140
- {attrs = [] ; lbl = Nolabel ; typ = any}
141
- (arrow ~arity: (arity - 1 ))
128
+ let arrow ~arity =
129
+ let effective_arity = if arity = 0 then 1 else arity in
130
+ let args =
131
+ Ext_list. init effective_arity (fun _ ->
132
+ ({attrs = [] ; lbl = Nolabel ; typ = any} : Parsetree.arg ))
133
+ in
134
+ Ast_helper.Typ. arrows ~loc args any
142
135
in
143
136
match ! is_function with
144
137
| Some arity ->
@@ -156,8 +149,8 @@ let handle_ffi ~loc ~payload =
156
149
pexp_desc =
157
150
Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_expr" ]
158
151
~pval_type:
159
- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
160
- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
152
+ (Ast_helper.Typ. arrows
153
+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
161
154
(Ast_helper.Typ. any () ))
162
155
[exp];
163
156
pexp_attributes =
@@ -175,8 +168,8 @@ let handle_raw_structure loc payload =
175
168
pexp_desc =
176
169
Ast_external_mk. local_external_apply loc ~pval_prim: [" #raw_stmt" ]
177
170
~pval_type:
178
- (Ast_helper.Typ. arrow ~arity: ( Some 1 )
179
- {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }
171
+ (Ast_helper.Typ. arrows
172
+ [ {attrs = [] ; lbl = Nolabel ; typ = Ast_helper.Typ. any () }]
180
173
(Ast_helper.Typ. any () ))
181
174
[exp];
182
175
}
0 commit comments