Skip to content

Commit 7c5bbf5

Browse files
committed
Use built-in type uncurried$ with one variant Uncurried$.
1 parent 5c6aa48 commit 7c5bbf5

13 files changed

+155
-119
lines changed

jscomp/frontend/ast_core_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ let get_uncurry_arity (ty : t) =
133133
let get_curry_arity (ty : t) =
134134
match ty.ptyp_desc with
135135
| Ptyp_constr ({ txt = Ldot (Ldot (Lident "Js", "Fn"), _) }, [ t ])
136-
| Ptyp_constr ({ txt = Ldot (Lident "Js", "uncurried") }, [ t; _ ]) ->
136+
| Ptyp_constr ({ txt = Lident "uncurried$" }, [ t; _ ]) ->
137137
get_uncurry_arity_aux t 0
138138
| _ -> get_uncurry_arity_aux ty 0
139139

jscomp/frontend/ast_core_type_class_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let typ_mapper (self : Bs_ast_mapper.mapper) (ty : Parsetree.core_type) =
7676
[ { ptyp_desc = Ptyp_arrow (label, args, body) } ] )
7777
| Ptyp_constr
7878
(* Js.uncurried is re-wrapped around only in case Nothing below *)
79-
( { txt = Ldot (Lident "Js", "uncurried") },
79+
( { txt = Lident "uncurried$" },
8080
[ { ptyp_desc = Ptyp_arrow (label, args, body) }; _ ] ) );
8181
(* let it go without regard label names,
8282
it will report error later when the label is not empty

jscomp/frontend/ast_external_process.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,7 @@ let handle_attributes (loc : Bs_loc.t) (type_annotation : Parsetree.core_type)
870870
let prim_name_with_source = { name = prim_name; source = External } in
871871
let type_annotation, build_uncurried_type =
872872
match type_annotation.ptyp_desc with
873-
| Ptyp_constr
874-
(({ txt = Ldot (Lident "Js", "uncurried"); _ } as lid), [ t; arity_ ])
875-
->
873+
| Ptyp_constr (({ txt = Lident "uncurried$"; _ } as lid), [ t; arity_ ]) ->
876874
( t,
877875
fun ~arity x ->
878876
let tArity =

jscomp/ml/ast_uncurried.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let uncurriedType ~loc ~arity tArg =
1111
if new_representation arity then
1212
let tArity = arityType ~loc arity in
1313
Ast_helper.Typ.constr ~loc
14-
{ txt = Ldot (Lident "Js", "uncurried"); loc }
14+
{ txt = Lident "uncurried$"; loc }
1515
[ tArg; tArity ]
1616
else
1717
Ast_helper.Typ.constr ~loc
@@ -52,7 +52,7 @@ let uncurriedFun ~loc ~arity funExpr =
5252
if new_representation arity then
5353
Ast_helper.Exp.construct ~loc
5454
~attrs:(arity_to_attributes arity)
55-
{ txt = Ldot (Lident "Js", "Uncurried"); loc }
55+
{ txt = Lident "Uncurried$"; loc }
5656
(Some funExpr)
5757
else
5858
Ast_helper.Exp.record ~loc
@@ -70,14 +70,14 @@ let exprIsUncurriedFun (expr : Parsetree.expression) =
7070
| Pexp_record ([ ({ txt = Ldot (Ldot (Lident "Js", "Fn"), _) }, _e) ], None)
7171
->
7272
true
73-
| Pexp_construct ({ txt = Ldot (Lident "Js", "Uncurried") }, Some _) -> true
73+
| Pexp_construct ({ txt = Lident "Uncurried$" }, Some _) -> true
7474
| _ -> false
7575

7676
let exprExtractUncurriedFun (expr : Parsetree.expression) =
7777
match expr.pexp_desc with
7878
| Pexp_record ([ ({ txt = Ldot (Ldot (Lident "Js", "Fn"), _) }, e) ], None) ->
7979
e
80-
| Pexp_construct ({ txt = Ldot (Lident "Js", "Uncurried") }, Some e) -> e
80+
| Pexp_construct ({ txt = Lident "Uncurried$" }, Some e) -> e
8181
| _ -> assert false
8282

8383
(* Typed AST *)
@@ -105,13 +105,12 @@ let type_to_arity (tArity : Types.type_expr) =
105105

106106
let mk_js_fn ~env ~arity t =
107107
let typ_arity = arity_to_type arity in
108-
let lid : Longident.t = Ldot (Lident "Js", "uncurried") in
108+
let lid : Longident.t = Lident "uncurried$" in
109109
let path = Env.lookup_type lid env in
110110
Ctype.newconstr path [ t; typ_arity ]
111111

112112
let uncurried_type_get_arity ~env typ =
113113
match (Ctype.expand_head env typ).desc with
114-
| Tconstr (Pdot (Pident { name = "Js" }, "uncurried", _), [ _t; tArity ], _)
115-
->
114+
| Tconstr (Pident { name = "uncurried$" }, [ _t; tArity ], _) ->
116115
type_to_arity tArity
117116
| _ -> assert false

jscomp/ml/predef.ml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ and ident_floatarray = ident_create "floatarray"
4949
and ident_unknown = ident_create "unknown"
5050

5151
and ident_promise = ident_create "promise"
52+
and ident_uncurried = ident_create "uncurried$"
5253

5354
type test =
5455
| For_sure_yes
@@ -176,8 +177,9 @@ and ident_nil = ident_create "[]"
176177
and ident_cons = ident_create "::"
177178
and ident_none = ident_create "None"
178179
and ident_some = ident_create "Some"
179-
180180
and ident_ctor_unknown = ident_create "Unknown"
181+
and ident_ctor_uncurried = ident_create "Uncurried$"
182+
181183
let common_initial_env add_type add_extension empty_env =
182184
let decl_bool =
183185
{decl_abstr with
@@ -211,6 +213,15 @@ let common_initial_env add_type add_extension empty_env =
211213
type_arity = 1;
212214
type_kind = Type_variant([cstr ident_none []; cstr ident_some [tvar]]);
213215
type_variance = [Variance.covariant]}
216+
and decl_uncurried =
217+
let tvar1, tvar2 = newgenvar(), newgenvar() in
218+
{decl_abstr with
219+
type_params = [tvar1; tvar2];
220+
type_arity = 2;
221+
type_kind = Type_variant([cstr ident_ctor_uncurried [tvar1]]);
222+
type_variance = [Variance.covariant; Variance.covariant];
223+
type_unboxed = Types.unboxed_true_default_false;
224+
}
214225
and decl_unknown =
215226
let tvar = newgenvar () in
216227
{decl_abstr with
@@ -273,13 +284,14 @@ let common_initial_env add_type add_extension empty_env =
273284
add_type ident_unit decl_unit (
274285
add_type ident_bool decl_bool (
275286
add_type ident_float decl_abstr (
276-
add_type ident_unknown decl_unknown(
287+
add_type ident_unknown decl_unknown (
288+
add_type ident_uncurried decl_uncurried (
277289
add_type ident_string decl_abstr (
278290
add_type ident_int decl_abstr_imm (
279291
add_type ident_extension_constructor decl_abstr (
280292
add_type ident_floatarray decl_abstr (
281293
add_type ident_promise decl_promise (
282-
empty_env))))))))))))))))))))))))
294+
empty_env)))))))))))))))))))))))))
283295

