File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -93,11 +93,11 @@ let from_labels ~loc arity labels : t =
9393 (Ext_list. map2 labels tyvars (fun x y -> Parsetree. Otag (x, [] , y)))
9494 Closed
9595 in
96- Ext_list. fold_right2 labels tyvars result_type
97- ( fun label (* {loc ; txt = label } *) tyvar acc ->
98- Ast_helper.Typ. arrow ~loc: label.loc ~arity: ( Some arity )
99- {lbl = Asttypes. Labelled label; typ = tyvar}
100- acc)
96+ let args =
97+ Ext_list. map2 labels tyvars ( fun label tyvar ->
98+ { Parsetree. lbl = Asttypes. Labelled label; typ = tyvar} )
99+ in
100+ Typ. arrows ~loc args result_type
101101
102102let make_obj ~loc xs = Typ. object_ ~loc xs Closed
103103
Original file line number Diff line number Diff line change @@ -56,6 +56,15 @@ module Typ = struct
5656 let var ?loc ?attrs a = mk ?loc ?attrs (Ptyp_var a)
5757 let arrow ?loc ?attrs ~arity arg ret =
5858 mk ?loc ?attrs (Ptyp_arrow {arg; ret; arity})
59+ let arrows ?loc ?attrs args ret =
60+ let arity = Some (List. length args) in
61+ let rec build_arrows arity_to_use = function
62+ | [] -> ret
63+ | [arg] -> arrow ?loc ?attrs ~arity: arity_to_use arg ret
64+ | arg :: rest ->
65+ arrow ?loc ?attrs ~arity: arity_to_use arg (build_arrows None rest)
66+ in
67+ build_arrows arity args
5968 let tuple ?loc ?attrs a = mk ?loc ?attrs (Ptyp_tuple a)
6069 let constr ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_constr (a, b))
6170 let object_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_object (a, b))
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ module Typ : sig
5656 val var : ?loc : loc -> ?attrs : attrs -> string -> core_type
5757 val arrow :
5858 ?loc : loc -> ?attrs : attrs -> arity :arity -> arg -> core_type -> core_type
59+ val arrows : ?loc : loc -> ?attrs : attrs -> arg list -> core_type -> core_type
5960 val tuple : ?loc : loc -> ?attrs : attrs -> core_type list -> core_type
6061 val constr : ?loc : loc -> ?attrs : attrs -> lid -> core_type list -> core_type
6162 val object_ :
You can’t perform that action at this time.
0 commit comments