@@ -14,6 +14,11 @@ let init () =
14
14
{
15
15
structure_gen =
16
16
(fun (tdcls : tdcls ) _explict_nonrec ->
17
+ let handle_uncurried_fn_tranform ~loc ~arity fn =
18
+ match Config. uncurried.contents with
19
+ | Uncurried -> Ast_uncurried. uncurriedFun ~loc ~arity fn
20
+ | Legacy | Swap -> fn
21
+ in
17
22
let handle_tdcl tdcl =
18
23
let core_type =
19
24
Ast_derive_util. core_type_of_type_declaration tdcl
@@ -39,7 +44,9 @@ let init () =
39
44
(Pat. constraint_ (Pat. var {txt; loc}) core_type)
40
45
(Exp. field
41
46
(Exp. ident {txt = Lident txt; loc})
42
- {txt = Longident. Lident pld_label; loc})))
47
+ {txt = Longident. Lident pld_label; loc})
48
+ (* arity will alwys be 1 since these are single param functions*)
49
+ |> handle_uncurried_fn_tranform ~arity: 1 ~loc ))
43
50
| Ptype_variant constructor_declarations ->
44
51
Ext_list. map constructor_declarations
45
52
(fun
@@ -94,7 +101,8 @@ let init () =
94
101
annotate_type
95
102
in
96
103
Ext_list. fold_right vars exp (fun var b ->
97
- Ast_compatible. fun_ (Pat. var {loc; txt = var}) b)))
104
+ Ast_compatible. fun_ (Pat. var {loc; txt = var}) b)
105
+ |> handle_uncurried_fn_tranform ~loc ~arity ))
98
106
| Ptype_abstract | Ptype_open ->
99
107
Ast_derive_util. notApplicable tdcl.ptype_loc derivingName;
100
108
[]
@@ -103,6 +111,11 @@ let init () =
103
111
Ext_list. flat_map tdcls handle_tdcl);
104
112
signature_gen =
105
113
(fun (tdcls : Parsetree.type_declaration list ) _explict_nonrec ->
114
+ let handle_uncurried_type_tranform ~loc ~arity t =
115
+ match Config. uncurried.contents with
116
+ | Uncurried -> Ast_uncurried. uncurriedType ~loc ~arity t
117
+ | Legacy | Swap -> t
118
+ in
106
119
let handle_tdcl tdcl =
107
120
let core_type =
108
121
Ast_derive_util. core_type_of_type_declaration tdcl
@@ -119,7 +132,10 @@ let init () =
119
132
| Ptype_record label_declarations ->
120
133
Ext_list. map label_declarations (fun {pld_name; pld_type} ->
121
134
Ast_comb. single_non_rec_val ?attrs:gentype_attrs pld_name
122
- (Ast_compatible. arrow core_type pld_type))
135
+ (Ast_compatible. arrow core_type pld_type
136
+ (* arity will alwys be 1 since these are single param functions*)
137
+ |> handle_uncurried_type_tranform ~arity: 1
138
+ ~loc: pld_name.loc))
123
139
| Ptype_variant constructor_declarations ->
124
140
Ext_list. map constructor_declarations
125
141
(fun
@@ -135,6 +151,7 @@ let init () =
135
151
| Pcstr_tuple pcd_args -> pcd_args
136
152
| Pcstr_record _ -> assert false
137
153
in
154
+ let arity = pcd_args |> List. length in
138
155
let annotate_type =
139
156
match pcd_res with
140
157
| Some x -> x
@@ -143,7 +160,8 @@ let init () =
143
160
Ast_comb. single_non_rec_val ?attrs:gentype_attrs
144
161
{loc; txt = Ext_string. uncapitalize_ascii con_name}
145
162
(Ext_list. fold_right pcd_args annotate_type (fun x acc ->
146
- Ast_compatible. arrow x acc)))
163
+ Ast_compatible. arrow x acc)
164
+ |> handle_uncurried_type_tranform ~arity ~loc ))
147
165
| Ptype_open | Ptype_abstract ->
148
166
Ast_derive_util. notApplicable tdcl.ptype_loc derivingName;
149
167
[]
0 commit comments