Skip to content

Commit ecb0880

Browse files
committed
Rename Pcty_fun to Pcty_arrow (and idem in Types, Typedtree, Outcometree) to be coherent with Ptyp_arrow.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13536 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent da65939 commit ecb0880

37 files changed

+123
-86
lines changed

bytecomp/translclass.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ let rec transl_class_rebind obj_init cl vf =
422422
let path, obj_init = transl_class_rebind obj_init cl' vf in
423423
let rec check_constraint = function
424424
Cty_constr(path', _, _) when Path.same path path' -> ()
425-
| Cty_fun (_, _, cty) -> check_constraint cty
425+
| Cty_arrow (_, _, cty) -> check_constraint cty
426426
| _ -> raise Exit
427427
in
428428
check_constraint cl.cl_type;

camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1095,11 +1095,11 @@ value varify_constructors var_names =
10951095
mkcty loc
10961096
(Pcty_constr (long_class_ident id) (List.map ctyp (list_of_opt_ctyp tl [])))
10971097
| CtFun loc (TyLab _ lab t) ct ->
1098-
mkcty loc (Pcty_fun lab (ctyp t) (class_type ct))
1098+
mkcty loc (Pcty_arrow lab (ctyp t) (class_type ct))
10991099
| CtFun loc (TyOlb loc1 lab t) ct ->
11001100
let t = TyApp loc1 (predef_option loc1) t in
1101-
mkcty loc (Pcty_fun ("?" ^ lab) (ctyp t) (class_type ct))
1102-
| CtFun loc t ct -> mkcty loc (Pcty_fun "" (ctyp t) (class_type ct))
1101+
mkcty loc (Pcty_arrow ("?" ^ lab) (ctyp t) (class_type ct))
1102+
| CtFun loc t ct -> mkcty loc (Pcty_arrow "" (ctyp t) (class_type ct))
11031103
| CtSig loc t_o ctfl ->
11041104
let t =
11051105
match t_o with

camlp4/Camlp4Top/Rprint.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ value rec print_out_class_type ppf =
329329
(print_typlist Toploop.print_out_type.val ",") tyl ]
330330
in
331331
fprintf ppf "@[%a%a@]" pr_tyl tyl print_ident id
332-
| Octy_fun lab ty cty ->
332+
| Octy_arrow lab ty cty ->
333333
fprintf ppf "@[%a[ %a ] ->@ %a@]" print_ty_label lab
334334
Toploop.print_out_type.val ty print_out_class_type cty
335335
| Octy_signature self_ty csil ->

camlp4/boot/Camlp4.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15483,14 +15483,14 @@ module Struct =
1548315483
(Pcty_constr ((long_class_ident id),
1548415484
(List.map ctyp (list_of_opt_ctyp tl []))))
1548515485
| CtFun (loc, (TyLab (_, lab, t)), ct) ->
15486-
mkcty loc (Pcty_fun (lab, (ctyp t), (class_type ct)))
15486+
mkcty loc (Pcty_arrow (lab, (ctyp t), (class_type ct)))
1548715487
| CtFun (loc, (TyOlb (loc1, lab, t)), ct) ->
1548815488
let t = TyApp (loc1, (predef_option loc1), t)
1548915489
in
1549015490
mkcty loc
15491-
(Pcty_fun (("?" ^ lab), (ctyp t), (class_type ct)))
15491+
(Pcty_arrow (("?" ^ lab), (ctyp t), (class_type ct)))
1549215492
| CtFun (loc, t, ct) ->
15493-
mkcty loc (Pcty_fun ("", (ctyp t), (class_type ct)))
15493+
mkcty loc (Pcty_arrow ("", (ctyp t), (class_type ct)))
1549415494
| CtSig (loc, t_o, ctfl) ->
1549515495
let t =
1549615496
(match t_o with | Ast.TyNil _ -> Ast.TyAny loc | t -> t) in

ocamldoc/odoc_ast.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ module Typedtree_search =
200200
let rec iter = function
201201
Types.Cty_constr (_, _, cty) -> iter cty
202202
| Types.Cty_signature s -> s
203-
| Types.Cty_fun (_,_, cty) -> iter cty
203+
| Types.Cty_arrow (_,_, cty) -> iter cty
204204
in
205205
fun ct_decl -> iter ct_decl.Types.clty_type
206206

