@@ -321,24 +321,42 @@ and value_description =
321
321
pval_name : string loc ;
322
322
pval_type : core_type ;
323
323
pval_prim : string list ;
324
- pval_attributes : attributes ;
324
+ pval_attributes : attributes ; (* .... [@@id1 E1] [@@id2 E2] *)
325
325
pval_loc : Location .t ;
326
326
}
327
327
328
+ (*
329
+ val x: t (prim = [])
330
+ external x: t = "s1" ... "sn" (prim = ["s1";..."sn"])
331
+
332
+ Note: when used under Pstr_primitive, prim cannot be empty
333
+ *)
334
+
328
335
(* Type declarations *)
329
336
330
337
and type_declaration =
331
338
{
332
339
ptype_name : string loc ;
333
340
ptype_params : (string loc option * variance ) list ;
341
+ (* ('a1,...'an) t; None represents _*)
334
342
ptype_cstrs : (core_type * core_type * Location .t ) list ;
343
+ (* ... constraint T1=T1' ... constraint Tn=Tn' *)
335
344
ptype_kind : type_kind ;
336
- ptype_private : private_flag ;
337
- ptype_manifest : core_type option ;
338
- ptype_attributes : attributes ;
345
+ ptype_private : private_flag ; (* = private ... *)
346
+ ptype_manifest : core_type option ; (* = T *)
347
+ ptype_attributes : attributes ; (* .... [@@id1 E1] [@@id2 E2] *)
339
348
ptype_loc : Location .t ;
340
349
}
341
350
351
+ (*
352
+ type t (abstract, no manifest)
353
+ type t = T0 (abstract, manifest=T0)
354
+ type t = C of T | ... (variant, no manifest)
355
+ type t = T0 = C of T | ... (variant, manifest=T0)
356
+ type t = {l: T; ...} (record, no manifest)
357
+ type t = T0 = {l : T; ...} (record, manifest=T0)
358
+ *)
359
+
342
360
and type_kind =
343
361
| Ptype_abstract
344
362
| Ptype_variant of constructor_declaration list
@@ -353,6 +371,12 @@ and label_declaration =
353
371
pld_attributes : attributes ;
354
372
}
355
373
374
+ (* { ...; l: T; ... } (mutable=Immutable)
375
+ { ...; mutable l: T; ... } (mutable=Mutable)
376
+
377
+ Note: T can be a Pexp_poly.
378
+ *)
379
+
356
380
and constructor_declaration =
357
381
{
358
382
pcd_name : string loc ;
@@ -361,6 +385,11 @@ and constructor_declaration =
361
385
pcd_loc : Location .t ;
362
386
pcd_attributes : attributes ;
363
387
}
388
+ (*
389
+ | C of T1 * ... * Tn (res = None)
390
+ | C: T0 (args = [], res = Some T0)
391
+ | C: T1 * ... * Tn -> T0 (res = Some T0)
392
+ *)
364
393
365
394
(* * {2 Class language} *)
366
395
@@ -370,14 +399,22 @@ and class_type =
370
399
{
371
400
pcty_desc : class_type_desc ;
372
401
pcty_loc : Location .t ;
373
- pcty_attributes : attributes ;
402
+ pcty_attributes : attributes ; (* CT [@id1 E1] [@id2 E2] ... *)
374
403
}
375
404
376
405
and class_type_desc =
377
406
| Pcty_constr of Longident. t loc * core_type list
407
+ (* tconstr
408
+ ['a1, ..., 'an] tconstr *)
378
409
| Pcty_signature of class_signature
379
- | Pcty_fun of label * core_type * class_type
410
+ (* object ... end *)
411
+ | Pcty_arrow of label * core_type * class_type
412
+ (* T -> CT (label = "")
413
+ ~l:T -> CT (label = "l")
414
+ ?l:T -> CT (label = "?l")
415
+ *)
380
416
| Pcty_extension of extension
417
+ (* [%id E] *)
381
418
382
419
and class_signature =
383
420
{
0 commit comments