summaryrefslogtreecommitdiff
blob: d5f961dae6223580def13b6fd251f0ebdf3a7733 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
diff -uNr ppx_core-113.33.00/_oasis ppx_core-113.33.00+4.03/_oasis
--- ppx_core-113.33.00/_oasis	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/_oasis	2016-03-23 17:20:19.000000000 +0100
@@ -1,8 +1,8 @@
 OASISFormat:      0.4
-OCamlVersion:     >= 4.02.3
+OCamlVersion:     >= 4.03.0
 FindlibVersion:   >= 1.3.2
 Name:             ppx_core
-Version:          113.33.00
+Version:          113.33.00+4.03
 Synopsis:         Standard library for ppx rewriters
 Authors:          Jane Street Group, LLC <opensource@janestreet.com>
 Copyrights:       (C) 2015-2016 Jane Street Group LLC <opensource@janestreet.com>
diff -uNr ppx_core-113.33.00/src/ast_builder.ml ppx_core-113.33.00+4.03/src/ast_builder.ml
--- ppx_core-113.33.00/src/ast_builder.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/ast_builder.ml	2016-03-23 17:20:19.000000000 +0100
@@ -28,21 +28,21 @@
                 ({ txt = "nonrec"; loc }, PStr []) :: td.ptype_attributes }
   ;;
 
-  let eint ~loc t = pexp_constant ~loc (Const_int t)
-  let echar ~loc t = pexp_constant ~loc (Const_char t)
-  let estring ~loc t = pexp_constant ~loc (Const_string (t, None))
-  let efloat ~loc t = pexp_constant ~loc (Const_float t)
-  let eint32 ~loc t = pexp_constant ~loc (Const_int32 t)
-  let eint64 ~loc t = pexp_constant ~loc (Const_int64 t)
-  let enativeint ~loc t = pexp_constant ~loc (Const_nativeint t)
-
-  let pint ~loc t = ppat_constant ~loc (Const_int t)
-  let pchar ~loc t = ppat_constant ~loc (Const_char t)
-  let pstring ~loc t = ppat_constant ~loc (Const_string (t, None))
-  let pfloat ~loc t = ppat_constant ~loc (Const_float t)
-  let pint32 ~loc t = ppat_constant ~loc (Const_int32 t)
-  let pint64 ~loc t = ppat_constant ~loc (Const_int64 t)
-  let pnativeint ~loc t = ppat_constant ~loc (Const_nativeint t)
+  let eint ~loc t = pexp_constant ~loc (Pconst_integer (string_of_int t, None))
+  let echar ~loc t = pexp_constant ~loc (Pconst_char t)
+  let estring ~loc t = pexp_constant ~loc (Pconst_string (t, None))
+  let efloat ~loc t = pexp_constant ~loc (Pconst_float (t, None))
+  let eint32 ~loc t = pexp_constant ~loc (Pconst_integer (Int32.to_string t, Some 'l'))
+  let eint64 ~loc t = pexp_constant ~loc (Pconst_integer (Int64.to_string t, Some 'L'))
+  let enativeint ~loc t = pexp_constant ~loc (Pconst_integer (Nativeint.to_string t, Some 'n'))
+
+  let pint ~loc t = ppat_constant ~loc (Pconst_integer (string_of_int t, None))
+  let pchar ~loc t = ppat_constant ~loc (Pconst_char t)
+  let pstring ~loc t = ppat_constant ~loc (Pconst_string (t, None))
+  let pfloat ~loc t = ppat_constant ~loc (Pconst_float (t, None))
+  let pint32 ~loc t = ppat_constant ~loc (Pconst_integer (Int32.to_string t, Some 'l'))
+  let pint64 ~loc t = ppat_constant ~loc (Pconst_integer (Int64.to_string t, Some 'L'))
+  let pnativeint ~loc t = ppat_constant ~loc (Pconst_integer (Nativeint.to_string t, Some 'n'))
 
   let ebool ~loc t = pexp_construct ~loc (Located.lident ~loc (string_of_bool t)) None
   let pbool ~loc t = ppat_construct ~loc (Located.lident ~loc (string_of_bool t)) None
@@ -77,10 +77,11 @@
     | _ -> pexp_apply ~loc e el
   ;;
 