284296
let build_initial_env add_type add_exception empty_env =
285297
let common = common_initial_env add_type add_exception empty_env in

jscomp/ml/translcore.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
775775
with Not_constant -> Lprim (Pmakeblock Blk_tuple, ll, e.exp_loc))
776776
| Texp_construct ({ txt = Lident "false" }, _, []) -> Lconst Const_false
777777
| Texp_construct ({ txt = Lident "true" }, _, []) -> Lconst Const_true
778-
| Texp_construct ({ txt = Ldot (Lident "Js", "Uncurried")}, _, [expr]) ->
778+
| Texp_construct ({ txt = Lident "Uncurried$"}, _, [expr]) ->
779779
(* ReScript uncurried encoding *)
780780
let loc = expr.exp_loc in
781781
let lambda = transl_exp expr in

jscomp/ml/typecore.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
21052105
exp_env = env }
21062106
| Pexp_construct(lid, sarg) ->
21072107
(match lid.txt with
2108-
| Ldot (Lident "Js", "Uncurried") ->
2108+
| Lident "Uncurried$" ->
21092109
let arity = Ast_uncurried.attributes_to_arity sexp.pexp_attributes in
21102110
let uncurried_typ = Ast_uncurried.mk_js_fn ~env ~arity (newvar()) in
21112111
unify_exp_types loc env uncurried_typ ty_expected
@@ -2998,7 +2998,7 @@ and type_application uncurried env funct (sargs : sargs) : targs * Types.type_ex
29982998
then int_of_string (String.sub a 5 (String.length a - 5))
29992999
else 0 in
30003000
Some (arity, t)
3001-
| Tconstr (Pdot(Pident {name = "Js"},"uncurried",_),[t; tArity],_) ->
3001+
| Tconstr (Pident {name = "uncurried$"},[t; tArity],_) ->
30023002
let arity = Ast_uncurried.type_to_arity tArity in
30033003
Some (arity, t)
30043004
| _ -> None in

jscomp/ml/typedecl.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,8 +1593,8 @@ let rec parse_native_repr_attributes env core_type ty =
15931593
let parse_native_repr_attributes env core_type ty =
15941594
match core_type.ptyp_desc, (Ctype.repr ty).desc
15951595
with
1596-
| Ptyp_constr ({txt = Ldot(Lident "Js", "uncurried")}, [{ptyp_desc = Ptyp_arrow (_, _, ct2)}; _]),
1597-
Tconstr (Pdot(Pident {name = "Js"},"uncurried",_),[{desc = Tarrow (_, _, t2, _)}; _],_) ->
1596+
| Ptyp_constr ({txt = Lident "uncurried$"}, [{ptyp_desc = Ptyp_arrow (_, _, ct2)}; _]),
1597+
Tconstr (Pident {name = "uncurried$"},[{desc = Tarrow (_, _, t2, _)}; _],_) ->
15981598
let repr_args, repr_res = parse_native_repr_attributes env ct2 t2 in
15991599
let native_repr_args = Same_as_ocaml_repr :: repr_args in
16001600
(native_repr_args, repr_res)

lib/4.06.1/unstable/all_ounit_tests.ml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43762,6 +43762,7 @@ and ident_floatarray = ident_create "floatarray"
4376243762
and ident_unknown = ident_create "unknown"
4376343763

4376443764
and ident_promise = ident_create "promise"
43765+
and ident_uncurried = ident_create "uncurried$"
4376543766

4376643767
type test =
4376743768
| For_sure_yes
@@ -43889,8 +43890,9 @@ and ident_nil = ident_create "[]"
4388943890
and ident_cons = ident_create "::"
4389043891
and ident_none = ident_create "None"
4389143892
and ident_some = ident_create "Some"
43892-
4389343893
and ident_ctor_unknown = ident_create "Unknown"
43894+
and ident_ctor_uncurried = ident_create "Uncurried$"
43895+
4389443896
let common_initial_env add_type add_extension empty_env =
4389543897
let decl_bool =
4389643898
{decl_abstr with
@@ -43924,6 +43926,15 @@ let common_initial_env add_type add_extension empty_env =
4392443926
type_arity = 1;
4392543927
type_kind = Type_variant([cstr ident_none []; cstr ident_some [tvar]]);
4392643928
type_variance = [Variance.covariant]}
43929+
and decl_uncurried =
43930+
let tvar1, tvar2 = newgenvar(), newgenvar() in
43931+
{decl_abstr with
43932+
type_params = [tvar1; tvar2];
43933+
type_arity = 2;
43934+
type_kind = Type_variant([cstr ident_ctor_uncurried [tvar1]]);
43935+
type_variance = [Variance.covariant; Variance.covariant];
43936+
type_unboxed = Types.unboxed_true_default_false;
43937+
}
4392743938
and decl_unknown =
4392843939
let tvar = newgenvar () in
4392943940
{decl_abstr with
@@ -43986,13 +43997,14 @@ let common_initial_env add_type add_extension empty_env =
4398643997
add_type ident_unit decl_unit (
4398743998
add_type ident_bool decl_bool (
4398843999
add_type ident_float decl_abstr (
43989-
add_type ident_unknown decl_unknown(
44000+
add_type ident_unknown decl_unknown (
44001+
add_type ident_uncurried decl_uncurried (
4399044002
add_type ident_string decl_abstr (
4399144003
add_type ident_int decl_abstr_imm (
4399244004
add_type ident_extension_constructor decl_abstr (
4399344005
add_type ident_floatarray decl_abstr (
4399444006
add_type ident_promise decl_promise (
43995-
empty_env))))))))))))))))))))))))
44007+
empty_env)))))))))))))))))))))))))
4399644008

4399744009
let build_initial_env add_type add_exception empty_env =
4399844010
let common = common_initial_env add_type add_exception empty_env in

0 commit comments

Comments
 (0)