@@ -98,20 +98,21 @@ module T = struct
98
98
match desc with
99
99
| Ptyp_any -> any ~loc ~attrs ()
100
100
| Ptyp_var s -> var ~loc ~attrs s
101
- | Ptyp_arrow (lab , t1 , t2 , _ ) ->
102
- arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2)
101
+ | Ptyp_arrow (lab , t1 , t2 , arity ) -> (
102
+ let typ0 = arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) in
103
+ match arity with
104
+ | None -> typ0
105
+ | Some arity ->
106
+ let arity_string = " Has_arity" ^ string_of_int arity in
107
+ let arity_type =
108
+ Ast_helper0.Typ. variant ~loc
109
+ [Rtag (Location. mknoloc arity_string, [] , true , [] )]
110
+ Closed None
111
+ in
112
+ Ast_helper0.Typ. constr ~loc
113
+ {txt = Lident " function$" ; loc}
114
+ [typ0; arity_type])
103
115
| Ptyp_tuple tyl -> tuple ~loc ~attrs (List. map (sub.typ sub) tyl)
104
- | Ptyp_constr
105
- ( ({txt = Lident " function$" } as lid),
106
- [({ptyp_desc = Ptyp_arrow (_, _, _, Some arity)} as t_arg)] ) ->
107
- let encode_arity_string arity = " Has_arity" ^ string_of_int arity in
108
- let arity_type ~loc arity =
109
- Ast_helper0.Typ. variant ~loc
110
- [Rtag ({txt = encode_arity_string arity; loc}, [] , true , [] )]
111
- Closed None
112
- in
113
- constr ~loc ~attrs (map_loc sub lid)
114
- [sub.typ sub t_arg; arity_type ~loc: Location. none arity]
115
116
| Ptyp_constr (lid , tl ) ->
116
117
constr ~loc ~attrs (map_loc sub lid) (List. map (sub.typ sub) tl)
117
118
| Ptyp_object (l , o ) ->
0 commit comments