Skip to content

Commit a8c9fec

Browse files
committed
More Typ.arrows
1 parent bf9b986 commit a8c9fec

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

compiler/frontend/ast_derive_abstract.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ let handle_tdcl light (tdcl : Parsetree.type_declaration) :
125125
let accessor_type =
126126
if is_optional then
127127
let optional_type = Ast_core_type.lift_option_type pld_type in
128-
Ast_helper.Typ.arrow ~loc ~arity:(Some 1)
129-
{attrs = []; lbl = Nolabel; typ = core_type}
128+
Ast_helper.Typ.arrows ~loc
129+
[{attrs = []; lbl = Nolabel; typ = core_type}]
130130
optional_type
131131
else
132-
Ast_helper.Typ.arrow ~loc ~arity:(Some 1)
133-
{attrs = []; lbl = Nolabel; typ = core_type}
132+
Ast_helper.Typ.arrows ~loc
133+
[{attrs = []; lbl = Nolabel; typ = core_type}]
134134
pld_type
135135
in
136136
let accessor_prim =

compiler/frontend/ast_derive_js_mapper.ml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ let erase_type_str =
6969
Str.primitive
7070
(Val.mk ~prim:["%identity"]
7171
{loc = noloc; txt = erase_type_lit}
72-
(Ast_helper.Typ.arrow ~arity:(Some 1)
73-
{attrs = []; lbl = Nolabel; typ = any}
74-
any))
72+
(Ast_helper.Typ.arrows [{attrs = []; lbl = Nolabel; typ = any}] any))
7573

7674
let unsafe_index = "_index"
7775

@@ -81,11 +79,12 @@ let unsafe_index_get =
8179
(Val.mk ~prim:[""]
8280
{loc = noloc; txt = unsafe_index}
8381
~attrs:[Ast_attributes.get_index]
84-
(Ast_helper.Typ.arrow ~arity:None
85-
{attrs = []; lbl = Nolabel; typ = any}
86-
(Ast_helper.Typ.arrow ~arity:None
87-
{attrs = []; lbl = Nolabel; typ = any}
88-
any)))
82+
(Ast_helper.Typ.arrows
83+
[
84+
{attrs = []; lbl = Nolabel; typ = any};
85+
{attrs = []; lbl = Nolabel; typ = any};
86+
]
87+
any))
8988

9089
let unsafe_index_get_exp = Exp.ident {loc = noloc; txt = Lident unsafe_index}
9190

@@ -136,8 +135,7 @@ let app1 = Ast_compatible.app1
136135

137136
let app2 = Ast_compatible.app2
138137

139-
let ( ->~ ) a b =
140-
Ast_helper.Typ.arrow ~arity:(Some 1) {attrs = []; lbl = Nolabel; typ = a} b
138+
let ( ->~ ) a b = Ast_helper.Typ.arrows [{attrs = []; lbl = Nolabel; typ = a}] b
141139

142140
let raise_when_not_found_ident =
143141
Longident.Ldot (Lident Primitive_modules.util, "raiseWhenNotFound")
@@ -309,8 +307,8 @@ let init () =
309307
let pat_from_js = {Asttypes.loc; txt = from_js} in
310308
let to_js_type result =
311309
Ast_comb.single_non_rec_val pat_to_js
312-
(Ast_helper.Typ.arrow ~arity:(Some 1)
313-
{attrs = []; lbl = Nolabel; typ = core_type}
310+
(Ast_helper.Typ.arrows
311+
[{attrs = []; lbl = Nolabel; typ = core_type}]
314312
result)
315313
in
316314
let new_type, new_tdcl =

compiler/frontend/ast_derive_projector.ml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ let init () =
136136
| Ptype_record label_declarations ->
137137
Ext_list.map label_declarations (fun {pld_name; pld_type} ->
138138
Ast_comb.single_non_rec_val ?attrs:gentype_attrs pld_name
139-
(Ast_helper.Typ.arrow ~arity:(Some 1)
140-
{attrs = []; lbl = Nolabel; typ = core_type}
139+
(Ast_helper.Typ.arrows
140+
[{attrs = []; lbl = Nolabel; typ = core_type}]
141141
pld_type
142142
(*arity will alwys be 1 since these are single param functions*)))
143143
| Ptype_variant constructor_declarations ->
@@ -156,23 +156,19 @@ let init () =
156156
| Pcstr_record _ ->
157157
raise_unsupported_vaiant_record_arg pcd_loc
158158
in
159-
let arity = pcd_args |> List.length in
160159
let annotate_type =
161160
match pcd_res with
162161
| Some x -> x
163162
| None -> core_type
164163
in
165-
let add_arity ~arity t =
166-
if arity > 0 then Ast_uncurried.uncurried_type ~arity t
167-
else t
168-
in
169164
Ast_comb.single_non_rec_val ?attrs:gentype_attrs
170165
{loc; txt = Ext_string.uncapitalize_ascii con_name}
171-
(Ext_list.fold_right pcd_args annotate_type (fun x acc ->
172-
Ast_helper.Typ.arrow ~arity:None
173-
{attrs = []; lbl = Nolabel; typ = x}
174-
acc)
175-
|> add_arity ~arity))
166+
(let args =
167+
Ext_list.map pcd_args (fun x ->
168+
({attrs = []; lbl = Nolabel; typ = x}
169+
: Parsetree.arg))
170+
in
171+
Ast_helper.Typ.arrows ~loc args annotate_type))
176172
| Ptype_open | Ptype_abstract ->
177173
Ast_derive_util.not_applicable tdcl.ptype_loc deriving_name;
178174
[]

0 commit comments

Comments
 (0)