-  let eapply ~loc e el = pexp_apply ~loc e (List.map el ~f:(fun e -> ("", e)))
+  let eapply ~loc e el =
+    pexp_apply ~loc e (List.map el ~f:(fun e -> (Asttypes.Nolabel, e)))
 
   let eabstract ~loc ps e =
-    List.fold_right ps ~init:e ~f:(fun p e -> pexp_fun ~loc "" None p e)
+    List.fold_right ps ~init:e ~f:(fun p e -> pexp_fun ~loc Asttypes.Nolabel None p e)
   ;;
 
   let pconstruct cd arg = ppat_construct ~loc:cd.pcd_loc (Located.map_lident cd.pcd_name) arg
diff -uNr ppx_core-113.33.00/src/ast_pattern.ml ppx_core-113.33.00+4.03/src/ast_pattern.ml
--- ppx_core-113.33.00/src/ast_pattern.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/ast_pattern.ml	2016-03-23 17:20:19.000000000 +0100
@@ -80,6 +80,13 @@
 
 let ( >>| ) t f = map t ~f
 
+let map0 (T func) ~f = T (fun ctx loc x k -> func ctx loc x (           k  f     ))
+let map1 (T func) ~f = T (fun ctx loc x k -> func ctx loc x (fun a   -> k (f a  )))
+let map2 (T func) ~f = T (fun ctx loc x k -> func ctx loc x (fun a b -> k (f a b)))
+
+let alt_option some none =
+  alt (map1 some ~f:(fun x -> Some x)) (map0 none ~f:None)
+
 let many (T f) = T (fun ctx loc l k ->
   k (List.map l ~f:(fun x -> f ctx loc x (fun x -> x))))
 ;;
@@ -96,25 +103,37 @@
 
 let ( ^:: ) = cons
 
