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 =
93
93
(Ext_list. map2 labels tyvars (fun x y -> Parsetree. Otag (x, [] , y)))
94
94
Closed
95
95
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
101
101
102
102
let make_obj ~loc xs = Typ. object_ ~loc xs Closed
103
103
Original file line number Diff line number Diff line change @@ -56,6 +56,15 @@ module Typ = struct
56
56
let var ?loc ?attrs a = mk ?loc ?attrs (Ptyp_var a)
57
57
let arrow ?loc ?attrs ~arity arg ret =
58
58
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
59
68
let tuple ?loc ?attrs a = mk ?loc ?attrs (Ptyp_tuple a)
60
69
let constr ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_constr (a, b))
61
70
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
56
56
val var : ?loc : loc -> ?attrs : attrs -> string -> core_type
57
57
val arrow :
58
58
?loc : loc -> ?attrs : attrs -> arity :arity -> arg -> core_type -> core_type
59
+ val arrows : ?loc : loc -> ?attrs : attrs -> arg list -> core_type -> core_type
59
60
val tuple : ?loc : loc -> ?attrs : attrs -> core_type list -> core_type
60
61
val constr : ?loc : loc -> ?attrs : attrs -> lid -> core_type list -> core_type
61
62
val object_ :
You can’t perform that action at this time.
0 commit comments