@@ -198,26 +198,50 @@ let mapper =
198
198
in
199
199
(match reconstruct_args args with
200
200
| Some (xs : string list ) ->
201
- let ans =
202
- List. fold_right
203
- xs
204
- ~f: (fun ident acc ->
201
+ let to_pat ident = Pat. var ~loc (Ast_builder.Default.Located. mk ident ~loc ) in
202
+ let rec loop = function
203
+ | [] -> [% expr delay (fun () -> [% e new_body])]
204
+ | ident1 :: ident2 :: ident3 :: ident4 :: ident5 :: tl ->
205
+ [% expr
206
+ Fresh. five
207
+ (fun
208
+ [%p to_pat ident1 ]
209
+ [%p to_pat ident2 ]
210
+ [%p to_pat ident3 ]
211
+ [%p to_pat ident4 ]
212
+ [%p to_pat ident5 ]
213
+ -> [% e loop tl])]
214
+ | ident1 :: ident2 :: ident3 :: ident4 :: tl ->
215
+ [% expr
216
+ Fresh. four
217
+ (fun
218
+ [%p to_pat ident1 ]
219
+ [%p to_pat ident2 ]
220
+ [%p to_pat ident3 ]
221
+ [%p to_pat ident4 ]
222
+ -> [% e loop tl])]
223
+ | ident1 :: ident2 :: ident3 :: tl ->
224
+ [% expr
225
+ Fresh. three (fun [%p to_pat ident1 ] [%p to_pat ident2 ] [%p to_pat ident3 ] ->
226
+ [% e loop tl])]
227
+ | ident1 :: ident2 :: tl ->
228
+ [% expr Fresh. two (fun [%p to_pat ident1 ] [%p to_pat ident2 ] -> [% e loop tl])]
229
+ | ident :: tl ->
205
230
[% expr
206
231
Fresh. one
207
232
(fun [%p Pat. var ~loc (Ast_builder.Default.Located. mk ident ~loc )] ->
208
- [%e acc ])])
209
- ~init :[%expr delay (fun () -> [%e new_body ])]
233
+ [%e loop tl ])]
210
234
in
211
- ans
235
+ loop xs
212
236
| None ->
213
- Stdlib. Format. eprintf " Can't reconstruct args of 'fresh'" ;
237
+ Format. eprintf " Can't reconstruct args of 'fresh'" ;
214
238
{ e with pexp_desc = Pexp_apply (e1, [ Nolabel , new_body ]) })
215
239
| Pexp_apply (d , [ (_ , body ) ]) when is_defer d ->
216
240
let ans = [% expr delay (fun () -> [% e self#expression body])] in
217
241
ans
218
242
| Pexp_apply (d , body ) when is_unif d ->
219
243
(* let loc_str =
220
- Stdlib .Format.asprintf "%a" Selected_ast.Ast.Location.print_compact e.pexp_loc;
244
+ Caml .Format.asprintf "%a" Selected_ast.Ast.Location.print_compact e.pexp_loc;
221
245
in
222
246
let body = (Labelled "loc", Exp.constant (Pconst_string (loc_str,None))) :: body in *)
223
247
Exp. apply ~loc: e.pexp_loc d body
0 commit comments