-let eint       t = pexp_constant (const_int t)
-let echar      t = pexp_constant (const_char t)
-let estring    t = pexp_constant (const_string t drop)
-let efloat     t = pexp_constant (const_float t)
-let eint32     t = pexp_constant (const_int32 t)
-let eint64     t = pexp_constant (const_int64 t)
+let echar      t = pexp_constant (pconst_char   t     )
+let estring    t = pexp_constant (pconst_string t drop)
+let efloat     t = pexp_constant (pconst_float  t drop)
+
+let pchar      t = ppat_constant (pconst_char   t     )
+let pstring    t = ppat_constant (pconst_string t drop)
+let pfloat     t = ppat_constant (pconst_float  t drop)
+
+let int'       (T f) = T (fun ctx loc x k -> f ctx loc (int_of_string       x) k)
+let int32'     (T f) = T (fun ctx loc x k -> f ctx loc (Int32.of_string     x) k)
+let int64'     (T f) = T (fun ctx loc x k -> f ctx loc (Int64.of_string     x) k)
+let nativeint' (T f) = T (fun ctx loc x k -> f ctx loc (Nativeint.of_string x) k)
+
+let const_int       t = pconst_integer (int'       t) none
+let const_int32     t = pconst_integer (int32'     t) (some (char 'l'))
+let const_int64     t = pconst_integer (int64'     t) (some (char 'L'))
+let const_nativeint t = pconst_integer (nativeint' t) (some (char 'n'))
+
+let eint       t = pexp_constant (const_int       t)
+let eint32     t = pexp_constant (const_int32     t)
+let eint64     t = pexp_constant (const_int64     t)
 let enativeint t = pexp_constant (const_nativeint t)
 
-let pint       t = ppat_constant (const_int t)
-let pchar      t = ppat_constant (const_char t)
-let pstring    t = ppat_constant (const_string t drop)
-let pfloat     t = ppat_constant (const_float t)
-let pint32     t = ppat_constant (const_int32 t)
-let pint64     t = ppat_constant (const_int64 t)
+let pint       t = ppat_constant (const_int       t)
+let pint32     t = ppat_constant (const_int32     t)
+let pint64     t = ppat_constant (const_int64     t)
 let pnativeint t = ppat_constant (const_nativeint t)
 
 let single_expr_payload t = pstr (pstr_eval t nil ^:: nil)
 
-let no_label t = string "" ** t
+let no_label t = (cst Asttypes.Nolabel ~to_string:(fun _ -> "Nolabel")) ** t
 
 let attribute (T f1) (T f2) = T (fun ctx loc ((name : _ Location.loc), payload) k ->
   let k = f1 ctx name.loc name.txt k in
diff -uNr ppx_core-113.33.00/src/ast_pattern.mli ppx_core-113.33.00+4.03/src/ast_pattern.mli
--- ppx_core-113.33.00/src/ast_pattern.mli	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/ast_pattern.mli	2016-03-23 17:20:19.000000000 +0100
@@ -115,6 +115,10 @@
     one. *)
 val alt : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t
 
+(** Same as [alt], for the common case where the left-hand-side captures a value but not
+    the right-hand-side. *)
+val alt_option : ('a, 'v -> 'b, 'c) t -> ('a, 'b, 'c) t -> ('a, 'v option -> 'b, 'c) t
+
 (** Same as [alt] *)
 val ( ||| ) : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> ('a, 'b, 'c) t
 
@@ -125,6 +129,10 @@
 (** Same as [map] *)
 val ( >>| ) : ('a, 'b, 'c) t -> ('d -> 'b) -> ('a, 'd, 'c) t
 
+val map0 : ('a,               'b, 'c) t -> f:               'v  -> ('a, 'v -> 'b, 'c) t
+val map1 : ('a, 'v1 ->        'b, 'c) t -> f:('v1 ->        'v) -> ('a, 'v -> 'b, 'c) t
+val map2 : ('a, 'v1 -> 'v2 -> 'b, 'c) t -> f:('v1 -> 'v2 -> 'v) -> ('a, 'v -> 'b, 'c) t
+
 val ( ^:: ) : ('a, 'b, 'c) t -> ('a list, 'c, 'd) t -> ('a list, 'b, 'd) t
 val many : ('a, 'b -> 'b, 'c) t -> ('a list, 'c list -> 'd, 'd) t
 
@@ -194,7 +202,7 @@
 
 val single_expr_payload : (expression, 'a, 'b) t -> (payload, 'a, 'b) t
 
-val no_label : (expression, 'a, 'b) t -> (string * expression, 'a, 'b) t
+val no_label : (expression, 'a, 'b) t -> (Asttypes.arg_label * expression, 'a, 'b) t
 
 val attribute : (string, 'a, 'b) t -> (payload, 'b, 'c) t -> (attribute, 'a, 'c) t
 val extension : (string, 'a, 'b) t -> (payload, 'b, 'c) t -> (attribute, 'a, 'c) t
diff -uNr ppx_core-113.33.00/src/attribute.ml ppx_core-113.33.00+4.03/src/attribute.ml
--- ppx_core-113.33.00/src/attribute.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/attribute.ml	2016-03-23 17:20:19.000000000 +0100
@@ -15,6 +15,10 @@
     ; "ocaml.doc"
     ; "ocaml.text"
     ; "nonrec"
+    ; "ocaml.noalloc"
+    ; "ocaml.unboxed"
+    ; "ocaml.untagged"
+    ; "ocaml.inline"
     ]
 ;;
 
@@ -74,6 +78,7 @@
     | Pstr_eval               : structure_item          t
     | Pstr_extension          : structure_item          t
     | Psig_extension          : signature_item          t
+    | Row_field               : row_field               t
 
   let label_declaration       = Label_declaration
   let constructor_declaration = Constructor_declaration
@@ -100,6 +105,7 @@
   let pstr_eval               = Pstr_eval
   let pstr_extension          = Pstr_extension
   let psig_extension          = Psig_extension
+  let row_field               = Row_field
 
   let get_pstr_eval st =
     match st.pstr_desc with
@@ -116,6 +122,17 @@
     | Psig_extension (e, l) -> (e, l)
     | _ -> failwith "Attribute.Context.get_psig_extension"
 
+  module Row_field = struct
+    let get_attrs = function
+      | Rinherit _ -> []
+      | Rtag (_, attrs, _, _) -> attrs
+
+    let set_attrs attrs = function
+      | Rinherit _ -> invalid_arg "Row_field.set_attrs"
+      | Rtag (lbl, _, can_be_constant, params_opts) ->
+        Rtag (lbl, attrs, can_be_constant, params_opts)
+  end
+
   let get_attributes : type a. a t -> a -> attributes = fun t x ->
     match t with
     | Label_declaration       -> x.pld_attributes
@@ -143,6 +160,7 @@
     | Pstr_eval               -> snd (get_pstr_eval      x)
     | Pstr_extension          -> snd (get_pstr_extension x)
     | Psig_extension          -> snd (get_psig_extension x)
+    | Row_field               -> Row_field.get_attrs x
 
   let set_attributes : type a. a t -> a -> attributes -> a = fun t x attrs ->
     match t with
@@ -174,6 +192,7 @@
       { x with pstr_desc = Pstr_extension (get_pstr_extension x |> fst, attrs) }
     | Psig_extension ->
       { x with psig_desc = Psig_extension (get_psig_extension x |> fst, attrs) }
+    | Row_field               -> Row_field.set_attrs attrs x
 
   let desc : type a. a t -> string = function
     | Label_declaration       -> "label declaration"
@@ -201,6 +220,7 @@
     | Pstr_eval               -> "toplevel expression"
     | Pstr_extension          -> "toplevel extension"
     | Psig_extension          -> "toplevel signature extension"
+    | Row_field               -> "row field"
 
 (*
   let pattern : type a b c d. a t
@@ -435,6 +455,7 @@
   method! attribute (name, _) =
     Location.raise_errorf ~loc:name.loc
       "attribute not expected here, Ppx_core.Std.Attribute needs updating!"
+      name.txt
 
   method private check_node : type a. a Context.t -> a -> a = fun context node ->
     let attrs = Context.get_attributes context node in
@@ -480,6 +501,7 @@
   method! module_expr             x = super#module_expr             (self#check_node Context.Module_expr             x)
   method! value_binding           x = super#value_binding           (self#check_node Context.Value_binding           x)
   method! module_binding          x = super#module_binding          (self#check_node Context.Module_binding          x)
+  method! row_field               x = super#row_field               (self#check_node Context.Row_field               x)
 
   method! class_field x =
     let x = self#check_node              Context.Class_field x in
diff -uNr ppx_core-113.33.00/src/attribute.mli ppx_core-113.33.00+4.03/src/attribute.mli
--- ppx_core-113.33.00/src/attribute.mli	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/attribute.mli	2016-03-23 17:20:19.000000000 +0100
@@ -42,6 +42,7 @@
   val pstr_eval               : structure_item          t
   val pstr_extension          : structure_item          t
   val psig_extension          : signature_item          t
+  val row_field               : row_field               t
 end
 
 (** [declare fully_qualified_name context payload_pattern k] declares an attribute. [k] is
diff -uNr ppx_core-113.33.00/src/common.ml ppx_core-113.33.00+4.03/src/common.ml
--- ppx_core-113.33.00/src/common.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/common.ml	2016-03-23 17:20:19.000000000 +0100
@@ -16,7 +16,7 @@
   List.fold_right
     (fun (tp, _variance) acc ->
       let loc = tp.ptyp_loc in
-      ptyp_arrow ~loc "" (f ~loc tp) acc)
+      ptyp_arrow ~loc Nolabel (f ~loc tp) acc)
     td.ptype_params
     result_type
 ;;
@@ -74,7 +74,9 @@
 
   method! constructor_declaration cd =
     (* Don't recurse through cd.pcd_res *)
-    List.iter (fun ty -> self#core_type ty) cd.pcd_args
+    match cd.pcd_args with
+    | Pcstr_tuple args -> List.iter (fun ty -> self#core_type ty) args
+    | Pcstr_record _ -> failwith "Pcstr_record not supported"
 end
 
 let types_are_recursive ?(stop_on_functions = true) ?(short_circuit = fun _ -> None)
@@ -110,6 +112,7 @@
   match payload with
   | PStr []          -> name.loc
   | PStr (x :: l)    -> { x.pstr_loc with loc_end = (last x l).pstr_loc.loc_end }
+  | PSig _           -> failwith "Not yet implemented"
   | PTyp t           -> t.ptyp_loc
   | PPat (x, None)   -> x.ppat_loc
   | PPat (x, Some e) -> { x.ppat_loc with loc_end = e.pexp_loc.loc_end }
diff -uNr ppx_core-113.33.00/src/gen/common.ml ppx_core-113.33.00+4.03/src/gen/common.ml
--- ppx_core-113.33.00/src/gen/common.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/gen/common.ml	2016-03-23 17:20:19.000000000 +0100
@@ -70,8 +70,13 @@
   | Type_variant cds ->
     List.fold_left cds ~init:acc
       ~f:(fun acc (cd : Types.constructor_declaration) ->
-         List.fold_left cd.cd_args ~init:acc
-           ~f:(add_type_expr_dependencies env))
+        match cd.cd_args with
+        | Cstr_tuple typ_exprs ->
+          List.fold_left typ_exprs ~init:acc ~f:(add_type_expr_dependencies env)
+        | Cstr_record label_decls ->
+          List.fold_left label_decls ~init:acc
+            ~f:(fun acc (label_decl : Types.label_declaration) ->
+              add_type_expr_dependencies env acc label_decl.ld_type))
   | Type_abstract ->
     match td.type_manifest with
     | None -> acc
diff -uNr ppx_core-113.33.00/src/gen/gen_ast_builder.ml ppx_core-113.33.00+4.03/src/gen/gen_ast_builder.ml
--- ppx_core-113.33.00/src/gen/gen_ast_builder.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/gen/gen_ast_builder.ml	2016-03-23 17:20:19.000000000 +0100
@@ -121,57 +121,60 @@
   open M
 
   let gen_combinator_for_constructor ~wrapper:(wpath, wprefix, has_attrs) path ~prefix cd =
-    let args =
-      List.mapi cd.cd_args ~f:(fun i _ -> sprintf "x%d" i)
-    in
-    let exp =
-      Exp.construct (Loc.mk (fqn_longident path cd.cd_id))
-        (match args with
-         | []  -> None
-         | [x] -> Some (evar x)
-         | _   -> Some (Exp.tuple (List.map args ~f:evar)))
-    in
-    let body =
-      let fields =
-        [ ( Loc.mk (fqn_longident' wpath (wprefix ^ "loc"))
-          , evar "loc"
-          )
-        ; ( Loc.mk (fqn_longident' wpath (wprefix ^ "desc"))
-          , exp
-          )
-        ]
+    match cd.cd_args with
+    | Cstr_record _ -> failwith "Cstr_record not supported"
+    | Cstr_tuple cd_args ->
+      let args =
+        List.mapi cd_args ~f:(fun i _ -> sprintf "x%d" i)
+      in
+      let exp =
+        Exp.construct (Loc.mk (fqn_longident path cd.cd_id))
+          (match args with
+           | []  -> None
+           | [x] -> Some (evar x)
+           | _   -> Some (Exp.tuple (List.map args ~f:evar)))
       in
-      let fields =
-        if has_attrs then
-          ( Loc.mk (fqn_longident' wpath (wprefix ^ "attributes"))
-          , [%expr []]
-          )
-          :: fields
+      let body =
+        let fields =
+          [ ( Loc.mk (fqn_longident' wpath (wprefix ^ "loc"))
+            , evar "loc"
+            )
+          ; ( Loc.mk (fqn_longident' wpath (wprefix ^ "desc"))
+            , exp
+            )
+          ]
+        in
+        let fields =
+          if has_attrs then
+            ( Loc.mk (fqn_longident' wpath (wprefix ^ "attributes"))
+            , [%expr []]
+            )
+            :: fields
+          else
+            fields
+        in
+        Exp.record fields None
+      in
+      let body =
+  (*      match args with
+        | [] -> [%expr fun () -> [%e body]]
+        | _ ->*)
+          List.fold_right args ~init:body ~f:(fun arg acc ->
+            [%expr fun [%p pvar arg] -> [%e acc]])
+      in
+  (*    let body =
+        if not has_attrs then
+          body
+        else
+          [%expr fun ?(attrs=[]) -> [%e body]]
+      in*)
+      let body =
+        if fixed_loc then
+          body
         else
-          fields
+          [%expr fun ~loc -> [%e body]]
       in
-      Exp.record fields None
-    in
-    let body =
-(*      match args with
-      | [] -> [%expr fun () -> [%e body]]
-      | _ ->*)
-        List.fold_right args ~init:body ~f:(fun arg acc ->
-          [%expr fun [%p pvar arg] -> [%e acc]])
-    in
-(*    let body =
-      if not has_attrs then
-        body
-      else
-        [%expr fun ?(attrs=[]) -> [%e body]]
-    in*)
-    let body =
-      if fixed_loc then
-        body
-      else
-        [%expr fun ~loc -> [%e body]]
-    in
-    [%stri let [%p pvar (function_name_of_id ~prefix cd.cd_id)] = [%e body]]
+      [%stri let [%p pvar (function_name_of_id ~prefix cd.cd_id)] = [%e body]]
   ;;
 
   let gen_combinator_for_record path ~prefix lds =
@@ -189,10 +192,10 @@
     let body =
       let l = List.filter funcs ~f:(fun f -> f <> "loc" && f <> "attributes") in
       match l with
-      | [x] -> Exp.fun_ "" None (pvar x) body
+      | [x] -> Exp.fun_ Nolabel None (pvar x) body
       | _ ->
         List.fold_right l ~init:body ~f:(fun func acc ->
-          Exp.fun_ func None (pvar func) acc
+          Exp.fun_ (Labelled func) None (pvar func) acc
         )
     in
 (*    let body =
diff -uNr ppx_core-113.33.00/src/gen/gen_ast_pattern.ml ppx_core-113.33.00+4.03/src/gen/gen_ast_pattern.ml
--- ppx_core-113.33.00/src/gen/gen_ast_pattern.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/gen/gen_ast_pattern.ml	2016-03-23 17:20:19.000000000 +0100
@@ -157,66 +157,69 @@
   ]
 
 let gen_combinator_for_constructor ?wrapper path ~prefix cd =
-  let args =
-    List.mapi cd.cd_args ~f:(fun i _ -> sprintf "x%d" i)
-  in
-  let funcs =
-    List.mapi cd.cd_args ~f:(fun i _ -> sprintf "f%d" i)
-  in
-  let pat =
-    Pat.construct (Loc.mk (fqn_longident path cd.cd_id))
-      (match args with
-       | []  -> None
-       | [x] -> Some (pvar x)
-       | _   -> Some (Pat.tuple (List.map args ~f:pvar)))
-  in
-  let exp =
-    apply_parsers funcs (List.map args ~f:evar) cd.cd_args
-  in
-  let expected = without_prefix ~prefix (Ident.name cd.cd_id) in
-  let body =
-    [%expr
-      match x with
-      | [%p pat] -> ctx.matched <- ctx.matched + 1; [%e exp]
-      | _ -> fail loc [%e Exp.constant (Const_string (expected, None))]
-    ]
-  in
-  let body =
-    match wrapper with
-    | None -> body
-    | Some (path, prefix, has_attrs) ->
-      let body =
-        [%expr
-          let loc = [%e Exp.field (evar "x")
-                          (Loc.mk @@ fqn_longident' path (prefix ^ "loc"))]
-          in
-          let x = [%e Exp.field (evar "x")
-                        (Loc.mk @@ fqn_longident' path (prefix ^ "desc"))]
-          in
-          [%e body]
-        ]
-      in
-      if has_attrs then
-        [%expr
-          [%e assert_no_attributes ~path ~prefix];
-          [%e body]
-        ]
-      else
-        body
-  in
-  let body =
-    let loc =
+  match cd.cd_args with
+  | Cstr_record _ -> failwith "Cstr_record not supported"
+  | Cstr_tuple cd_args ->
+    let args =
+      List.mapi cd_args ~f:(fun i _ -> sprintf "x%d" i)
+    in
+    let funcs =
+      List.mapi cd_args ~f:(fun i _ -> sprintf "f%d" i)
+    in
+    let pat =
+      Pat.construct (Loc.mk (fqn_longident path cd.cd_id))
+        (match args with
+         | []  -> None
+         | [x] -> Some (pvar x)
+         | _   -> Some (Pat.tuple (List.map args ~f:pvar)))
+    in
+    let exp =
+      apply_parsers funcs (List.map args ~f:evar) cd_args
+    in
+    let expected = without_prefix ~prefix (Ident.name cd.cd_id) in
+    let body =
+      [%expr
+        match x with
+        | [%p pat] -> ctx.matched <- ctx.matched + 1; [%e exp]
+        | _ -> fail loc [%e Exp.constant (Pconst_string (expected, None))]
+      ]
+    in
+    let body =
       match wrapper with
-      | None -> [%pat? loc]
-      | Some _ -> [%pat? _loc]
+      | None -> body
+      | Some (path, prefix, has_attrs) ->
+        let body =
+          [%expr
+            let loc = [%e Exp.field (evar "x")
+                            (Loc.mk @@ fqn_longident' path (prefix ^ "loc"))]
+            in
+            let x = [%e Exp.field (evar "x")
+                          (Loc.mk @@ fqn_longident' path (prefix ^ "desc"))]
+            in
+            [%e body]
+          ]
+        in
+        if has_attrs then
+          [%expr
+            [%e assert_no_attributes ~path ~prefix];
+            [%e body]
+          ]
+        else
+          body
     in
-    [%expr T (fun ctx [%p loc] x k -> [%e body])]
-  in
-  let body =
-    List.fold_right funcs ~init:body ~f:(fun func acc ->
-      [%expr fun (T [%p pvar func]) -> [%e acc]])
-  in
-  [%stri let [%p pvar (function_name_of_id ~prefix cd.cd_id)] = [%e body]]
+    let body =
+      let loc =
+        match wrapper with
+        | None -> [%pat? loc]
+        | Some _ -> [%pat? _loc]
+      in
+      [%expr T (fun ctx [%p loc] x k -> [%e body])]
+    in
+    let body =
+      List.fold_right funcs ~init:body ~f:(fun func acc ->
+        [%expr fun (T [%p pvar func]) -> [%e acc]])
+    in
+    [%stri let [%p pvar (function_name_of_id ~prefix cd.cd_id)] = [%e body]]
 ;;
 
 let gen_combinator_for_record path ~prefix ~has_attrs lds =
@@ -241,7 +244,7 @@
   let body = [%expr T (fun ctx loc x k -> [%e body])] in
   let body =
     List.fold_right funcs ~init:body ~f:(fun func acc ->
-      Exp.fun_ func None [%pat? T [%p pvar func]] acc)
+      Exp.fun_ (Labelled func) None [%pat? T [%p pvar func]] acc)
   in
   [%stri let [%p pvar (Common.function_name_of_path path)] = [%e body]]
 ;;
diff -uNr ppx_core-113.33.00/src/gen/gen.ml ppx_core-113.33.00+4.03/src/gen/gen.ml
--- ppx_core-113.33.00/src/gen/gen.ml	2016-03-09 16:44:53.000000000 +0100
+++ ppx_core-113.33.00+4.03/src/gen/gen.ml	2016-03-23 17:20:19.000000000 +0100
@@ -23,7 +23,7 @@
 
   method apply
     :  Parsetree.expression
-    -> (string * Parsetree.expression) list
+    -> (Asttypes.arg_label * Parsetree.expression) list
     -> Parsetree.expression
 
   method abstract
@@ -49,9 +49,9 @@
   method class_params = []
 
   method apply expr args = Exp.apply expr args
-  method abstract patt expr = Exp.fun_ "" None patt expr
+  method abstract patt expr = Exp.fun_ Nolabel None patt expr
 
-  method typ ty = Typ.arrow "" ty ty
+  method typ ty = Typ.arrow Nolabel ty ty
 
   method array  = [%expr Array.map]
   method any    = [%expr fun x -> x]
@@ -68,7 +68,7 @@
   method class_params = []
 
   method apply expr args = Exp.apply expr args
-  method abstract patt expr = Exp.fun_ "" None patt expr
+  method abstract patt expr = Exp.fun_ Nolabel None patt expr
 
   method typ ty = [%type: [%t ty] -> unit]
   method array  = [%expr Array.iter]
@@ -88,8 +88,9 @@
 
   method class_params = [(Typ.var "acc", Asttypes.Invariant)]
 
-  method apply expr args = Exp.apply expr (args @ [("", evar "acc")])
-  method abstract patt expr = Exp.fun_ "" None patt (Exp.fun_ "" None (pvar "acc") expr)
+  method apply expr args = Exp.apply expr (args @ [(Asttypes.Nolabel, evar "acc")])
+  method abstract patt expr =
+    Exp.fun_ Nolabel None patt (Exp.fun_ Nolabel None (pvar "acc") expr)
 
   method typ ty = [%type: [%t ty] -> 'acc -> 'acc]
   method array =
@@ -121,8 +122,9 @@
 
   method class_params = [(Typ.var "acc", Asttypes.Invariant)]
 
-  method apply expr args = Exp.apply expr (args @ [("", evar "acc")])
-  method abstract patt expr = Exp.fun_ "" None patt (Exp.fun_ "" None (pvar "acc") expr)
+  method apply expr args = Exp.apply expr (args @ [(Asttypes.Nolabel, evar "acc")])
+  method abstract patt expr =
+    Exp.fun_ Nolabel None patt (Exp.fun_ Nolabel None (pvar "acc") expr)
 
   method typ ty = [%type: [%t ty] -> 'acc -> [%t ty] * 'acc]
   method array =
@@ -180,12 +182,12 @@
 
     method class_params = [(Typ.var "ctx", Asttypes.Invariant)]
 
-    method apply expr args = Exp.apply expr (("", evar "ctx") :: args)
+    method apply expr args = Exp.apply expr ((Asttypes.Nolabel, evar "ctx") :: args)
     method abstract patt expr =
       if uses_ctx expr then
-        Exp.fun_ "" None (pvar "ctx") (Exp.fun_ "" None patt expr)
+        Exp.fun_ Nolabel None (pvar "ctx") (Exp.fun_ Nolabel None patt expr)
       else
-        Exp.fun_ "" None (pvar "_ctx") (Exp.fun_ "" None patt expr)
+        Exp.fun_ Nolabel None (pvar "_ctx") (Exp.fun_ Nolabel None patt expr)
 
     method typ ty = [%type: 'ctx -> [%t ty] -> [%t ty]]
     method array = [%expr fun ctx a -> Array.map (f ctx) a]
@@ -219,7 +221,7 @@
   let ty = Typ.constr (Loc.mk ~loc (longident_of_path path)) params in
   let ty =
     List.fold_right
-      (fun param ty -> Typ.arrow "" (what#typ param) ty)
+      (fun param ty -> Typ.arrow Nolabel (what#typ param) ty)
       params (what#typ ty)
   in
   Typ.poly vars ty
@@ -244,7 +246,8 @@
       | _ ->
         Exp.apply map
           (List.map
-             (fun te -> ("", type_expr_mapper ~what ~all_types ~var_mappers te))
+             (fun te ->
+               (Asttypes.Nolabel, type_expr_mapper ~what ~all_types ~var_mappers te))
              params)
     else
       what#any
@@ -263,7 +266,8 @@
   List.map2
     (fun te var ->
        (var,
-        what#apply (type_expr_mapper ~what ~all_types ~var_mappers te) [("", evar var)]))
+        what#apply (type_expr_mapper ~what ~all_types ~var_mappers te)
+          [(Asttypes.Nolabel, evar var)]))
     tes vars
 ;;
 
@@ -290,24 +294,27 @@
   let cases =
     List.map
       (fun cd ->
-         let vars = vars_of_list cd.cd_args in
-         let cstr = Loc.mk ~loc (lident (Ident.name cd.cd_id)) in
-         let deconstruct =
-           Pat.construct cstr
-             (match vars with
-              | [] -> None
-              | _ -> Some (Pat.tuple (List.map pvar vars)))
-         in
-         let reconstruct =
-           Exp.construct cstr
-             (match vars with
-              | [] -> None
-              | _ -> Some (Exp.tuple (List.map evar vars)))
-         in
-         let mappers =
-           map_variables ~what ~all_types ~var_mappers vars cd.cd_args
-         in
-         Exp.case deconstruct (what#combine mappers ~reconstruct))
+         match cd.cd_args with
+         | Cstr_tuple args ->
+           let vars = vars_of_list args in
+           let cstr = Loc.mk ~loc (lident (Ident.name cd.cd_id)) in
+           let deconstruct =
+             Pat.construct cstr
+               (match vars with
+                | [] -> None
+                | _ -> Some (Pat.tuple (List.map pvar vars)))
+           in
+           let reconstruct =
+             Exp.construct cstr
+               (match vars with
+                | [] -> None
+                | _ -> Some (Exp.tuple (List.map evar vars)))
+           in
+           let mappers =
+             map_variables ~what ~all_types ~var_mappers vars args
+           in
+           Exp.case deconstruct (what#combine mappers ~reconstruct)
+         | Cstr_record _ -> failwith "Cstr_record not supported")
       cds
   in
   what#abstract (pvar "x") (Exp.match_ (evar "x") cases)
@@ -333,7 +340,7 @@
         | Some te -> type_expr_mapper ~what ~all_types ~var_mappers te
     in
     List.fold_right
-      (fun (_, v) acc -> Exp.fun_ "" None (pvar v) acc)
+      (fun (_, v) acc -> Exp.fun_ Nolabel None (pvar v) acc)
       var_mappers body
   end
 ;;