ocamldoc/odoc_env.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ let subst_class_type env t =
238238
| Types.Cty_signature cs ->
239239
(* on ne s'occupe pas des vals et methods *)
240240
t
241-
| Types.Cty_fun (l, texp, ct) ->
241+
| Types.Cty_arrow (l, texp, ct) ->
242242
let new_texp = subst_type env texp in
243243
let new_ct = iter ct in
244-
Types.Cty_fun (l, new_texp, new_ct)
244+
Types.Cty_arrow (l, new_texp, new_ct)
245245
in
246246
iter t

ocamldoc/odoc_print.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ let simpl_class_type t =
9090
Types.cty_concr = Types.Concr.empty ;
9191
Types.cty_inher = []
9292
}
93-
| Types.Cty_fun (l, texp, ct) ->
93+
| Types.Cty_arrow (l, texp, ct) ->
9494
let new_ct = iter ct in
95-
Types.Cty_fun (l, texp, new_ct)
95+
Types.Cty_arrow (l, texp, new_ct)
9696
in
9797
iter t
9898

ocamldoc/odoc_sig.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ module Analyser =
450450
ic
451451

452452
| Parsetree.Pcty_signature _
453-
| Parsetree.Pcty_fun _ ->
453+
| Parsetree.Pcty_arrow _ ->
454454
(* we don't have a name for the class signature, so we call it "object ... end" *)
455455
{
456456
ic_name = Odoc_messages.object_end ;
@@ -1235,7 +1235,7 @@ module Analyser =
12351235
in
12361236
([], Class_structure (inher_l, ele))
12371237

1238-
| (Parsetree.Pcty_fun (parse_label, _, pclass_type), Types.Cty_fun (label, type_expr, class_type)) ->
1238+
| (Parsetree.Pcty_arrow (parse_label, _, pclass_type), Types.Cty_arrow (label, type_expr, class_type)) ->
12391239
(* label = string. Dans les signatures, pas de nom de parametres a l'interieur des tuples *)
12401240
(* si label = "", pas de label. ici on a l'information pour savoir si on a un label explicite. *)
12411241
if parse_label = label then
@@ -1252,7 +1252,7 @@ module Analyser =
12521252
)
12531253
else
12541254
(
1255-
raise (Failure "Parsetree.Pcty_fun (parse_label, _, pclass_type), labels differents")
1255+
raise (Failure "Parsetree.Pcty_arrow (parse_label, _, pclass_type), labels differents")
12561256
)
12571257

12581258
| _ ->
@@ -1286,8 +1286,8 @@ module Analyser =
12861286
in
12871287
Class_signature (inher_l, ele)
12881288

1289-
| (Parsetree.Pcty_fun (parse_label, _, pclass_type), Types.Cty_fun (label, type_expr, class_type)) ->
1290-
raise (Failure "analyse_class_type_kind : Parsetree.Pcty_fun (...) with Types.Cty_fun (...)")
1289+
| (Parsetree.Pcty_arrow (parse_label, _, pclass_type), Types.Cty_arrow (label, type_expr, class_type)) ->
1290+
raise (Failure "analyse_class_type_kind : Parsetree.Pcty_arrow (...) with Types.Cty_arrow (...)")
12911291
(*
12921292
| (Parsetree.Pcty_constr (longident, _) (*of Longident.t * core_type list *),
12931293
Types.Cty_signature class_signature) ->

ocamldoc/odoc_str.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let string_of_class_type_param_list l =
125125
let string_of_class_params c =
126126
let b = Buffer.create 256 in
127127
let rec iter = function
128-
Types.Cty_fun (label, t, ctype) ->
128+
Types.Cty_arrow (label, t, ctype) ->
129129
let parent = is_arrow_type t in
130130
Printf.bprintf b "%s%s%s%s -> "
131131
(

otherlibs/labltk/browser/searchpos.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ let rec search_pos_class_type cl ~pos ~env =
151151
end
152152
| Pctf_extension _ -> ()
153153
end)
154-
| Pcty_fun (_, ty, cty) ->
154+
| Pcty_arrow (_, ty, cty) ->
155155
search_pos_type ty ~pos ~env;
156156
search_pos_class_type cty ~pos ~env
157157
| Pcty_extension _ -> ()

parsing/ast_helper.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ module Cty = struct
209209

210210
let constr ?loc ?attrs a b = mk ?loc ?attrs (Pcty_constr (a, b))
211211
let signature ?loc ?attrs a = mk ?loc ?attrs (Pcty_signature a)
212-
let fun_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_fun (a, b, c))
212+
let arrow ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_arrow (a, b, c))
213213
let extension ?loc ?attrs a = mk ?loc ?attrs (Pcty_extension a)
214214
end
215215

parsing/ast_helper.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ module Cty:
190190

191191
val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> class_type
192192
val signature: ?loc:loc -> ?attrs:attrs -> class_signature -> class_type
193-
val fun_: ?loc:loc -> ?attrs:attrs -> label -> core_type -> class_type -> class_type
193+
val arrow: ?loc:loc -> ?attrs:attrs -> label -> core_type -> class_type -> class_type
194194
val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_type
195195
end
196196
module Ctf:

parsing/ast_mapper.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ module CT = struct
8282
match desc with
8383
| Pcty_constr (lid, tys) -> constr ~loc ~attrs (map_loc sub lid) (List.map (sub # typ) tys)
8484
| Pcty_signature x -> signature ~loc ~attrs (sub # class_signature x)
85-
| Pcty_fun (lab, t, ct) ->
86-
fun_ ~loc ~attrs lab
85+
| Pcty_arrow (lab, t, ct) ->
86+
arrow ~loc ~attrs lab
8787
(sub # typ t)
8888
(sub # class_type ct)
8989
| Pcty_extension x -> extension ~loc ~attrs (sub # extension x)

parsing/parser.mly

+4-4
Original file line numberDiff line numberDiff line change
@@ -884,13 +884,13 @@ class_type:
884884
class_signature
885885
{ $1 }
886886
| QUESTION LIDENT COLON simple_core_type_or_tuple_no_attr MINUSGREATER class_type
887-
{ mkcty(Pcty_fun("?" ^ $2 , mkoption $4, $6)) }
887+
{ mkcty(Pcty_arrow("?" ^ $2 , mkoption $4, $6)) }
888888
| OPTLABEL simple_core_type_or_tuple_no_attr MINUSGREATER class_type
889-
{ mkcty(Pcty_fun("?" ^ $1, mkoption $2, $4)) }
889+
{ mkcty(Pcty_arrow("?" ^ $1, mkoption $2, $4)) }
890890
| LIDENT COLON simple_core_type_or_tuple_no_attr MINUSGREATER class_type
891-
{ mkcty(Pcty_fun($1, $3, $5)) }
891+
{ mkcty(Pcty_arrow($1, $3, $5)) }
892892
| simple_core_type_or_tuple_no_attr MINUSGREATER class_type
893-
{ mkcty(Pcty_fun("", $1, $3)) }
893+
{ mkcty(Pcty_arrow("", $1, $3)) }
894894
| class_type attribute
895895
{ Cty.attr $1 $2 }
896896
| extension

parsing/parsetree.mli

+43-6
Original file line numberDiff line numberDiff line change
@@ -321,24 +321,42 @@ and value_description =
321321
pval_name: string loc;
322322
pval_type: core_type;
323323
pval_prim: string list;
324-
pval_attributes: attributes;
324+
pval_attributes: attributes; (* .... [@@id1 E1] [@@id2 E2] *)
325325
pval_loc: Location.t;
326326
}
327327

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+
328335
(* Type declarations *)
329336

330337
and type_declaration =
331338
{
332339
ptype_name: string loc;
333340
ptype_params: (string loc option * variance) list;
341+
(* ('a1,...'an) t; None represents _*)
334342
ptype_cstrs: (core_type * core_type * Location.t) list;
343+
(* ... constraint T1=T1' ... constraint Tn=Tn' *)
335344
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] *)
339348
ptype_loc: Location.t;
340349
}
341350

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+
342360
and type_kind =
343361
| Ptype_abstract
344362
| Ptype_variant of constructor_declaration list
@@ -353,6 +371,12 @@ and label_declaration =
353371
pld_attributes: attributes;
354372
}
355373

374+
(* { ...; l: T; ... } (mutable=Immutable)
375+
{ ...; mutable l: T; ... } (mutable=Mutable)
376+
377+
Note: T can be a Pexp_poly.
378+
*)
379+
356380
and constructor_declaration =
357381
{
358382
pcd_name: string loc;
@@ -361,6 +385,11 @@ and constructor_declaration =
361385
pcd_loc: Location.t;
362386
pcd_attributes: attributes;
363387
}
388+
(*
389+
| C of T1 * ... * Tn (res = None)
390+
| C: T0 (args = [], res = Some T0)
391+
| C: T1 * ... * Tn -> T0 (res = Some T0)
392+
*)
364393

365394
(** {2 Class language} *)
366395

@@ -370,14 +399,22 @@ and class_type =
370399
{
371400
pcty_desc: class_type_desc;
372401
pcty_loc: Location.t;
373-
pcty_attributes: attributes;
402+
pcty_attributes: attributes; (* CT [@id1 E1] [@id2 E2] ... *)
374403
}
375404

376405
and class_type_desc =
377406
| Pcty_constr of Longident.t loc * core_type list
407+
(* tconstr
408+
['a1, ..., 'an] tconstr *)
378409
| 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+
*)
380416
| Pcty_extension of extension
417+
(* [%id E] *)
381418

382419
and class_signature =
383420
{

parsing/pprintast.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ class printer ()= object(self:'self)
764764
| [] -> ()
765765
| _ -> pp f "[%a]@ " (self#list self#core_type ~sep:"," ) l) l
766766
self#longident_loc li
767-
| Pcty_fun (l, co, cl) ->
767+
| Pcty_arrow (l, co, cl) ->
768768
pp f "@[<2>%a@;->@;%a@]" (* FIXME remove parens later *)
769769
self#type_with_label (l,co) self#class_type cl
770770
| Pcty_extension _ -> assert false

parsing/printast.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ and class_type i ppf x =
407407
| Pcty_signature (cs) ->
408408
line i ppf "Pcty_signature\n";
409409
class_signature i ppf cs;
410-
| Pcty_fun (l, co, cl) ->
411-
line i ppf "Pcty_fun \"%s\"\n" l;
410+
| Pcty_arrow (l, co, cl) ->
411+
line i ppf "Pcty_arrow \"%s\"\n" l;
412412
core_type i ppf co;
413413
class_type i ppf cl;
414414
| Pcty_extension (s, arg) ->

tools/addlabels.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let rec labels_of_sty sty =
4444

4545
let rec labels_of_cty cty =
4646
match cty.pcty_desc with
47-
Pcty_fun (lab, _, rem) ->
47+
Pcty_arrow (lab, _, rem) ->
4848
let (labs, meths) = labels_of_cty rem in
4949
(lab :: labs, meths)
5050
| Pcty_signature { pcsig_fields = fields } ->

tools/depend.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ let rec add_class_type bv cty =
8686
| Pcty_signature { pcsig_self = ty; pcsig_fields = fieldl } ->
8787
add_type bv ty;
8888
List.iter (add_class_type_field bv) fieldl
89-
| Pcty_fun(_, ty1, cty2) ->
89+
| Pcty_arrow(_, ty1, cty2) ->
9090
add_type bv ty1; add_class_type bv cty2
9191
| Pcty_extension _ -> ()
9292

tools/eqparsetree.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ and eq_class_type_desc :
565565
(eq_list eq_core_type (a1, b1))
566566
| (Pcty_signature a0, Pcty_signature b0) ->
567567
eq_class_signature (a0, b0)
568-
| (Pcty_fun (a0, a1, a2), Pcty_fun (b0, b1, b2)) ->
568+
| (Pcty_arrow (a0, a1, a2), Pcty_arrow (b0, b1, b2)) ->
569569
((Asttypes.eq_label (a0, b0)) && (eq_core_type (a1, b1))) &&
570570
(eq_class_type (a2, b2))
571571
| (_, _) -> false

tools/tast_iter.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ let class_type sub ct =
257257
match ct.cltyp_desc with
258258
| Tcty_signature csg -> sub # class_signature csg
259259
| Tcty_constr (_path, _, list) -> List.iter (sub # core_type) list
260-
| Tcty_fun (_label, ct, cl) ->
260+
| Tcty_arrow (_label, ct, cl) ->
261261
sub # core_type ct;
262262
sub # class_type cl
263263

tools/untypeast.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ and untype_class_type ct =
453453
Tcty_signature csg -> Pcty_signature (untype_class_signature csg)
454454
| Tcty_constr (_path, lid, list) ->
455455
Pcty_constr (lid, List.map untype_core_type list)
456-
| Tcty_fun (label, ct, cl) ->
457-
Pcty_fun (label, untype_core_type ct, untype_class_type cl)
456+
| Tcty_arrow (label, ct, cl) ->
457+
Pcty_arrow (label, untype_core_type ct, untype_class_type cl)
458458
in
459459
{ pcty_desc = desc;
460460
pcty_loc = ct.cltyp_loc;

typing/btype.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ let rec unmark_class_type =
367367
List.iter unmark_type tyl; unmark_class_type cty
368368
| Cty_signature sign ->
369369
unmark_class_signature sign
370-
| Cty_fun (_, ty, cty) ->
370+
| Cty_arrow (_, ty, cty) ->
371371
unmark_type ty; unmark_class_type cty
372372

373373

0 commit comments

Comments
 (0)