@@ -19,8 +19,12 @@ let init () =
19
19
Ast_derive_util. core_type_of_type_declaration tdcl
20
20
in
21
21
let gentype_attrs =
22
- Ext_list. filter core_type.ptyp_attributes
23
- Ast_attributes. is_gentype
22
+ match
23
+ Ext_list. exists core_type.ptyp_attributes
24
+ Ast_attributes. is_gentype
25
+ with
26
+ | true -> Some [Ast_attributes. gentype]
27
+ | false -> None
24
28
in
25
29
match tdcl.ptype_kind with
26
30
| Ptype_record label_declarations ->
@@ -30,7 +34,7 @@ let init () =
30
34
Parsetree.label_declaration )
31
35
->
32
36
let txt = " param" in
33
- Ast_comb. single_non_rec_value ~ attrs: gentype_attrs pld_name
37
+ Ast_comb. single_non_rec_value ? attrs:gentype_attrs pld_name
34
38
(Ast_compatible. fun_
35
39
(Pat. constraint_ (Pat. var {txt; loc}) core_type)
36
40
(Exp. field
@@ -61,7 +65,7 @@ let init () =
61
65
| None -> core_type
62
66
| Some x -> x
63
67
in
64
- Ast_comb. single_non_rec_value ~ attrs: gentype_attrs
68
+ Ast_comb. single_non_rec_value ? attrs:gentype_attrs
65
69
{loc; txt = little_con_name}
66
70
(if arity = 0 then
67
71
(* TODO: add a prefix, better inter-op with FFI *)
@@ -104,13 +108,17 @@ let init () =
104
108
Ast_derive_util. core_type_of_type_declaration tdcl
105
109
in
106
110
let gentype_attrs =
107
- Ext_list. filter core_type.ptyp_attributes
108
- Ast_attributes. is_gentype
111
+ match
112
+ Ext_list. exists core_type.ptyp_attributes
113
+ Ast_attributes. is_gentype
114
+ with
115
+ | true -> Some [Ast_attributes. gentype]
116
+ | false -> None
109
117
in
110
118
match tdcl.ptype_kind with
111
119
| Ptype_record label_declarations ->
112
120
Ext_list. map label_declarations (fun {pld_name; pld_type} ->
113
- Ast_comb. single_non_rec_val ~ attrs: gentype_attrs pld_name
121
+ Ast_comb. single_non_rec_val ? attrs:gentype_attrs pld_name
114
122
(Ast_compatible. arrow core_type pld_type))
115
123
| Ptype_variant constructor_declarations ->
116
124
Ext_list. map constructor_declarations
@@ -132,7 +140,7 @@ let init () =
132
140
| Some x -> x
133
141
| None -> core_type
134
142
in
135
- Ast_comb. single_non_rec_val ~ attrs: gentype_attrs
143
+ Ast_comb. single_non_rec_val ? attrs:gentype_attrs
136
144
{loc; txt = Ext_string. uncapitalize_ascii con_name}
137
145
(Ext_list. fold_right pcd_args annotate_type (fun x acc ->
138
146
Ast_compatible. arrow x acc)))
0 commit comments