diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index 8161894bf9..34b7a52561 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -1538,7 +1538,7 @@ and compile_prim (prim_info : Lam.prim_info) (* either a getter {[ x #. height ]} or {[ x ## method_call ]} *) - assert (not setter); + (* assert (not setter); *) match compile_lambda { lambda_cxt with continuation = NeedValue Not_tail } obj diff --git a/jscomp/ml/typecore.ml b/jscomp/ml/typecore.ml index c6f20c1706..5fcb3d7288 100644 --- a/jscomp/ml/typecore.ml +++ b/jscomp/ml/typecore.ml @@ -2159,7 +2159,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg=Rejected) env sexp ty exp_type; exp_attributes = []; exp_env = env } in - let apply_internal name e = + let _apply_internal name e = let lid:Longident.t = Ldot (Ldot (Lident "Js", "Internal"), name) in let (path, desc) = Env.lookup_value lid env in let id = mk_exp (Texp_ident(path, {txt=lid; loc=Location.none}, desc)) desc.val_type in @@ -2178,7 +2178,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg=Rejected) env sexp ty | _ -> false in if fully_applied && not is_primitive then - rue (apply_internal "opaqueFullApply" (mk_apply funct args)) + rue (mk_apply funct args) else rue (mk_apply funct args) | Pexp_match(sarg, caselist) -> diff --git a/jscomp/test/DerivingAccessorsCurried.js b/jscomp/test/DerivingAccessorsCurried.js index 49a7d6079e..2ad2d0eb53 100644 --- a/jscomp/test/DerivingAccessorsCurried.js +++ b/jscomp/test/DerivingAccessorsCurried.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function myField(param) { return param.myField; @@ -22,7 +23,7 @@ function doubleNum(param_0, param_1) { } function compose(a, accessor) { - return accessor(a); + return Curry._1(accessor, a); } let _composedMyField = 1; diff --git a/jscomp/test/DerivingAccessorsUncurried.js b/jscomp/test/DerivingAccessorsUncurried.js index 49a7d6079e..2ad2d0eb53 100644 --- a/jscomp/test/DerivingAccessorsUncurried.js +++ b/jscomp/test/DerivingAccessorsUncurried.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function myField(param) { return param.myField; @@ -22,7 +23,7 @@ function doubleNum(param_0, param_1) { } function compose(a, accessor) { - return accessor(a); + return Curry._1(accessor, a); } let _composedMyField = 1; diff --git a/jscomp/test/Import.js b/jscomp/test/Import.js index b094a389db..b4dddc9291 100644 --- a/jscomp/test/Import.js +++ b/jscomp/test/Import.js @@ -1,18 +1,19 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); async function eachIntAsync(list, f) { - return (await import("../../lib/js/belt_List.js").then(function (m) { + return Curry._2(await import("../../lib/js/belt_List.js").then(function (m) { return m.forEach; - }))(list, f); + }), list, f); } function eachIntLazy(list, f) { return import("../../lib/js/belt_List.js").then(function (m) { return m.forEach; }).then(function (each) { - return Promise.resolve(each(list, f)); + return Promise.resolve(Curry._2(each, list, f)); }); } diff --git a/jscomp/test/UncurriedAlways.js b/jscomp/test/UncurriedAlways.js index 6180b31cac..2a4cdf49df 100644 --- a/jscomp/test/UncurriedAlways.js +++ b/jscomp/test/UncurriedAlways.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function foo(x, y) { return x + y | 0; @@ -155,24 +156,20 @@ let OptMixed = { }; function fn(cb) { - return cb(); + return Curry._1(cb, undefined); } -((function (s) { - console.log({ - NAME: "foo", - VAL: s - }); - })()); +console.log({ + NAME: "foo", + VAL: undefined +}); function fn1(a, b, param) { - return a() + b | 0; + return Curry._1(a, undefined) + b | 0; } function a$1(__x) { - return fn1((function () { - return 1; - }), 2, __x); + return 3; } function f3(x, y, z) { @@ -203,11 +200,11 @@ let PartialApplication = { }; function hello1(y, f) { - return f(y); + return Curry._1(f, y); } function hello2(y, f) { - return f(y); + return Curry._1(f, y); } let ReverseApplication = { @@ -217,27 +214,25 @@ let ReverseApplication = { function f(a, b, c) { return [ - b(a), - c(a) + Curry._1(b, a), + Curry._1(c, a) ]; } function f2(a, b, c, d, e) { - let __tuple_internal_obj = a(b); - let param = [ - c(__tuple_internal_obj, d), - d(__tuple_internal_obj, 1, 2), - e(__tuple_internal_obj) - ]; - return (param[0] + param[1] | 0) + param[2] | 0; + let __tuple_internal_obj = Curry._1(a, b); + let param_0 = Curry._2(c, __tuple_internal_obj, d); + let param_1 = Curry._3(d, __tuple_internal_obj, 1, 2); + let param_2 = Curry._1(e, __tuple_internal_obj); + return (param_0 + param_1 | 0) + param_2 | 0; } function f3$1(foo, x) { - return foo(x); + return Curry._1(foo, x); } function f4(x, f) { - return f(x, 3); + return Curry._2(f, x, 3); } let Pipe = { diff --git a/jscomp/test/UncurriedExternals.js b/jscomp/test/UncurriedExternals.js index 2aa967abd0..71167e6651 100644 --- a/jscomp/test/UncurriedExternals.js +++ b/jscomp/test/UncurriedExternals.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let React = require("react"); function dd() { @@ -19,7 +20,7 @@ let M = { }) }; -let hh = M.sum(1.0, 2.0); +let hh = Curry._2(M.sum, 1.0, 2.0); let mf = 3 % 4; diff --git a/jscomp/test/UntaggedVariants.js b/jscomp/test/UntaggedVariants.js index fc4bad2165..0a7b0b1a72 100644 --- a/jscomp/test/UntaggedVariants.js +++ b/jscomp/test/UntaggedVariants.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Js_dict = require("../../lib/js/js_dict.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); let Caml_array = require("../../lib/js/caml_array.js"); @@ -372,7 +373,7 @@ function classify$9(v) { case "object" : return v.x; case "function" : - return v(3); + return Curry._1(v, 3); } } @@ -574,7 +575,7 @@ function test(t) { case "string" : return t; case "function" : - return t(); + return Curry._1(t, undefined); } } diff --git a/jscomp/test/a_filename_test.js b/jscomp/test/a_filename_test.js index 309864fbda..5fe5fd915f 100644 --- a/jscomp/test/a_filename_test.js +++ b/jscomp/test/a_filename_test.js @@ -44,49 +44,49 @@ if (process.platform !== "win32") { "/a/tmp.txt", "/a/tmp.txt/subdir/file.txt" ]); - eq("File \"a_filename_test.res\", line 28, characters 5-12", test({ + eq("File \"a_filename_test.res\", line 28, characters 5-12", Ext_filename_test.node_relative_path(true, { NAME: "File", VAL: "./a/b.c" }, { NAME: "File", VAL: "./a/u/g.c" }), "./u/g.c"); - eq("File \"a_filename_test.res\", line 31, characters 4-11", test({ + eq("File \"a_filename_test.res\", line 31, characters 4-11", Ext_filename_test.node_relative_path(true, { NAME: "File", VAL: "./a/b.c" }, { NAME: "File", VAL: "xxxghsoghos/ghsoghso/node_modules/buckle-stdlib/list.js" }), "buckle-stdlib/list.js"); - eq("File \"a_filename_test.res\", line 37, characters 4-11", test({ + eq("File \"a_filename_test.res\", line 37, characters 4-11", Ext_filename_test.node_relative_path(true, { NAME: "File", VAL: "./a/b.c" }, { NAME: "File", VAL: "xxxghsoghos/ghsoghso/node_modules//buckle-stdlib/list.js" }), "buckle-stdlib/list.js"); - eq("File \"a_filename_test.res\", line 43, characters 4-11", test({ + eq("File \"a_filename_test.res\", line 43, characters 4-11", Ext_filename_test.node_relative_path(true, { NAME: "File", VAL: "./a/b.c" }, { NAME: "File", VAL: "xxxghsoghos/ghsoghso/node_modules/./buckle-stdlib/list.js" }), "buckle-stdlib/list.js"); - eq("File \"a_filename_test.res\", line 48, characters 5-12", test({ + eq("File \"a_filename_test.res\", line 48, characters 5-12", Ext_filename_test.node_relative_path(true, { NAME: "File", VAL: "./a/c.js" }, { NAME: "File", VAL: "./a/b" }), "./b"); - eq("File \"a_filename_test.res\", line 49, characters 5-12", test({ + eq("File \"a_filename_test.res\", line 49, characters 5-12", Ext_filename_test.node_relative_path(true, { NAME: "File", VAL: "./a/c" }, { NAME: "File", VAL: "./a/b.js" }), "./b.js"); - eq("File \"a_filename_test.res\", line 50, characters 5-12", test({ + eq("File \"a_filename_test.res\", line 50, characters 5-12", Ext_filename_test.node_relative_path(true, { NAME: "Dir", VAL: "./a/" }, { diff --git a/jscomp/test/a_recursive_type.js b/jscomp/test/a_recursive_type.js index e46f155b06..ccd7a52800 100644 --- a/jscomp/test/a_recursive_type.js +++ b/jscomp/test/a_recursive_type.js @@ -1,9 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function g(x) { - return x._0(x); + return Curry._1(x._0, x); } let loop = g({ @@ -11,9 +12,7 @@ let loop = g({ _0: g }); -let non_terminate = (function (x) { - return x._0(x); -})({ +let non_terminate = Curry._1(g, { TAG: "A", _0: g }); diff --git a/jscomp/test/a_scope_bug.js b/jscomp/test/a_scope_bug.js index 353958d34b..f80dcfef42 100644 --- a/jscomp/test/a_scope_bug.js +++ b/jscomp/test/a_scope_bug.js @@ -13,9 +13,7 @@ function odd(_z) { }; } -function even(y) { - return odd(y); -} +let even = odd; exports.odd = odd; exports.even = even; diff --git a/jscomp/test/ari_regress_test.js b/jscomp/test/ari_regress_test.js index 55e9383ea1..0fb1d223ff 100644 --- a/jscomp/test/ari_regress_test.js +++ b/jscomp/test/ari_regress_test.js @@ -2,15 +2,27 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); -let g = (function (extra) { - return 3 + extra | 0; -})(4); +function f(x) { + return function (extra) { + return x + extra | 0; + }; +} + +let g = Curry._1(f(3), 4); let h = { contents: 0 }; +function gg(x, y) { + let u = x + y | 0; + return function (z) { + return u + z | 0; + }; +} + function g1(x, y) { let u = x + y | 0; h.contents = h.contents + 1 | 0; @@ -19,14 +31,10 @@ function g1(x, y) { }; } -let u = 8; - -let x = (function (z) { - return u + z | 0; -})(6); +let x = Curry._1(gg(3, 5), 6); function v(__x) { - return g1(3, 4)(6, __x); + return Curry._2(g1(3, 4), 6, __x); } let suites_0 = [ diff --git a/jscomp/test/arith_lexer.js b/jscomp/test/arith_lexer.js index 7ede8cf05e..3fe31466a5 100644 --- a/jscomp/test/arith_lexer.js +++ b/jscomp/test/arith_lexer.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Lexing = require("../../lib/js/lexing.js"); let Pervasives = require("../../lib/js/pervasives.js"); let Caml_format = require("../../lib/js/caml_format.js"); @@ -151,7 +152,7 @@ function __ocaml_lex_lexeme_rec(lexbuf, ___ocaml_lex_state) { case 9 : return "EOF"; default: - lexbuf.refill_buff(lexbuf); + Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; continue; } diff --git a/jscomp/test/arity.js b/jscomp/test/arity.js index c102b0bb09..bde98e4f6a 100644 --- a/jscomp/test/arity.js +++ b/jscomp/test/arity.js @@ -1,15 +1,16 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function u(f, a, b) { - console.log(f(a, b)); - console.log(f(a, b)); + console.log(Curry._2(f, a, b)); + console.log(Curry._2(f, a, b)); } function u2(f, a, b) { - console.log(f(a, b)); - console.log(f(a, b)); + console.log(Curry._2(f, a, b)); + console.log(Curry._2(f, a, b)); } function f(x, y) { @@ -22,7 +23,7 @@ function add(prim0, prim1) { function h(u) { let m = u.hi; - return m(1, 2); + return Curry._2(m, 1, 2); } let nested = { diff --git a/jscomp/test/arity_deopt.js b/jscomp/test/arity_deopt.js index 9424711c78..9f0ced9551 100644 --- a/jscomp/test/arity_deopt.js +++ b/jscomp/test/arity_deopt.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -52,17 +53,11 @@ function f3(x) { eq("File \"arity_deopt.res\", line 47, characters 11-18", 6, 6); -eq("File \"arity_deopt.res\", line 48, characters 11-18", 6, (function (y, z) { - return (1 + y | 0) + z | 0; -})(2, 3)); +eq("File \"arity_deopt.res\", line 48, characters 11-18", 6, Curry._2(f1(1), 2, 3)); -eq("File \"arity_deopt.res\", line 49, characters 11-18", 6, (function (z) { - return 3 + z | 0; -})(3)); +eq("File \"arity_deopt.res\", line 49, characters 11-18", 6, Curry._1(f2(1, 2), 3)); -eq("File \"arity_deopt.res\", line 50, characters 11-18", 6, (function (y, z) { - return (1 + y | 0) + z | 0; -})(2, 3)); +eq("File \"arity_deopt.res\", line 50, characters 11-18", 6, Curry._2(f3(1), 2, 3)); Mt.from_pair_suites("Arity_deopt", suites.contents); diff --git a/jscomp/test/arity_infer.js b/jscomp/test/arity_infer.js index e79d4a0c52..287497a2b3 100644 --- a/jscomp/test/arity_infer.js +++ b/jscomp/test/arity_infer.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f0(x) { let tmp; @@ -24,7 +25,7 @@ function f1(x) { RE_EXN_ID: "Not_found" } }); - return undefined(x); + return Curry._1(undefined, x); } function f3(x) { diff --git a/jscomp/test/array_test.js b/jscomp/test/array_test.js index 8e971d222b..3c43f34ab2 100644 --- a/jscomp/test/array_test.js +++ b/jscomp/test/array_test.js @@ -5,6 +5,7 @@ let Mt = require("./mt.js"); let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_array = require("../../lib/js/caml_array.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); @@ -19,7 +20,7 @@ function starts_with(xs, prefix, p) { } try { for(let i = 0; i < len2; ++i){ - if (!p(Caml_array.get(xs, i), Caml_array.get(prefix, i))) { + if (!Curry._2(p, Caml_array.get(xs, i), Caml_array.get(prefix, i))) { throw new Error(H, { cause: { RE_EXN_ID: H diff --git a/jscomp/test/async_await.js b/jscomp/test/async_await.js index ae29f57668..9f8973e2a9 100644 --- a/jscomp/test/async_await.js +++ b/jscomp/test/async_await.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); function next(n) { @@ -13,7 +14,7 @@ async function useNext() { function Make(I) { let get = async function (key) { - return await I.get(key); + return await Curry._1(I.get, key); }; return { get: get diff --git a/jscomp/test/async_inline.js b/jscomp/test/async_inline.js index 423dc97bb3..fda60ccfe8 100644 --- a/jscomp/test/async_inline.js +++ b/jscomp/test/async_inline.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let React = require("react"); async function willBeInlined() { @@ -24,24 +25,20 @@ function wrapSomethingAsync2() { } async function doSomethingAsync(someAsyncFunction) { - return await someAsyncFunction(); + return await Curry._1(someAsyncFunction, undefined); } -function broken(someAsyncFunction) { - return doSomethingAsync(someAsyncFunction); -} +let broken = doSomethingAsync; let M = { broken: broken }; async function broken$1(someAsyncFunction) { - return await someAsyncFunction(); + return await Curry._1(someAsyncFunction, undefined); } -function broken$2(someAsyncFunction) { - return broken$1(someAsyncFunction); -} +let broken$2 = broken$1; function curriedId(x) { return x; diff --git a/jscomp/test/basic_module_test.js b/jscomp/test/basic_module_test.js index cc66bb5a9e..cc3f95312f 100644 --- a/jscomp/test/basic_module_test.js +++ b/jscomp/test/basic_module_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Offset = require("./offset.js"); let Pr6726 = require("./pr6726.js"); let Mt_global = require("./mt_global.js"); @@ -14,7 +15,7 @@ function test(set) { count.contents = Offset.$$Set.cardinal(set) + count.contents | 0; } -test(Offset.M.$$Set.singleton("42")); +test(Curry._1(Offset.M.$$Set.singleton, "42")); let suites = { contents: /* [] */0 diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index 71c28192b9..db7281675d 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -338,16 +338,16 @@ function xor(n1, n2) { function hwb(n) { let h = function (i, j) { if (i === j) { - return mkVar(i); + return mkNode("Zero", i, "One"); } else { - return xor(and2(not(mkVar(j)), h(i, j - 1 | 0)), and2(mkVar(j), g(i, j - 1 | 0))); + return xor(and2(not(mkNode("Zero", j, "One")), h(i, j - 1 | 0)), and2(mkNode("Zero", j, "One"), g(i, j - 1 | 0))); } }; let g = function (i, j) { if (i === j) { - return mkVar(i); + return mkNode("Zero", i, "One"); } else { - return xor(and2(not(mkVar(i)), h(i + 1 | 0, j)), and2(mkVar(i), g(i + 1 | 0, j))); + return xor(and2(not(mkNode("Zero", i, "One")), h(i + 1 | 0, j)), and2(mkNode("Zero", i, "One"), g(i + 1 | 0, j))); } }; return h(0, n - 1 | 0); diff --git a/jscomp/test/bench.js b/jscomp/test/bench.js index d23518c4a5..ae9119dd39 100644 --- a/jscomp/test/bench.js +++ b/jscomp/test/bench.js @@ -1,28 +1,25 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); let Pervasives = require("../../lib/js/pervasives.js"); function map(f, a) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = Curry.__1(f); let l = a.length; if (l === 0) { return []; } - let r = Caml_array.make(l, f$1(a[0])); + let r = Caml_array.make(l, Curry._1(f$1, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f$1(a[i]); + r[i] = Curry._1(f$1, a[i]); } return r; } function init(l, f) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = Curry.__1(f); if (l === 0) { return []; } @@ -34,20 +31,18 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f$1(0)); + let res = Caml_array.make(l, Curry._1(f$1, 0)); for(let i = 1; i < l; ++i){ - res[i] = f$1(i); + res[i] = Curry._1(f$1, i); } return res; } function fold_left(f, x, a) { - let f$1 = function (x, y) { - return f(x, y); - }; + let f$1 = Curry.__2(f); let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f$1(r, a[i]); + r = Curry._2(f$1, r, a[i]); } return r; } diff --git a/jscomp/test/bs_abstract_test.js b/jscomp/test/bs_abstract_test.js index 650119951d..e30aa9e898 100644 --- a/jscomp/test/bs_abstract_test.js +++ b/jscomp/test/bs_abstract_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let v = { hd: 3, @@ -17,7 +18,7 @@ let f = { }; function uf(u) { - return u.y0(1); + return Curry._1(u.y0, 1); } function uf1(u) { @@ -27,21 +28,21 @@ function uf1(u) { } function uf2(u) { - return u.y1(1, 2); + return Curry._2(u.y1, 1, 2); } function uff(f) { - return f.yyyy(1); + return Curry._1(f.yyyy, 1); } function uff2(f) { - return f.yyyy1(1, 2); + return Curry._2(f.yyyy1, 1, 2); } function uff3(f) { let x = f.yyyy2; if (x !== undefined) { - return x(0); + return Curry._1(x, 0); } else { return 0; } diff --git a/jscomp/test/bs_auto_uncurry.js b/jscomp/test/bs_auto_uncurry.js index 3ea45355c0..107dab66c6 100644 --- a/jscomp/test/bs_auto_uncurry.js +++ b/jscomp/test/bs_auto_uncurry.js @@ -1,9 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_splice_call = require("../../lib/js/caml_splice_call.js"); -let Curry = {}; +let Curry$1 = {}; let Block = {}; @@ -74,7 +75,7 @@ function h(x, y, z) { } function h1(x, y, u, z) { - return map2(x, y, z(u)); + return map2(x, y, Curry._1(z, u)); } function add3(x) { @@ -134,7 +135,7 @@ function hh(xs, a) { ]); } -exports.Curry = Curry; +exports.Curry = Curry$1; exports.Block = Block; exports.xbs = xbs; exports.f = f; diff --git a/jscomp/test/bs_hashmap_test.js b/jscomp/test/bs_hashmap_test.js index 41e07fbb6e..e44cd0452e 100644 --- a/jscomp/test/bs_hashmap_test.js +++ b/jscomp/test/bs_hashmap_test.js @@ -9,6 +9,7 @@ let Belt_Array = require("../../lib/js/belt_Array.js"); let Belt_HashMap = require("../../lib/js/belt_HashMap.js"); let Belt_SortArray = require("../../lib/js/belt_SortArray.js"); let Array_data_util = require("./array_data_util.js"); +let Belt_internalBucketsType = require("../../lib/js/belt_internalBucketsType.js"); let suites = { contents: /* [] */0 @@ -30,15 +31,13 @@ function eq(x, y) { return x === y; } -function hash(x) { - return Hashtbl.hash(x); -} +let hash = Hashtbl.hash; let cmp = Caml.int_compare; let Y = Belt_Id.hashable(hash, eq); -let empty = Belt_HashMap.make(30, Y); +let empty = Belt_internalBucketsType.make(Y.hash, Y.eq, 30); function add(prim0, prim1) { return prim0 + prim1 | 0; @@ -79,7 +78,7 @@ eqx("File \"bs_hashmap_test.res\", line 42, characters 6-13", Belt_SortArray.sta let u$1 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); -let v$1 = Belt_HashMap.make(40, Y); +let v$1 = Belt_internalBucketsType.make(Y.hash, Y.eq, 40); Belt_HashMap.mergeMany(v$1, Belt_Array.zip(u$1, u$1)); diff --git a/jscomp/test/bs_hashset_int_test.js b/jscomp/test/bs_hashset_int_test.js index c7647d3d44..3abb87e389 100644 --- a/jscomp/test/bs_hashset_int_test.js +++ b/jscomp/test/bs_hashset_int_test.js @@ -7,6 +7,7 @@ let Belt_SetInt = require("../../lib/js/belt_SetInt.js"); let Array_data_util = require("./array_data_util.js"); let Belt_HashSetInt = require("../../lib/js/belt_HashSetInt.js"); let Belt_SortArrayInt = require("../../lib/js/belt_SortArrayInt.js"); +let Belt_internalBucketsType = require("../../lib/js/belt_internalBucketsType.js"); let suites = { contents: /* [] */0 @@ -54,7 +55,7 @@ eq("File \"bs_hashset_int_test.res\", line 25, characters 5-12", sum2(v), 6825); let u$1 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); -let v$1 = Belt_HashSetInt.make(40); +let v$1 = Belt_internalBucketsType.make(undefined, undefined, 40); Belt_HashSetInt.mergeMany(v$1, u$1); diff --git a/jscomp/test/bs_hashtbl_string_test.js b/jscomp/test/bs_hashtbl_string_test.js index ab60ab5044..7b5b7014be 100644 --- a/jscomp/test/bs_hashtbl_string_test.js +++ b/jscomp/test/bs_hashtbl_string_test.js @@ -10,6 +10,7 @@ let Belt_HashMapInt = require("../../lib/js/belt_HashMapInt.js"); let Belt_HashSetInt = require("../../lib/js/belt_HashSetInt.js"); let Belt_HashMapString = require("../../lib/js/belt_HashMapString.js"); let Caml_hash_primitive = require("../../lib/js/caml_hash_primitive.js"); +let Belt_internalBucketsType = require("../../lib/js/belt_internalBucketsType.js"); function hash_string(s) { return Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, s)); @@ -42,7 +43,7 @@ let Int = Belt_Id.hashable(Hashtbl.hash, (function (x, y) { return x === y; })); -let empty = Belt_HashMap.make(500000, Int); +let empty = Belt_internalBucketsType.make(Int.hash, Int.eq, 500000); function bench() { for(let i = 0; i <= 1000000; ++i){ @@ -67,7 +68,7 @@ function bench() { } function bench2(m) { - let empty = Belt_HashMap.make(1000000, m); + let empty = Belt_internalBucketsType.make(m.hash, m.eq, 1000000); for(let i = 0; i <= 1000000; ++i){ Belt_HashMap.set(empty, String(i), i); } @@ -147,7 +148,7 @@ function bench3(m) { let Sx = Belt_Id.comparable(Caml.string_compare); function bench4() { - let table = Belt_HashMapString.make(1000000); + let table = Belt_internalBucketsType.make(undefined, undefined, 1000000); for(let i = 0; i <= 1000000; ++i){ Belt_HashMapString.set(table, String(i), i); } @@ -185,7 +186,7 @@ function bench4() { } function bench5() { - let table = Belt_HashMap.make(1000000, Int); + let table = Belt_internalBucketsType.make(Int.hash, Int.eq, 1000000); console.time("bs_hashtbl_string_test.res 112"); for(let i = 0; i <= 1000000; ++i){ Belt_HashMap.set(table, i, i); @@ -229,7 +230,7 @@ function bench5() { } function bench6() { - let table = Belt_HashMapInt.make(1000000); + let table = Belt_internalBucketsType.make(undefined, undefined, 1000000); for(let i = 0; i <= 1000000; ++i){ Belt_HashMapInt.set(table, i, i); } @@ -267,7 +268,7 @@ function bench6() { } function bench7() { - let table = Belt_HashSetInt.make(2000000); + let table = Belt_internalBucketsType.make(undefined, undefined, 2000000); for(let i = 0; i <= 1000000; ++i){ Belt_HashSetInt.add(table, i); } diff --git a/jscomp/test/bs_list_test.js b/jscomp/test/bs_list_test.js index 52d626d882..174aa0efc9 100644 --- a/jscomp/test/bs_list_test.js +++ b/jscomp/test/bs_list_test.js @@ -809,25 +809,21 @@ let d = Belt_List.makeBy(10, (function (x) { return (x << 1); })); -function map2_add(x, y) { - return Belt_List.zipBy(x, y, add); -} - -$eq$tilde$9(map2_add(length_10_id, length_10_id), d); +$eq$tilde$9(Belt_List.zipBy(length_10_id, length_10_id, add), d); -$eq$tilde$9(map2_add(/* [] */0, { +$eq$tilde$9(Belt_List.zipBy(/* [] */0, { hd: 1, tl: /* [] */0 -}), /* [] */0); +}, add), /* [] */0); -$eq$tilde$9(map2_add({ +$eq$tilde$9(Belt_List.zipBy({ hd: 1, tl: /* [] */0 -}, /* [] */0), /* [] */0); +}, /* [] */0, add), /* [] */0); -$eq$tilde$9(map2_add(/* [] */0, /* [] */0), /* [] */0); +$eq$tilde$9(Belt_List.zipBy(/* [] */0, /* [] */0, add), /* [] */0); -$eq$tilde$9(map2_add(length_10_id, length_10_id), Belt_List.concat(Belt_List.map(length_8_id, (function (x) { +$eq$tilde$9(Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, (function (x) { return (x << 1); })), { hd: 16, @@ -837,7 +833,7 @@ $eq$tilde$9(map2_add(length_10_id, length_10_id), Belt_List.concat(Belt_List.map } })); -$eq$tilde$9(map2_add(length_10_id, length_8_id), Belt_List.mapWithIndex(length_8_id, (function (i, x) { +$eq$tilde$9(Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (function (i, x) { return i + x | 0; }))); diff --git a/jscomp/test/bs_map_set_dict_test.js b/jscomp/test/bs_map_set_dict_test.js index c3b367a6f5..f4b7b41de7 100644 --- a/jscomp/test/bs_map_set_dict_test.js +++ b/jscomp/test/bs_map_set_dict_test.js @@ -65,7 +65,7 @@ let m2 = { data: undefined }; -let data = undefined; +let data; Belt_Map.getId(m2); @@ -75,11 +75,13 @@ for(let i = 0; i <= 100000; ++i){ data = Belt_MapDict.set(data, i, i, m_dict.cmp); } +let data$1 = data; + let newm_cmp = m_dict.cmp; let newm = { cmp: newm_cmp, - data: data + data: data$1 }; console.log(newm); @@ -92,13 +94,13 @@ let m_dict$1 = Belt_Map.getId(m); let cmp = m_dict$1.cmp; -let data$1 = undefined; +let data$2; for(let i$1 = 0; i$1 <= 100000; ++i$1){ - data$1 = Belt_SetDict.add(data$1, i$1, cmp); + data$2 = Belt_SetDict.add(data$2, i$1, cmp); } -console.log(data$1); +console.log(data$2); function f(none) { return Belt_Map.fromArray(none, Icmp); diff --git a/jscomp/test/bs_map_test.js b/jscomp/test/bs_map_test.js index dd79a0faba..689645a29f 100644 --- a/jscomp/test/bs_map_test.js +++ b/jscomp/test/bs_map_test.js @@ -47,13 +47,9 @@ function b(loc, v) { }; } -function mapOfArray(x) { - return Belt_MapInt.fromArray(x); -} +let mapOfArray = Belt_MapInt.fromArray; -function setOfArray(x) { - return Belt_SetInt.fromArray(x); -} +let setOfArray = Belt_SetInt.fromArray; function emptyMap() { diff --git a/jscomp/test/bs_mutable_set_test.js b/jscomp/test/bs_mutable_set_test.js index 615216b6a4..16d171bb1f 100644 --- a/jscomp/test/bs_mutable_set_test.js +++ b/jscomp/test/bs_mutable_set_test.js @@ -55,7 +55,7 @@ for(let i = 0 ,i_finish = r.length; i < i_finish; ++i){ Belt_MutableSetInt.remove(u, r[i]); } -b("File \"bs_mutable_set_test.res\", line 33, characters 8-15", u.data === undefined); +b("File \"bs_mutable_set_test.res\", line 33, characters 8-15", Belt_MutableSetInt.isEmpty(u)); Belt_MutableSetInt.add(u, 0); @@ -67,13 +67,13 @@ Belt_MutableSetInt.add(u, 0); eq("File \"bs_mutable_set_test.res\", line 38, characters 9-16", Belt_internalAVLset.size(u.data), 3); -b("File \"bs_mutable_set_test.res\", line 39, characters 8-15", u.data !== undefined); +b("File \"bs_mutable_set_test.res\", line 39, characters 8-15", !Belt_MutableSetInt.isEmpty(u)); for(let i$1 = 0; i$1 <= 3; ++i$1){ Belt_MutableSetInt.remove(u, i$1); } -b("File \"bs_mutable_set_test.res\", line 43, characters 8-15", u.data === undefined); +b("File \"bs_mutable_set_test.res\", line 43, characters 8-15", Belt_MutableSetInt.isEmpty(u)); Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 20000)); @@ -101,11 +101,11 @@ Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 19999)); eq("File \"bs_mutable_set_test.res\", line 56, characters 9-16", Belt_internalAVLset.size(u.data), 1); -b("File \"bs_mutable_set_test.res\", line 57, characters 8-15", Belt_MutableSetInt.has(u, 20000)); +b("File \"bs_mutable_set_test.res\", line 57, characters 8-15", Belt_internalSetInt.has(u.data, 20000)); Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 30000)); -b("File \"bs_mutable_set_test.res\", line 59, characters 8-15", u.data === undefined); +b("File \"bs_mutable_set_test.res\", line 59, characters 8-15", Belt_MutableSetInt.isEmpty(u)); let xs$1 = Array_data_util.randomRange(1000, 2000); @@ -145,11 +145,9 @@ eq("File \"bs_mutable_set_test.res\", line 82, characters 9-16", indeedAded, 100 eq("File \"bs_mutable_set_test.res\", line 83, characters 9-16", Belt_internalAVLset.size(v.data), 1501); -let d = { +b("File \"bs_mutable_set_test.res\", line 84, characters 8-15", Belt_MutableSetInt.isEmpty({ data: undefined -}; - -b("File \"bs_mutable_set_test.res\", line 84, characters 8-15", d.data === undefined); +})); eq("File \"bs_mutable_set_test.res\", line 85, characters 9-16", Belt_internalAVLset.minimum(v.data), 500); @@ -173,9 +171,9 @@ eq("File \"bs_mutable_set_test.res\", line 91, characters 9-16", Belt_internalAV Belt_internalAVLset.checkInvariantInternal(v.data); -eq("File \"bs_mutable_set_test.res\", line 93, characters 9-16", Belt_MutableSetInt.get(v, 3), undefined); +eq("File \"bs_mutable_set_test.res\", line 93, characters 9-16", Belt_internalSetInt.get(v.data, 3), undefined); -eq("File \"bs_mutable_set_test.res\", line 94, characters 9-16", Belt_MutableSetInt.get(v, 1200), 1200); +eq("File \"bs_mutable_set_test.res\", line 94, characters 9-16", Belt_internalSetInt.get(v.data, 1200), 1200); let match = Belt_MutableSetInt.split(v, 1000); @@ -199,9 +197,7 @@ b("File \"bs_mutable_set_test.res\", line 99, characters 8-15", Belt_MutableSetI b("File \"bs_mutable_set_test.res\", line 100, characters 8-15", Belt_MutableSetInt.subset(bb, v)); -let d$1 = Belt_MutableSetInt.intersect(aa, bb); - -b("File \"bs_mutable_set_test.res\", line 101, characters 8-15", d$1.data === undefined); +b("File \"bs_mutable_set_test.res\", line 101, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa, bb))); let c = Belt_MutableSetInt.removeCheck(v, 1000); @@ -229,9 +225,7 @@ b("File \"bs_mutable_set_test.res\", line 108, characters 8-15", Belt_MutableSet b("File \"bs_mutable_set_test.res\", line 109, characters 8-15", Belt_MutableSetInt.subset(bb$1, v)); -let d$2 = Belt_MutableSetInt.intersect(aa$1, bb$1); - -b("File \"bs_mutable_set_test.res\", line 110, characters 8-15", d$2.data === undefined); +b("File \"bs_mutable_set_test.res\", line 110, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa$1, bb$1))); let xs$2 = Array_data_util.randomRange(0, 100); @@ -434,7 +428,7 @@ for(let i$2 = 0; i$2 <= 100000; ++i$2){ Belt_internalAVLset.checkInvariantInternal(v$1.data); b("File \"bs_mutable_set_test.res\", line 188, characters 10-17", Belt_Range.every(0, 100000, (function (i) { - return Belt_MutableSetInt.has(v$1, i); + return Belt_internalSetInt.has(v$1.data, i); }))); eq("File \"bs_mutable_set_test.res\", line 189, characters 5-12", Belt_internalAVLset.size(v$1.data), 100001); @@ -475,7 +469,7 @@ for(let i$4 = 0 ,i_finish$2 = vv.length; i$4 < i_finish$2; ++i$4){ eq("File \"bs_mutable_set_test.res\", line 216, characters 5-12", Belt_internalAVLset.size(v$3.data), 0); -b("File \"bs_mutable_set_test.res\", line 217, characters 4-11", v$3.data === undefined); +b("File \"bs_mutable_set_test.res\", line 217, characters 4-11", Belt_MutableSetInt.isEmpty(v$3)); let xs$25 = Belt_Array.makeBy(30, (function (i) { return i; @@ -658,11 +652,11 @@ let xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), (function (x) { return (x << 1); })); -let d$3 = { +let d = { data: Belt_internalSetInt.fromArray(xs$30) }; -let match$8 = Belt_MutableSetInt.split(d$3, 1001); +let match$8 = Belt_MutableSetInt.split(d, 1001); let match$9 = match$8[0]; diff --git a/jscomp/test/bs_poly_map_test.js b/jscomp/test/bs_poly_map_test.js index 0865fa4cc5..d0aaf258eb 100644 --- a/jscomp/test/bs_poly_map_test.js +++ b/jscomp/test/bs_poly_map_test.js @@ -51,8 +51,7 @@ function mergeInter(s1, s2) { } })); - let x = Belt_MapDict.keysToArray(m.data); - return Belt_Set.fromArray(x, Icmp); + return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function mergeUnion(s1, s2) { @@ -62,8 +61,7 @@ function mergeUnion(s1, s2) { } })); - let x = Belt_MapDict.keysToArray(m.data); - return Belt_Set.fromArray(x, Icmp); + return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function mergeDiff(s1, s2) { @@ -73,8 +71,7 @@ function mergeDiff(s1, s2) { } })); - let x = Belt_MapDict.keysToArray(m.data); - return Belt_Set.fromArray(x, Icmp); + return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function randomRange(i, j) { @@ -86,33 +83,19 @@ function randomRange(i, j) { })); } -let x = randomRange(0, 100); - -let u0 = Belt_Map.fromArray(x, Icmp); - -let x$1 = randomRange(30, 120); - -let u1 = Belt_Map.fromArray(x$1, Icmp); - -let x$2 = Array_data_util.range(30, 100); - -b("File \"bs_poly_map_test.res\", line 64, characters 4-11", Belt_Set.eq(mergeInter(u0, u1), Belt_Set.fromArray(x$2, Icmp))); +let u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); -let x$3 = Array_data_util.range(0, 120); +let u1 = Belt_Map.fromArray(randomRange(30, 120), Icmp); -b("File \"bs_poly_map_test.res\", line 65, characters 4-11", Belt_Set.eq(mergeUnion(u0, u1), Belt_Set.fromArray(x$3, Icmp))); +b("File \"bs_poly_map_test.res\", line 64, characters 4-11", Belt_Set.eq(mergeInter(u0, u1), Belt_Set.fromArray(Array_data_util.range(30, 100), Icmp))); -let x$4 = Array_data_util.range(0, 29); +b("File \"bs_poly_map_test.res\", line 65, characters 4-11", Belt_Set.eq(mergeUnion(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 120), Icmp))); -b("File \"bs_poly_map_test.res\", line 66, characters 4-11", Belt_Set.eq(mergeDiff(u0, u1), Belt_Set.fromArray(x$4, Icmp))); +b("File \"bs_poly_map_test.res\", line 66, characters 4-11", Belt_Set.eq(mergeDiff(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 29), Icmp))); -let x$5 = Array_data_util.range(101, 120); +b("File \"bs_poly_map_test.res\", line 67, characters 4-11", Belt_Set.eq(mergeDiff(u1, u0), Belt_Set.fromArray(Array_data_util.range(101, 120), Icmp))); -b("File \"bs_poly_map_test.res\", line 67, characters 4-11", Belt_Set.eq(mergeDiff(u1, u0), Belt_Set.fromArray(x$5, Icmp))); - -let x$6 = randomRange(0, 10); - -let a0 = Belt_Map.fromArray(x$6, Icmp); +let a0 = Belt_Map.fromArray(randomRange(0, 10), Icmp); let a1 = Belt_Map.set(a0, 3, 33); @@ -176,9 +159,7 @@ let a8 = Belt_Map.removeMany(a7, Array_data_util.randomRange(0, 100)); b("File \"bs_poly_map_test.res\", line 101, characters 4-11", Belt_MapDict.isEmpty(a8.data)); -let x$7 = randomRange(0, 100); - -let u0$1 = Belt_Map.fromArray(x$7, Icmp); +let u0$1 = Belt_Map.fromArray(randomRange(0, 100), Icmp); let u1$1 = Belt_Map.set(u0$1, 3, 32); @@ -207,14 +188,12 @@ let m = { let m1 = acc(m, Belt_Array.concat(Array_data_util.randomRange(0, 20), Array_data_util.randomRange(10, 30))); -let x$8 = Belt_Array.makeBy(31, (function (i) { +b("File \"bs_poly_map_test.res\", line 126, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, (function (i) { return [ i, i >= 10 && i <= 20 ? 2 : 1 ]; -})); - -b("File \"bs_poly_map_test.res\", line 126, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(x$8, Icmp), (function (x, y) { +})), Icmp), (function (x, y) { return x === y; }))); @@ -232,14 +211,12 @@ let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10 ]; }))); -let x$9 = Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { +let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { return [ x, x ]; -})); - -let v2 = Belt_Map.fromArray(x$9, Icmp); +})), Icmp); b("File \"bs_poly_map_test.res\", line 150, characters 4-11", Belt_Map.eq(v1, v2, (function (x, y) { return x === y; diff --git a/jscomp/test/bs_poly_mutable_map_test.js b/jscomp/test/bs_poly_mutable_map_test.js index 3bbcd3dbfa..9563788e47 100644 --- a/jscomp/test/bs_poly_mutable_map_test.js +++ b/jscomp/test/bs_poly_mutable_map_test.js @@ -45,9 +45,7 @@ function randomRange(i, j) { })); } -let x = randomRange(0, 10); - -let a0 = Belt_MutableMap.fromArray(x, Icmp); +let a0 = Belt_MutableMap.fromArray(randomRange(0, 10), Icmp); Belt_MutableMap.set(a0, 3, 33); @@ -74,11 +72,9 @@ eq("File \"bs_poly_mutable_map_test.res\", line 29, characters 5-12", Belt_inter Belt_MutableMap.removeMany(a0, Array_data_util.randomRange(0, 100)); -b("File \"bs_poly_mutable_map_test.res\", line 31, characters 4-11", a0.data === undefined); - -let x$1 = randomRange(0, 10000); +b("File \"bs_poly_mutable_map_test.res\", line 31, characters 4-11", Belt_MutableMap.isEmpty(a0)); -let a0$1 = Belt_MutableMap.fromArray(x$1, Icmp); +let a0$1 = Belt_MutableMap.fromArray(randomRange(0, 10000), Icmp); Belt_MutableMap.set(a0$1, 2000, 33); diff --git a/jscomp/test/bs_poly_mutable_set_test.js b/jscomp/test/bs_poly_mutable_set_test.js index 676ec6ca82..555faffc53 100644 --- a/jscomp/test/bs_poly_mutable_set_test.js +++ b/jscomp/test/bs_poly_mutable_set_test.js @@ -65,7 +65,7 @@ for(let i = 0 ,i_finish = r.length; i < i_finish; ++i){ Belt_MutableSet.remove(u, r[i]); } -b("File \"bs_poly_mutable_set_test.res\", line 28, characters 4-11", u.data === undefined); +b("File \"bs_poly_mutable_set_test.res\", line 28, characters 4-11", Belt_MutableSet.isEmpty(u)); Belt_MutableSet.add(u, 0); @@ -77,13 +77,13 @@ Belt_MutableSet.add(u, 0); eq("File \"bs_poly_mutable_set_test.res\", line 33, characters 5-12", Belt_internalAVLset.size(u.data), 3); -b("File \"bs_poly_mutable_set_test.res\", line 34, characters 4-11", u.data !== undefined); +b("File \"bs_poly_mutable_set_test.res\", line 34, characters 4-11", !Belt_MutableSet.isEmpty(u)); for(let i$1 = 0; i$1 <= 3; ++i$1){ Belt_MutableSet.remove(u, i$1); } -b("File \"bs_poly_mutable_set_test.res\", line 38, characters 4-11", u.data === undefined); +b("File \"bs_poly_mutable_set_test.res\", line 38, characters 4-11", Belt_MutableSet.isEmpty(u)); Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 20000)); @@ -115,7 +115,7 @@ b("File \"bs_poly_mutable_set_test.res\", line 52, characters 4-11", Belt_Mutabl Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 30000)); -b("File \"bs_poly_mutable_set_test.res\", line 54, characters 4-11", u.data === undefined); +b("File \"bs_poly_mutable_set_test.res\", line 54, characters 4-11", Belt_MutableSet.isEmpty(u)); let none$1 = Array_data_util.randomRange(1000, 2000); @@ -153,12 +153,10 @@ eq("File \"bs_poly_mutable_set_test.res\", line 77, characters 5-12", indeedAded eq("File \"bs_poly_mutable_set_test.res\", line 78, characters 5-12", Belt_internalAVLset.size(v.data), 1501); -let d = { +b("File \"bs_poly_mutable_set_test.res\", line 79, characters 4-11", Belt_MutableSet.isEmpty({ cmp: IntCmp.cmp, data: undefined -}; - -b("File \"bs_poly_mutable_set_test.res\", line 79, characters 4-11", d.data === undefined); +})); eq("File \"bs_poly_mutable_set_test.res\", line 80, characters 5-12", Belt_internalAVLset.minimum(v.data), 500); @@ -208,9 +206,7 @@ b("File \"bs_poly_mutable_set_test.res\", line 94, characters 4-11", Belt_Mutabl b("File \"bs_poly_mutable_set_test.res\", line 95, characters 4-11", Belt_MutableSet.subset(bb, v)); -let d$1 = Belt_MutableSet.intersect(aa, bb); - -b("File \"bs_poly_mutable_set_test.res\", line 96, characters 4-11", d$1.data === undefined); +b("File \"bs_poly_mutable_set_test.res\", line 96, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa, bb))); let c = Belt_MutableSet.removeCheck(v, 1000); @@ -238,9 +234,7 @@ b("File \"bs_poly_mutable_set_test.res\", line 103, characters 4-11", Belt_Mutab b("File \"bs_poly_mutable_set_test.res\", line 104, characters 4-11", Belt_MutableSet.subset(bb$1, v)); -let d$2 = Belt_MutableSet.intersect(aa$1, bb$1); - -b("File \"bs_poly_mutable_set_test.res\", line 105, characters 4-11", d$2.data === undefined); +b("File \"bs_poly_mutable_set_test.res\", line 105, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa$1, bb$1))); let none$2 = Array_data_util.randomRange(0, 100); diff --git a/jscomp/test/bs_queue_test.js b/jscomp/test/bs_queue_test.js index 432d8a9bdb..2d9e79e69a 100644 --- a/jscomp/test/bs_queue_test.js +++ b/jscomp/test/bs_queue_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); let Belt_MutableQueue = require("../../lib/js/belt_MutableQueue.js"); @@ -24,7 +25,7 @@ function b(loc, x) { function does_raise(f, q) { try { - f(q); + Curry._1(f, q); return false; } catch (exn){ @@ -56,7 +57,7 @@ if (!(Caml_obj.equal(Belt_MutableQueue.toArray(q), []) && q.length === 0)) { }); } -if (!(Caml_obj.equal(Belt_MutableQueue.toArray($plus$plus(q, 1)), [1]) && q.length === 1)) { +if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 1), q)), [1]) && q.length === 1)) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -69,7 +70,7 @@ if (!(Caml_obj.equal(Belt_MutableQueue.toArray($plus$plus(q, 1)), [1]) && q.leng }); } -if (!(Caml_obj.equal(Belt_MutableQueue.toArray($plus$plus(q, 2)), [ +if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 2), q)), [ 1, 2 ]) && q.length === 2)) { @@ -85,7 +86,7 @@ if (!(Caml_obj.equal(Belt_MutableQueue.toArray($plus$plus(q, 2)), [ }); } -if (!(Caml_obj.equal(Belt_MutableQueue.toArray($plus$plus(q, 3)), [ +if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 3), q)), [ 1, 2, 3 @@ -102,7 +103,7 @@ if (!(Caml_obj.equal(Belt_MutableQueue.toArray($plus$plus(q, 3)), [ }); } -if (!(Caml_obj.equal(Belt_MutableQueue.toArray($plus$plus(q, 4)), [ +if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 4), q)), [ 1, 2, 3, @@ -250,7 +251,7 @@ let q$1 = { last: undefined }; -if (Belt_MutableQueue.popExn($plus$plus(q$1, 1)) !== 1) { +if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 1), q$1)) !== 1) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -276,7 +277,7 @@ if (!does_raise(Belt_MutableQueue.popExn, q$1)) { }); } -if (Belt_MutableQueue.popExn($plus$plus(q$1, 2)) !== 2) { +if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 2), q$1)) !== 2) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -321,7 +322,7 @@ let q$2 = { last: undefined }; -if (Belt_MutableQueue.peekExn($plus$plus(q$2, 1)) !== 1) { +if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 1), q$2)) !== 1) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -334,7 +335,7 @@ if (Belt_MutableQueue.peekExn($plus$plus(q$2, 1)) !== 1) { }); } -if (Belt_MutableQueue.peekExn($plus$plus(q$2, 2)) !== 1) { +if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 2), q$2)) !== 1) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -347,7 +348,7 @@ if (Belt_MutableQueue.peekExn($plus$plus(q$2, 2)) !== 1) { }); } -if (Belt_MutableQueue.peekExn($plus$plus(q$2, 3)) !== 1) { +if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 3), q$2)) !== 1) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -1371,4 +1372,4 @@ exports.b = b; exports.Q = Q; exports.does_raise = does_raise; exports.$plus$plus = $plus$plus; -/* q Not a pure module */ +/* Not a pure module */ diff --git a/jscomp/test/bs_set_int_test.js b/jscomp/test/bs_set_int_test.js index 83bfef16e5..80039fd7d5 100644 --- a/jscomp/test/bs_set_int_test.js +++ b/jscomp/test/bs_set_int_test.js @@ -52,7 +52,7 @@ let u = Belt_SetInt.intersect(Belt_SetInt.fromArray([ 5 ])); -b("File \"bs_set_int_test.res\", line 27, characters 11-18", $eq$tilde(u, [3])); +b("File \"bs_set_int_test.res\", line 27, characters 11-18", Belt_SetInt.eq(Belt_SetInt.fromArray([3]), u)); function range(i, j) { return $$Array.init((j - i | 0) + 1 | 0, (function (k) { @@ -68,7 +68,9 @@ function revRange(i, j) { let v = Belt_SetInt.fromArray($$Array.append(range(100, 1000), revRange(400, 1500))); -b("File \"bs_set_int_test.res\", line 37, characters 4-11", $eq$tilde(v, range(100, 1500))); +let i = range(100, 1500); + +b("File \"bs_set_int_test.res\", line 37, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); let match = Belt_SetInt.partition(v, (function (x) { return x % 3 === 0; @@ -78,11 +80,11 @@ let l; let r; -for(let i = 100; i <= 1500; ++i){ - if (i % 3 === 0) { - l = Belt_SetInt.add(l, i); +for(let i$1 = 100; i$1 <= 1500; ++i$1){ + if (i$1 % 3 === 0) { + l = Belt_SetInt.add(l, i$1); } else { - r = Belt_SetInt.add(r, i); + r = Belt_SetInt.add(r, i$1); } } @@ -94,17 +96,41 @@ b("File \"bs_set_int_test.res\", line 50, characters 4-11", Belt_SetInt.eq(match b("File \"bs_set_int_test.res\", line 51, characters 4-11", Belt_SetInt.eq(match[1], nr)); -b("File \"bs_set_int_test.res\", line 55, characters 2-9", $eq$tilde(Belt_SetInt.intersect(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))), range(50, 100))); +let i$2 = range(50, 100); + +let s = Belt_SetInt.intersect(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); + +b("File \"bs_set_int_test.res\", line 55, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$2), s)); + +let i$3 = range(1, 200); + +let s$1 = Belt_SetInt.union(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); + +b("File \"bs_set_int_test.res\", line 66, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$3), s$1)); + +let i$4 = range(1, 49); + +let s$2 = Belt_SetInt.diff(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); + +b("File \"bs_set_int_test.res\", line 77, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$4), s$2)); + +let i$5 = revRange(50, 100); + +let s$3 = Belt_SetInt.intersect(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); + +b("File \"bs_set_int_test.res\", line 88, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$5), s$3)); + +let i$6 = revRange(1, 200); -b("File \"bs_set_int_test.res\", line 66, characters 2-9", $eq$tilde(Belt_SetInt.union(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))), range(1, 200))); +let s$4 = Belt_SetInt.union(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); -b("File \"bs_set_int_test.res\", line 77, characters 2-9", $eq$tilde(Belt_SetInt.diff(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))), range(1, 49))); +b("File \"bs_set_int_test.res\", line 99, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$6), s$4)); -b("File \"bs_set_int_test.res\", line 88, characters 2-9", $eq$tilde(Belt_SetInt.intersect(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))), revRange(50, 100))); +let i$7 = revRange(1, 49); -b("File \"bs_set_int_test.res\", line 99, characters 2-9", $eq$tilde(Belt_SetInt.union(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))), revRange(1, 200))); +let s$5 = Belt_SetInt.diff(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); -b("File \"bs_set_int_test.res\", line 110, characters 2-9", $eq$tilde(Belt_SetInt.diff(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))), revRange(1, 49))); +b("File \"bs_set_int_test.res\", line 110, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$7), s$5)); let ss = [ 1, diff --git a/jscomp/test/bs_splice_partial.js b/jscomp/test/bs_splice_partial.js index aa01df223d..eaf7fa5ef8 100644 --- a/jscomp/test/bs_splice_partial.js +++ b/jscomp/test/bs_splice_partial.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function test(g) { g.xx(10, 3, "xxx", 1, 2, 3); @@ -26,9 +27,9 @@ function test_hi__2(x) { } function test_cb(x) { - x.cb("hI", 1, 2, 3)(3); - x.cb("hI", 1, 2, 3)(3); - return x.cb2("hI", 1, 2, 3)(3); + Curry._1(x.cb("hI", 1, 2, 3), 3); + Curry._1(x.cb("hI", 1, 2, 3), 3); + return Curry._1(x.cb2("hI", 1, 2, 3), 3); } function f(x) { diff --git a/jscomp/test/bs_unwrap_test.js b/jscomp/test/bs_unwrap_test.js index 25e7a582d8..af678fe568 100644 --- a/jscomp/test/bs_unwrap_test.js +++ b/jscomp/test/bs_unwrap_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); console.log([ @@ -48,9 +49,7 @@ console.log(5, Caml_option.option_unwrap(some_arg)); console.log(6, undefined); -console.log(7, Caml_option.option_unwrap((function () { - console.log("trace"); -})())); +console.log(7, Caml_option.option_unwrap((console.log("trace"), undefined))); function dyn_log3(prim0, prim1, prim2) { console.log(prim0.VAL, Caml_option.option_unwrap(prim1)); @@ -87,7 +86,7 @@ function ff0(x, p) { } function ff1(x, p) { - console.log(Caml_option.option_unwrap(x()), p); + console.log(Caml_option.option_unwrap(Curry._1(x, undefined)), p); } function test00() { diff --git a/jscomp/test/chain_code_test.js b/jscomp/test/chain_code_test.js index a290de375a..904dd4e712 100644 --- a/jscomp/test/chain_code_test.js +++ b/jscomp/test/chain_code_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -37,18 +38,18 @@ function f2(h) { } function f3(h, x, y) { - return h.paint(x, y).draw(x, y); + return Curry._2(Curry._2(h.paint, x, y).draw, x, y); } function f4(h, x, y) { - h.paint = [ + Curry._1(h.paint, [ x, y - ]; - h.paint.draw = [ + ]); + Curry._1(h.paint.draw, [ x, y - ]; + ]); } eq("File \"chain_code_test.res\", line 24, characters 12-19", 32, ({ diff --git a/jscomp/test/class_type_ffi_test.js b/jscomp/test/class_type_ffi_test.js index b38f435362..234fae64d8 100644 --- a/jscomp/test/class_type_ffi_test.js +++ b/jscomp/test/class_type_ffi_test.js @@ -1,26 +1,81 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function test_set(x) { - x.length__aux = 3; + Curry._1(x.length__aux, 3); } function ff(fn, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { - return fn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); + return Curry.app(fn, [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11 + ]); } function ff2(fn, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { - return fn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); + return Curry.app(fn, [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12 + ]); } function off2(o, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { - return o.huge_method(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); + return Curry.app(o.huge_method, [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12 + ]); } function mk_f() { return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { - return a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); + return Curry.app(a0, [ + a1, + a2, + a3, + a4, + a5, + a6, + a7, + a8, + a9, + a10, + a11, + a12 + ]); }; } diff --git a/jscomp/test/coercion_module_alias_test.js b/jscomp/test/coercion_module_alias_test.js index 42b9423056..abdd32ce6f 100644 --- a/jscomp/test/coercion_module_alias_test.js +++ b/jscomp/test/coercion_module_alias_test.js @@ -3,6 +3,7 @@ let Char = require("../../lib/js/char.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); function l(prim) { console.log(prim); @@ -24,9 +25,7 @@ let prim$2 = Char.chr(66); console.log(prim$2); -function f(x) { - return List.length(x); -} +let f = List.length; function g(x) { return List.length(List.map((function (prim) { @@ -154,7 +153,7 @@ let M9 = { C$p: C$p$1 }; -let prim$4 = Char.chr(66); +let prim$4 = Curry._1(Char.chr, 66); console.log(prim$4); @@ -162,7 +161,7 @@ let M10 = { C$p: Char }; -let prim$5 = M10.C$p.chr(66); +let prim$5 = Curry._1(M10.C$p.chr, 66); console.log(prim$5); diff --git a/jscomp/test/complex_if_test.js b/jscomp/test/complex_if_test.js index 6fc7e2d7c5..ac9d60a393 100644 --- a/jscomp/test/complex_if_test.js +++ b/jscomp/test/complex_if_test.js @@ -127,7 +127,7 @@ let suites_0 = [ (function (param) { return { TAG: "Eq", - _0: string_escaped("\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), + _0: Bytes.to_string(escaped(Bytes.of_string("\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"))), _1: "\\000\\001\\002\\003\\004\\005\\006\\007\\b\\t\\n\\011\\012\\r\\014\\015\\016\\017\\018\\019\\020\\021\\022\\023\\024\\025\\026\\027\\028\\029\\030\\031 !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\127\\128\\129\\130\\131\\132\\133\\134\\135\\136\\137\\138\\139\\140\\141\\142\\143\\144\\145\\146\\147\\148\\149\\150\\151\\152\\153\\154\\155\\156\\157\\158\\159\\160\\161\\162\\163\\164\\165\\166\\167\\168\\169\\170\\171\\172\\173\\174\\175\\176\\177\\178\\179\\180\\181\\182\\183\\184\\185\\186\\187\\188\\189\\190\\191\\192\\193\\194\\195\\196\\197\\198\\199\\200\\201\\202\\203\\204\\205\\206\\207\\208\\209\\210\\211\\212\\213\\214\\215\\216\\217\\218\\219\\220\\221\\222\\223\\224\\225\\226\\227\\228\\229\\230\\231\\232\\233\\234\\235\\236\\237\\238\\239\\240\\241\\242\\243\\244\\245\\246\\247\\248\\249\\250\\251\\252\\253\\254\\255" }; }) diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 8939bea0dd..20edce5c06 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); function test() { @@ -14,11 +15,11 @@ function test() { let acc = _acc; let n = _n; if (n === 0) { - return acc(); + return Curry._1(acc, undefined); } _acc = (function () { v.contents = v.contents + n | 0; - return acc(); + return Curry._1(acc, undefined); }); _n = n - 1 | 0; continue; @@ -43,7 +44,7 @@ function test_closure() { })); } $$Array.iter((function (i) { - v.contents = v.contents + i(0) | 0; + v.contents = v.contents + Curry._1(i, 0) | 0; }), arr); return v.contents; } @@ -62,7 +63,7 @@ function test_closure2() { })); } $$Array.iter((function (i) { - v.contents = v.contents + i(0) | 0; + v.contents = v.contents + Curry._1(i, 0) | 0; }), arr); return v.contents; } diff --git a/jscomp/test/defunctor_make_test.js b/jscomp/test/defunctor_make_test.js index 75b6eca17b..2da3f40a1e 100644 --- a/jscomp/test/defunctor_make_test.js +++ b/jscomp/test/defunctor_make_test.js @@ -2,6 +2,7 @@ 'use strict'; let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); function getcompare(x) { return x; @@ -119,7 +120,7 @@ function add(x, data, compare, x_) { let d = x_._2; let v = x_._1; let l = x_._0; - let c = compare(x, v); + let c = Curry._2(compare, x, v); if (c === 0) { return { TAG: "Node", diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index 03af90cb46..e0dc2d539c 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let React = require("react"); let ReactDom = require("react-dom"); @@ -26,7 +27,7 @@ function map(f, x) { } else { return { TAG: "Cons", - _0: f(x._0), + _0: Curry._1(f, x._0), _1: map(f, x._1) }; } diff --git a/jscomp/test/earger_curry_test.js b/jscomp/test/earger_curry_test.js index f7ad48dad5..6ffeaa098d 100644 --- a/jscomp/test/earger_curry_test.js +++ b/jscomp/test/earger_curry_test.js @@ -2,28 +2,25 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); let Pervasives = require("../../lib/js/pervasives.js"); function map(f, a) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = Curry.__1(f); let l = a.length; if (l === 0) { return []; } - let r = Caml_array.make(l, f$1(a[0])); + let r = Caml_array.make(l, Curry._1(f$1, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f$1(a[i]); + r[i] = Curry._1(f$1, a[i]); } return r; } function init(l, f) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = Curry.__1(f); if (l === 0) { return []; } @@ -35,20 +32,18 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f$1(0)); + let res = Caml_array.make(l, Curry._1(f$1, 0)); for(let i = 1; i < l; ++i){ - res[i] = f$1(i); + res[i] = Curry._1(f$1, i); } return res; } function fold_left(f, x, a) { - let f$1 = function (x, y) { - return f(x, y); - }; + let f$1 = Curry.__2(f); let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f$1(r, a[i]); + r = Curry._2(f$1, r, a[i]); } return r; } @@ -133,13 +128,13 @@ function g(x) { return u; } -let a = f(0)(3, 4); +let a = Curry._2(f(0), 3, 4); -let b = f(0)(3, 5); +let b = Curry._2(f(0), 3, 5); -let c = g(0)(3, 4); +let c = Curry._2(g(0), 3, 4); -let d = g(0)(3, 5); +let d = Curry._2(g(0), 3, 5); eq("File \"earger_curry_test.res\", line 141, characters 5-12", a, 10); diff --git a/jscomp/test/event_ffi.js b/jscomp/test/event_ffi.js index c1a9fb070f..c2a6a955a5 100644 --- a/jscomp/test/event_ffi.js +++ b/jscomp/test/event_ffi.js @@ -2,40 +2,40 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); function h0(x) { - return x(); + return Curry._1(x, undefined); } function h00(x) { - return x(); + return Curry._1(x, undefined); } function h1(x, y) { - return x(y); + return Curry._1(x, y); } function h10(x) { - return x(3); + return Curry._1(x, 3); } function h30(x) { return function (a) { - return x(3, 3, a); + return Curry._3(x, 3, 3, a); }; } function h33(x) { - return x(1, 2, 3); + return Curry._3(x, 1, 2, 3); } function h34(x) { - return x(1, 2, 3)(4); + return Curry._4(x, 1, 2, 3, 4); } function ocaml_run(b, c) { - let x = 1; - return (x + b | 0) + c | 0; + return (1 + b | 0) + c | 0; } function a0() { diff --git a/jscomp/test/exception_raise_test.js b/jscomp/test/exception_raise_test.js index e46937b21b..30b487ca53 100644 --- a/jscomp/test/exception_raise_test.js +++ b/jscomp/test/exception_raise_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Js_exn = require("../../lib/js/js_exn.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -18,7 +19,7 @@ let D = /* @__PURE__ */Caml_exceptions.create("Exception_raise_test.D"); function appf(g, x) { let A = /* @__PURE__ */Caml_exceptions.create("A"); try { - return g(x); + return Curry._1(g, x); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -189,7 +190,7 @@ function eq(loc, x, y) { } try { - ((()=>{throw 2})()); + (Curry._1((()=>{throw 2}), undefined)); } catch (raw_e$2){ let e = Caml_js_exceptions.internalToOCamlException(raw_e$2); @@ -211,12 +212,12 @@ catch (raw_e$3){ function fff0(x, g) { let val; try { - val = x(); + val = Curry._1(x, undefined); } catch (exn){ return 1; } - return g(); + return Curry._1(g, undefined); } function input_lines(ic, _acc) { diff --git a/jscomp/test/exception_rebound_err_test.js b/jscomp/test/exception_rebound_err_test.js index 3c0843c748..71d7eff048 100644 --- a/jscomp/test/exception_rebound_err_test.js +++ b/jscomp/test/exception_rebound_err_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -67,7 +68,7 @@ function test_js_error4() { function f(g) { try { - return g(); + return Curry._1(g, undefined); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); diff --git a/jscomp/test/exception_value_test.js b/jscomp/test/exception_value_test.js index a48c45483f..60384a916d 100644 --- a/jscomp/test/exception_value_test.js +++ b/jscomp/test/exception_value_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Js_exn = require("../../lib/js/js_exn.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -50,7 +51,7 @@ let u = { function test_not_found(f, param) { try { - return f(); + return Curry._1(f, undefined); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); diff --git a/jscomp/test/ext_array_test.js b/jscomp/test/ext_array_test.js index 6e74676a71..d8e014a68f 100644 --- a/jscomp/test/ext_array_test.js +++ b/jscomp/test/ext_array_test.js @@ -3,6 +3,7 @@ let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); let Caml_option = require("../../lib/js/caml_option.js"); @@ -65,7 +66,7 @@ function filter(f, a) { return reverse_of_list(acc); } let v = a[i]; - if (f(v)) { + if (Curry._1(f, v)) { _i = i + 1 | 0; _acc = { hd: v, @@ -89,7 +90,7 @@ function filter_map(f, a) { return reverse_of_list(acc); } let v = a[i]; - let v$1 = f(v); + let v$1 = Curry._1(f, v); if (v$1 !== undefined) { _i = i + 1 | 0; _acc = { @@ -104,32 +105,32 @@ function filter_map(f, a) { } function range(from, to_) { - if (from <= to_) { - return $$Array.init((to_ - from | 0) + 1 | 0, (function (i) { - return i + from | 0; - })); + if (from > to_) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_array_test.range" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_array_test.range" - } - }); + return $$Array.init((to_ - from | 0) + 1 | 0, (function (i) { + return i + from | 0; + })); } function map2i(f, a, b) { let len = a.length; - if (len === b.length) { - return $$Array.mapi((function (i, a) { - return f(i, a, b[i]); - }), a); + if (len !== b.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_array_test.map2i" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_array_test.map2i" - } - }); + return $$Array.mapi((function (i, a) { + return Curry._3(f, i, a, b[i]); + }), a); } function tolist_aux(a, f, _i, _res) { @@ -140,7 +141,7 @@ function tolist_aux(a, f, _i, _res) { return res; } let v = a[i]; - let v$1 = f(v); + let v$1 = Curry._1(f, v); _res = v$1 !== undefined ? ({ hd: Caml_option.valFromOption(v$1), tl: res @@ -163,7 +164,7 @@ function of_list_map(f, a) { return []; } let tl = a.tl; - let hd = f(a.hd); + let hd = Curry._1(f, a.hd); let len = List.length(tl) + 1 | 0; let arr = Caml_array.make(len, hd); let _i = 1; @@ -174,7 +175,7 @@ function of_list_map(f, a) { if (!x) { return arr; } - arr[i] = f(x.hd); + arr[i] = Curry._1(f, x.hd); _x = x.tl; _i = i + 1 | 0; continue; @@ -189,7 +190,7 @@ function rfind_with_index(arr, cmp, v) { if (i < 0) { return i; } - if (cmp(arr[i], v)) { + if (Curry._2(cmp, arr[i], v)) { return i; } _i = i - 1 | 0; @@ -220,7 +221,7 @@ function find_with_index(arr, cmp, v) { if (i >= len) { return -1; } - if (cmp(arr[i], v)) { + if (Curry._2(cmp, arr[i], v)) { return i; } _i = i + 1 | 0; @@ -251,7 +252,7 @@ function exists(p, a) { if (i === n) { return false; } - if (p(a[i])) { + if (Curry._1(p, a[i])) { return true; } _i = i + 1 | 0; @@ -269,7 +270,7 @@ function unsafe_loop(_index, len, p, xs, ys) { if (index >= len) { return true; } - if (!p(xs[index], ys[index])) { + if (!Curry._2(p, xs[index], ys[index])) { return false; } _index = index + 1 | 0; diff --git a/jscomp/test/ext_bytes_test.js b/jscomp/test/ext_bytes_test.js index 9c496d4a89..c8de2ffa23 100644 --- a/jscomp/test/ext_bytes_test.js +++ b/jscomp/test/ext_bytes_test.js @@ -5,7 +5,7 @@ let Mt = require("./mt.js"); let Caml = require("../../lib/js/caml.js"); let Char = require("../../lib/js/char.js"); let Bytes = require("../../lib/js/bytes.js"); -let $$String = require("../../lib/js/string.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_bytes = require("../../lib/js/caml_bytes.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -136,7 +136,7 @@ function starts_with(xs, prefix, p) { } try { for(let i = 0; i < len2; ++i){ - if (!p(Caml_bytes.get(xs, i), Caml_bytes.get(prefix, i))) { + if (!Curry._2(p, Caml_bytes.get(xs, i), Caml_bytes.get(prefix, i))) { throw new Error(H, { cause: { RE_EXN_ID: H @@ -158,25 +158,21 @@ function starts_with(xs, prefix, p) { } } -let a = Bytes.init(100, (function (i) { - return Char.chr(i); -})); +let a = Bytes.init(100, Char.chr); Bytes.blit(a, 5, a, 10, 10); eq("File \"ext_bytes_test.res\", line 116, characters 4-11", a, Bytes.of_string("\x00\x01\x02\x03\x04\x05\x06\x07\b\t\x05\x06\x07\b\t\n\x0b\x0c\r\x0e\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abc")); -let a$1 = Bytes.init(100, (function (i) { - return Char.chr(i); -})); +let a$1 = Bytes.init(100, Char.chr); Bytes.blit(a$1, 10, a$1, 5, 10); eq("File \"ext_bytes_test.res\", line 128, characters 4-11", a$1, Bytes.of_string("\x00\x01\x02\x03\x04\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abc")); -let a$2 = $$String.init(100, (function (i) { - return Char.chr(i); -})); +let f = Char.chr; + +let a$2 = Bytes.unsafe_to_string(Bytes.init(100, f)); let b = Bytes.init(100, (function (i) { return /* '\000' */0; @@ -196,7 +192,7 @@ let s2 = Bytes.of_string(s1); eq("File \"ext_bytes_test.res\", line 153, characters 5-12", s, s2); -function f(a, b) { +function f$1(a, b) { return [ Caml_bytes.bytes_greaterthan(a, b), Caml_bytes.bytes_greaterequal(a, b), @@ -223,6 +219,6 @@ exports.test_id = test_id; exports.eq = eq; exports.escaped = escaped; exports.starts_with = starts_with; -exports.f = f; +exports.f = f$1; exports.f_0 = f_0; /* a Not a pure module */ diff --git a/jscomp/test/ext_filename_test.js b/jscomp/test/ext_filename_test.js index af53b2859e..7837155517 100644 --- a/jscomp/test/ext_filename_test.js +++ b/jscomp/test/ext_filename_test.js @@ -2,9 +2,10 @@ 'use strict'; let Sys = require("../../lib/js/sys.js"); -let Lazy = require("../../lib/js/lazy.js"); let List = require("../../lib/js/list.js"); -let $$String = require("../../lib/js/string.js"); +let $$Array = require("../../lib/js/array.js"); +let Bytes = require("../../lib/js/bytes.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_sys = require("../../lib/js/caml_sys.js"); let Filename = require("../../lib/js/filename.js"); let Pervasives = require("../../lib/js/pervasives.js"); @@ -19,7 +20,7 @@ let node_parent = ".."; let node_current = "."; -let cwd = Lazy.from_fun(function () { +let cwd = CamlinternalLazy.from_fun(function () { return Caml_sys.sys_getcwd(); }); @@ -32,18 +33,18 @@ function path_as_directory(x) { } function absolute_path(s) { - let s$1 = Filename.is_relative(s) ? Filename.concat(CamlinternalLazy.force(cwd), s) : s; + let s$1 = Curry._1(Filename.is_relative, s) ? Filename.concat(CamlinternalLazy.force(cwd), s) : s; let aux = function (_s) { while(true) { let s = _s; - let base = Filename.basename(s); - let dir = Filename.dirname(s); + let base = Curry._1(Filename.basename, s); + let dir = Curry._1(Filename.dirname, s); if (dir === s) { return dir; } if (base !== Filename.current_dir_name) { if (base === Filename.parent_dir_name) { - return Filename.dirname(aux(dir)); + return Curry._1(Filename.dirname, aux(dir)); } else { return Filename.concat(aux(dir), base); } @@ -63,10 +64,11 @@ function chop_extension(locOpt, name) { catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === "Invalid_argument") { + let s = "Filename.chop_extension ( " + loc + " : " + name + " )"; throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", - _1: "Filename.chop_extension ( " + loc + " : " + name + " )" + _1: s } }); } @@ -94,8 +96,8 @@ function chop_extension_if_any(fname) { let os_path_separator_char = Filename.dir_sep.codePointAt(0); function relative_path(file_or_dir_1, file_or_dir_2) { - let relevant_dir1 = file_or_dir_1.NAME === "File" ? Filename.dirname(file_or_dir_1.VAL) : file_or_dir_1.VAL; - let relevant_dir2 = file_or_dir_2.NAME === "File" ? Filename.dirname(file_or_dir_2.VAL) : file_or_dir_2.VAL; + let relevant_dir1 = file_or_dir_1.NAME === "File" ? Curry._1(Filename.dirname, file_or_dir_1.VAL) : file_or_dir_1.VAL; + let relevant_dir2 = file_or_dir_2.NAME === "File" ? Curry._1(Filename.dirname, file_or_dir_2.VAL) : file_or_dir_2.VAL; let dir1 = Ext_string_test.split(undefined, relevant_dir1, os_path_separator_char); let dir2 = Ext_string_test.split(undefined, relevant_dir2, os_path_separator_char); let go = function (_dir1, _dir2) { @@ -114,13 +116,13 @@ function relative_path(file_or_dir_1, file_or_dir_2) { }; let ys = go(dir1, dir2); if (ys && ys.hd === node_parent) { - return $$String.concat(node_sep, ys); + return $$Array.of_list(ys).join(node_sep); } - let __x = { + let xs = { hd: node_current, tl: ys }; - return $$String.concat(node_sep, __x); + return $$Array.of_list(xs).join(node_sep); } function node_relative_path(node_modules_shorten, file1, dep_file) { @@ -140,16 +142,17 @@ function node_relative_path(node_modules_shorten, file1, dep_file) { }) : ({ NAME: "Dir", VAL: absolute_path(file1.VAL) - })) + (node_sep + Filename.basename(file2)); + })) + (node_sep + Curry._1(Filename.basename, file2)); } let skip = function (_i) { while(true) { let i = _i; if (i >= len) { + let s = "invalid path: " + file2; throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", - _1: "invalid path: " + file2 + _1: s } }); } @@ -170,15 +173,16 @@ function find_root_filename(_cwd, filename) { if (Caml_sys.sys_file_exists(Filename.concat(cwd, filename))) { return cwd; } - let cwd$p = Filename.dirname(cwd); + let cwd$p = Curry._1(Filename.dirname, cwd); if (cwd$p.length < cwd.length) { _cwd = cwd$p; continue; } + let s = filename + " not found from " + cwd; throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", - _1: filename + " not found from " + cwd + _1: s } }); }; @@ -188,17 +192,19 @@ function find_package_json_dir(cwd) { return find_root_filename(cwd, Test_literals.bsconfig_json); } -let package_dir = Lazy.from_fun(function () { +let package_dir = CamlinternalLazy.from_fun(function () { let cwd$1 = CamlinternalLazy.force(cwd); return find_root_filename(cwd$1, Test_literals.bsconfig_json); }); function module_name_of_file(file) { - return $$String.capitalize_ascii(Filename.chop_extension(Filename.basename(file))); + let s = Filename.chop_extension(Curry._1(Filename.basename, file)); + return Bytes.unsafe_to_string(Bytes.capitalize_ascii(Bytes.unsafe_of_string(s))); } function module_name_of_file_if_any(file) { - return $$String.capitalize_ascii(chop_extension_if_any(Filename.basename(file))); + let s = chop_extension_if_any(Curry._1(Filename.basename, file)); + return Bytes.unsafe_to_string(Bytes.capitalize_ascii(Bytes.unsafe_of_string(s))); } function combine(p1, p2) { @@ -206,7 +212,7 @@ function combine(p1, p2) { return p2; } else if (p2 === "" || p2 === Filename.current_dir_name) { return p1; - } else if (Filename.is_relative(p2)) { + } else if (Curry._1(Filename.is_relative, p2)) { return Filename.concat(p1, p2); } else { return p2; @@ -219,14 +225,14 @@ function split_aux(p) { while(true) { let acc = _acc; let p$1 = _p; - let dir = Filename.dirname(p$1); + let dir = Curry._1(Filename.dirname, p$1); if (dir === p$1) { return [ dir, acc ]; } - let new_path = Filename.basename(p$1); + let new_path = Curry._1(Filename.basename, p$1); if (new_path === Filename.dir_sep) { _p = dir; continue; @@ -254,9 +260,7 @@ function rel_normalized_absolute_path(from, to_) { let xss = _xss; if (!xss) { if (yss) { - return List.fold_left((function (acc, x) { - return Filename.concat(acc, x); - }), yss.hd, yss.tl); + return List.fold_left(Filename.concat, yss.hd, yss.tl); } else { return Ext_string_test.empty; } @@ -275,9 +279,7 @@ function rel_normalized_absolute_path(from, to_) { let start = List.fold_left((function (acc, param) { return Filename.concat(acc, Ext_string_test.parent_dir_lit); }), Ext_string_test.parent_dir_lit, xs); - return List.fold_left((function (acc, v) { - return Filename.concat(acc, v); - }), start, yss); + return List.fold_left(Filename.concat, start, yss); }; } @@ -354,10 +356,11 @@ if (Sys.unix) { } else if (Sys.win32 || false) { simple_convert_node_path_to_os_path = Ext_string_test.replace_slash_backward; } else { + let s = "Unknown OS : " + Sys.os_type; throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", - _1: "Unknown OS : " + Sys.os_type + _1: s } }); } @@ -387,4 +390,4 @@ exports.rel_normalized_absolute_path = rel_normalized_absolute_path; exports.normalize_absolute_path = normalize_absolute_path; exports.get_extension = get_extension; exports.simple_convert_node_path_to_os_path = simple_convert_node_path_to_os_path; -/* cwd Not a pure module */ +/* simple_convert_node_path_to_os_path Not a pure module */ diff --git a/jscomp/test/ext_list_test.js b/jscomp/test/ext_list_test.js index d2870ed0bd..ea80d22098 100644 --- a/jscomp/test/ext_list_test.js +++ b/jscomp/test/ext_list_test.js @@ -3,6 +3,7 @@ let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); let Ext_string_test = require("./ext_string_test.js"); @@ -13,7 +14,7 @@ function filter_map(f, _xs) { return /* [] */0; } let ys = xs.tl; - let z = f(xs.hd); + let z = Curry._1(f, xs.hd); if (z !== undefined) { return { hd: Caml_option.valFromOption(z), @@ -38,7 +39,7 @@ function excludes(p, l) { } let l = x.tl; let x$1 = x.hd; - if (p(x$1)) { + if (Curry._1(p, x$1)) { excluded.contents = true; _x = l; continue; @@ -78,7 +79,7 @@ function exclude_with_fact(p, l) { } let l = x.tl; let x$1 = x.hd; - if (p(x$1)) { + if (Curry._1(p, x$1)) { excluded.contents = Caml_option.some(x$1); _x = l; continue; @@ -114,12 +115,12 @@ function exclude_with_fact2(p1, p2, l) { } let l = x.tl; let x$1 = x.hd; - if (p1(x$1)) { + if (Curry._1(p1, x$1)) { excluded1.contents = Caml_option.some(x$1); _x = l; continue; } - if (p2(x$1)) { + if (Curry._1(p2, x$1)) { excluded2.contents = Caml_option.some(x$1); _x = l; continue; @@ -169,7 +170,7 @@ function filter_mapi(f, xs) { return /* [] */0; } let ys = xs.tl; - let z = f(i, xs.hd); + let z = Curry._2(f, i, xs.hd); if (z !== undefined) { return { hd: Caml_option.valFromOption(z), @@ -192,7 +193,7 @@ function filter_map2(f, _xs, _ys) { if (ys) { let vs = ys.tl; let us = xs.tl; - let z = f(xs.hd, ys.hd); + let z = Curry._2(f, xs.hd, ys.hd); if (z !== undefined) { return { hd: Caml_option.valFromOption(z), @@ -232,7 +233,7 @@ function filter_map2i(f, xs, ys) { if (ys) { let vs = ys.tl; let us = xs.tl; - let z = f(i, xs.hd, ys.hd); + let z = Curry._3(f, i, xs.hd, ys.hd); if (z !== undefined) { return { hd: Caml_option.valFromOption(z), @@ -273,7 +274,7 @@ function rev_map_append(f, _l1, _l2) { return l2; } _l2 = { - hd: f(l1.hd), + hd: Curry._1(f, l1.hd), tl: l2 }; _l1 = l1.tl; @@ -293,7 +294,7 @@ function flat_map2(f, lx, ly) { if (ly$1) { _ly = ly$1.tl; _lx = lx$1.tl; - _acc = List.rev_append(f(lx$1.hd, ly$1.hd), acc); + _acc = List.rev_append(Curry._2(f, lx$1.hd, ly$1.hd), acc); continue; } throw new Error("Invalid_argument", { @@ -303,15 +304,15 @@ function flat_map2(f, lx, ly) { } }); } - if (!ly$1) { - return List.rev(acc); + if (ly$1) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.flat_map2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.flat_map2" - } - }); + return List.rev(acc); }; } @@ -323,7 +324,7 @@ function flat_map_aux(f, _acc, append, _lx) { return List.rev_append(acc, append); } _lx = lx.tl; - _acc = List.rev_append(f(lx.hd), acc); + _acc = List.rev_append(Curry._1(f, lx.hd), acc); continue; }; } @@ -344,7 +345,7 @@ function map2_last(f, l1, l2) { if (l2) { if (!l2.tl) { return { - hd: f(true, u, l2.hd), + hd: Curry._3(f, true, u, l2.hd), tl: /* [] */0 }; } @@ -359,7 +360,7 @@ function map2_last(f, l1, l2) { } } if (l2) { - let r = f(false, u, l2.hd); + let r = Curry._3(f, false, u, l2.hd); return { hd: r, tl: map2_last(f, l1$1, l2.tl) @@ -391,11 +392,11 @@ function map_last(f, l1) { let u = l1.hd; if (!l1$1) { return { - hd: f(true, u), + hd: Curry._2(f, true, u), tl: /* [] */0 }; } - let r = f(false, u); + let r = Curry._2(f, false, u); return { hd: r, tl: map_last(f, l1$1) @@ -409,7 +410,7 @@ function fold_right2_last(f, l1, l2, accu) { if (!l1$1) { if (l2) { if (!l2.tl) { - return f(true, last1, l2.hd, accu); + return Curry._4(f, true, last1, l2.hd, accu); } } else { @@ -422,7 +423,7 @@ function fold_right2_last(f, l1, l2, accu) { } } if (l2) { - return f(false, last1, l2.hd, fold_right2_last(f, l1$1, l2.tl, accu)); + return Curry._4(f, false, last1, l2.hd, fold_right2_last(f, l1$1, l2.tl, accu)); } throw new Error("Invalid_argument", { cause: { @@ -431,15 +432,15 @@ function fold_right2_last(f, l1, l2, accu) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2" - } - }); + return accu; } function init(n, f) { @@ -449,18 +450,18 @@ function init(n, f) { function take(n, l) { let arr = $$Array.of_list(l); let arr_length = arr.length; - if (arr_length >= n) { - return [ - $$Array.to_list($$Array.sub(arr, 0, n)), - $$Array.to_list($$Array.sub(arr, n, arr_length - n | 0)) - ]; + if (arr_length < n) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.take" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.take" - } - }); + return [ + $$Array.to_list($$Array.sub(arr, 0, n)), + $$Array.to_list($$Array.sub(arr, n, arr_length - n | 0)) + ]; } function try_take(n, l) { @@ -568,7 +569,7 @@ function aux(cmp, x, xss) { } let ys = xss.tl; let y = xss.hd; - if (cmp(x, List.hd(y))) { + if (Curry._2(cmp, x, List.hd(y))) { return { hd: { hd: x, @@ -624,7 +625,7 @@ function find_first_not(p, _x) { return; } let a = x.hd; - if (!p(a)) { + if (!Curry._1(p, a)) { return Caml_option.some(a); } _x = x.tl; @@ -638,7 +639,7 @@ function for_all_opt(p, _x) { if (!x) { return; } - let v = p(x.hd); + let v = Curry._1(p, x.hd); if (v !== undefined) { return v; } @@ -649,7 +650,7 @@ function for_all_opt(p, _x) { function fold(f, l, init) { return List.fold_left((function (acc, i) { - return f(i, init); + return Curry._2(f, i, init); }), init, l); } @@ -664,7 +665,7 @@ function rev_map_acc(acc, f, l) { } _x = x.tl; _accu = { - hd: f(x.hd), + hd: Curry._1(f, x.hd), tl: accu }; continue; @@ -674,7 +675,7 @@ function rev_map_acc(acc, f, l) { function map_acc(acc, f, l) { if (l) { return { - hd: f(l.hd), + hd: Curry._1(f, l.hd), tl: map_acc(acc, f, l.tl) }; } else { @@ -685,7 +686,7 @@ function map_acc(acc, f, l) { function rev_iter(f, xs) { if (xs) { rev_iter(f, xs.tl); - return f(xs.hd); + return Curry._1(f, xs.hd); } } @@ -704,7 +705,7 @@ function for_all2_no_exn(p, _l1, _l2) { if (!l2) { return false; } - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -720,7 +721,7 @@ function find_no_exn(p, _x) { return; } let x$1 = x.hd; - if (p(x$1)) { + if (Curry._1(p, x$1)) { return Caml_option.some(x$1); } _x = x.tl; @@ -734,7 +735,7 @@ function find_opt(p, _x) { if (!x) { return; } - let v = p(x.hd); + let v = Curry._1(p, x.hd); if (v !== undefined) { return v; } @@ -757,7 +758,7 @@ function split_map(f, xs) { List.rev(cs) ]; } - let match = f(xs$1.hd); + let match = Curry._1(f, xs$1.hd); _xs = xs$1.tl; _cs = { hd: match[1], @@ -775,7 +776,7 @@ function reduce_from_right(fn, lst) { let match = List.rev(lst); if (match) { return List.fold_left((function (x, y) { - return fn(y, x); + return Curry._2(fn, y, x); }), match.hd, match.tl); } throw new Error("Invalid_argument", { diff --git a/jscomp/test/ext_pervasives_test.js b/jscomp/test/ext_pervasives_test.js index 87cf58893c..e2da1da2c2 100644 --- a/jscomp/test/ext_pervasives_test.js +++ b/jscomp/test/ext_pervasives_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_string = require("../../lib/js/caml_string.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -8,15 +9,15 @@ let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); function $$finally(v, action, f) { let e; try { - e = f(v); + e = Curry._1(f, v); } catch (e$1){ - action(v); + Curry._1(action, v); throw new Error(e$1.RE_EXN_ID, { cause: e$1 }); } - action(v); + Curry._1(action, v); return e; } diff --git a/jscomp/test/ext_string_test.js b/jscomp/test/ext_string_test.js index 53b4cc582a..45c8749f01 100644 --- a/jscomp/test/ext_string_test.js +++ b/jscomp/test/ext_string_test.js @@ -3,6 +3,7 @@ let List = require("../../lib/js/list.js"); let Bytes = require("../../lib/js/bytes.js"); +let Curry = require("../../lib/js/curry.js"); let $$String = require("../../lib/js/string.js"); let Caml_bytes = require("../../lib/js/caml_bytes.js"); let Caml_string = require("../../lib/js/caml_string.js"); @@ -30,7 +31,7 @@ function split_by(keep_emptyOpt, is_delim, str) { }; } } - if (is_delim(Caml_string.get(str, pos))) { + if (Curry._1(is_delim, Caml_string.get(str, pos))) { let new_len = (last_pos - pos | 0) - 1 | 0; if (new_len !== 0 || keep_empty) { let v = $$String.sub(str, pos + 1 | 0, new_len); @@ -206,7 +207,7 @@ function unsafe_for_all_range(s, _start, finish, p) { if (start > finish) { return true; } - if (!p(s.codePointAt(start))) { + if (!Curry._1(p, s.codePointAt(start))) { return false; } _start = start + 1 | 0; @@ -216,15 +217,15 @@ function unsafe_for_all_range(s, _start, finish, p) { function for_all_range(s, start, finish, p) { let len = s.length; - if (!(start < 0 || finish >= len)) { - return unsafe_for_all_range(s, start, finish, p); + if (start < 0 || finish >= len) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_string_test.for_all_range" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_string_test.for_all_range" - } - }); + return unsafe_for_all_range(s, start, finish, p); } function for_all(p, s) { @@ -300,27 +301,27 @@ function contain_substring(s, sub) { function non_overlap_count(sub, s) { let sub_len = sub.length; - if (sub.length !== 0) { - let _acc = 0; - let _off = 0; - while(true) { - let off = _off; - let acc = _acc; - let i = find(off, sub, s); - if (i < 0) { - return acc; - } - _off = i + sub_len | 0; - _acc = acc + 1 | 0; - continue; - }; + if (sub.length === 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_string_test.non_overlap_count" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_string_test.non_overlap_count" - } - }); + let _acc = 0; + let _off = 0; + while(true) { + let off = _off; + let acc = _acc; + let i = find(off, sub, s); + if (i < 0) { + return acc; + } + _off = i + sub_len | 0; + _acc = acc + 1 | 0; + continue; + }; } function rfind(sub, s) { @@ -553,15 +554,15 @@ function unsafe_no_char_idx(x, ch, _i, last_idx) { function no_char(x, ch, i, len) { let str_len = x.length; - if (!(i < 0 || i >= str_len || len >= str_len)) { - return unsafe_no_char(x, ch, i, len); + if (i < 0 || i >= str_len || len >= str_len) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Ext_string_test.no_char" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Ext_string_test.no_char" - } - }); + return unsafe_no_char(x, ch, i, len); } function no_slash(x) { diff --git a/jscomp/test/ffi_arity_test.js b/jscomp/test/ffi_arity_test.js index 71cf9a5704..6bd8dc9f7c 100644 --- a/jscomp/test/ffi_arity_test.js +++ b/jscomp/test/ffi_arity_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); function f(v) { if (v % 2 === 0) { @@ -20,7 +21,7 @@ let v = [ 2, 3 ].map(function (a, b) { - return f(a)(b); + return Curry._1(f(a), b); }); let vv = [ @@ -63,9 +64,7 @@ function abc(x, y, z) { return (x + y | 0) + z | 0; } -function abc_u(x, y, z) { - return abc(x, y, z); -} +let abc_u = abc; fff(); @@ -120,10 +119,10 @@ Mt.from_pair_suites("Ffi_arity_test", { }); function bar(fn) { - return fn(); + return Curry._1(fn, undefined); } -((function(){console.log("forgiving arity")})()); +(Curry._1((function(){console.log("forgiving arity")}), undefined)); exports.f = f; exports.v = v; diff --git a/jscomp/test/ffi_js_test.js b/jscomp/test/ffi_js_test.js index b97a7f580d..0f0e5300f5 100644 --- a/jscomp/test/ffi_js_test.js +++ b/jscomp/test/ffi_js_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let keys = (function (x){return Object.keys(x)}); @@ -51,7 +52,7 @@ let string_config = { eq("File \"ffi_js_test.res\", line 30, characters 12-19", [ 6, - $$higher_order(1)(2, 3) + Curry._2($$higher_order(1), 2, 3) ]); let same_type_0 = { diff --git a/jscomp/test/flexible_array_test.js b/jscomp/test/flexible_array_test.js index c2d2426b27..38dbe985db 100644 --- a/jscomp/test/flexible_array_test.js +++ b/jscomp/test/flexible_array_test.js @@ -2,6 +2,7 @@ 'use strict'; let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_array = require("../../lib/js/caml_array.js"); @@ -244,7 +245,7 @@ function filter_from(i, p, s) { let u = empty; for(let i$1 = i ,i_finish = length(s); i$1 < i_finish; ++i$1){ let ele = get(s, i$1); - if (p(ele)) { + if (Curry._1(p, ele)) { u = push_back(u, ele); } diff --git a/jscomp/test/for_loop_test.js b/jscomp/test/for_loop_test.js index 03b984a4c1..76fad4f6f0 100644 --- a/jscomp/test/for_loop_test.js +++ b/jscomp/test/for_loop_test.js @@ -3,6 +3,7 @@ let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); function for_3(x) { @@ -21,7 +22,7 @@ function for_3(x) { })); } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return v.contents; } @@ -43,7 +44,7 @@ function for_4(x) { })); } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return v.contents; } @@ -64,7 +65,7 @@ function for_5(x, u) { })); } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return v.contents; } @@ -102,7 +103,7 @@ function for_6(x, u) { inspect_3 = v2.contents; } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return [ v.contents, @@ -127,7 +128,7 @@ function for_7() { } } $$Array.iter((function (f) { - f(); + Curry._1(f, undefined); }), arr); return v.contents; } @@ -149,7 +150,7 @@ function for_8() { } } $$Array.iter((function (f) { - f(); + Curry._1(f, undefined); }), arr); return v.contents; } @@ -164,9 +165,6 @@ function for_9() { tl: v.contents }; }; - let get = function () { - return $$Array.of_list(List.rev(v.contents)); - }; let vv = { contents: 0 }; @@ -196,14 +194,14 @@ function for_9() { })); } $$Array.iter((function (f) { - f(); + Curry._1(f, undefined); }), arr); $$Array.iter((function (f) { - f(); + Curry._1(f, undefined); }), arr2); return [[ vv.contents, - get(), + $$Array.of_list(List.rev(v.contents)), vv2.contents ]]; } diff --git a/jscomp/test/format_test.js b/jscomp/test/format_test.js index 9c7de3c192..e7dbc96ed5 100644 --- a/jscomp/test/format_test.js +++ b/jscomp/test/format_test.js @@ -3,7 +3,7 @@ let Mt = require("./mt.js"); let List = require("../../lib/js/list.js"); -let $$String = require("../../lib/js/string.js"); +let Bytes = require("../../lib/js/bytes.js"); let Pervasives = require("../../lib/js/pervasives.js"); let Caml_format = require("../../lib/js/caml_format.js"); @@ -174,7 +174,9 @@ let literals = { aux_list("File \"format_test.res\", line 72, characters 18-25", literals); -eq("File \"format_test.res\", line 74, characters 12-19", $$String.uppercase_ascii(Caml_format.hexstring_of_float(7.875, -1, /* '-' */45)), "0X1.F8P+2"); +let s = Caml_format.hexstring_of_float(7.875, -1, /* '-' */45); + +eq("File \"format_test.res\", line 74, characters 12-19", Bytes.unsafe_to_string(Bytes.uppercase_ascii(Bytes.unsafe_of_string(s))), "0X1.F8P+2"); function scan_float(loc, s, expect) { eq(loc, Caml_format.float_of_string(s), expect); diff --git a/jscomp/test/fun_pattern_match.js b/jscomp/test/fun_pattern_match.js index a7f1adbd17..4d4068f335 100644 --- a/jscomp/test/fun_pattern_match.js +++ b/jscomp/test/fun_pattern_match.js @@ -2,6 +2,7 @@ 'use strict'; let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); function f(param, v) { return ((((param.x0 + param.x1 | 0) + param.x2 | 0) + param.x3 | 0) + param.x4 | 0) + v | 0; @@ -68,7 +69,7 @@ function r() { let match = r(); -let v = match.VAL(); +let v = Curry._1(match.VAL, undefined); console.log(v); diff --git a/jscomp/test/functor_app_test.js b/jscomp/test/functor_app_test.js index 53402b6e29..04dc323448 100644 --- a/jscomp/test/functor_app_test.js +++ b/jscomp/test/functor_app_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Functor_def = require("./functor_def.js"); let Functor_inst = require("./functor_inst.js"); @@ -34,9 +35,9 @@ let Y0 = Functor_def.Make(Functor_inst); let Y1 = Functor_def.Make(Functor_inst); -eq("File \"functor_app_test.res\", line 15, characters 3-10", Y0.h(1, 2), 4); +eq("File \"functor_app_test.res\", line 15, characters 3-10", Curry._2(Y0.h, 1, 2), 4); -eq("File \"functor_app_test.res\", line 16, characters 3-10", Y1.h(2, 3), 6); +eq("File \"functor_app_test.res\", line 16, characters 3-10", Curry._2(Y1.h, 2, 3), 6); let v = Functor_def.$$return(); diff --git a/jscomp/test/functor_def.js b/jscomp/test/functor_def.js index 8c1046548d..000a6fc513 100644 --- a/jscomp/test/functor_def.js +++ b/jscomp/test/functor_def.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let v = { contents: 0 @@ -18,7 +19,7 @@ function $$return() { function Make(U) { let h = function (x, x$1) { console.log(f(x$1, x$1)); - return U.say(x$1, x$1); + return Curry._2(U.say, x$1, x$1); }; return { h: h diff --git a/jscomp/test/functors.js b/jscomp/test/functors.js index 7af4f0d308..d0b513a63c 100644 --- a/jscomp/test/functors.js +++ b/jscomp/test/functors.js @@ -1,13 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function O(X) { let cow = function (x) { - return X.foo(x); + return Curry._1(X.foo, x); }; let sheep = function (x) { - return 1 + X.foo(x) | 0; + return 1 + Curry._1(X.foo, x) | 0; }; return { cow: cow, @@ -17,10 +18,10 @@ function O(X) { function F(X, Y) { let cow = function (x) { - return Y.foo(X.foo(x)); + return Curry._1(Y.foo, Curry._1(X.foo, x)); }; let sheep = function (x) { - return 1 + cow(x) | 0; + return 1 + Curry._1(Y.foo, Curry._1(X.foo, x)) | 0; }; return { cow: cow, @@ -29,11 +30,8 @@ function F(X, Y) { } function F1(X, Y) { - let cow = function (x) { - return Y.foo(X.foo(x)); - }; let sheep = function (x) { - return 1 + cow(x) | 0; + return 1 + Curry._1(Y.foo, Curry._1(X.foo, x)) | 0; }; return { sheep: sheep @@ -41,11 +39,8 @@ function F1(X, Y) { } function F2(X, Y) { - let cow = function (x) { - return Y.foo(X.foo(x)); - }; let sheep = function (x) { - return 1 + cow(x) | 0; + return 1 + Curry._1(Y.foo, Curry._1(X.foo, x)) | 0; }; return { sheep: sheep @@ -54,11 +49,8 @@ function F2(X, Y) { let M = { F: (function (funarg, funarg$1) { - let cow = function (x) { - return funarg$1.foo(funarg.foo(x)); - }; let sheep = function (x) { - return 1 + cow(x) | 0; + return 1 + Curry._1(funarg$1.foo, Curry._1(funarg.foo, x)) | 0; }; return { sheep: sheep diff --git a/jscomp/test/global_module_alias_test.js b/jscomp/test/global_module_alias_test.js index 99890d07ea..4621458071 100644 --- a/jscomp/test/global_module_alias_test.js +++ b/jscomp/test/global_module_alias_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -113,7 +114,7 @@ eq("File \"global_module_alias_test.res\", line 80, characters 12-19", g(), 4); let V = xx(); -eq("File \"global_module_alias_test.res\", line 84, characters 5-12", V.length({ +eq("File \"global_module_alias_test.res\", line 84, characters 5-12", Curry._1(V.length, { hd: 1, tl: { hd: 2, @@ -128,7 +129,7 @@ eq("File \"global_module_alias_test.res\", line 85, characters 5-12", v.contents let H$1 = f(); -eq("File \"global_module_alias_test.res\", line 87, characters 5-12", H$1.length({ +eq("File \"global_module_alias_test.res\", line 87, characters 5-12", Curry._1(H$1.length, { hd: 1, tl: { hd: 2, diff --git a/jscomp/test/gpr496_test.js b/jscomp/test/gpr496_test.js index 89eb671d8d..43385d80b2 100644 --- a/jscomp/test/gpr496_test.js +++ b/jscomp/test/gpr496_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -67,7 +68,7 @@ eq("File \"gpr496_test.res\", line 32, characters 12-19", expected, u); eq("File \"gpr496_test.res\", line 34, characters 12-19", expected, expected2); function ff(x, y) { - return Caml.bool_min(x, y()); + return Caml.bool_min(x, Curry._1(y, undefined)); } eq("File \"gpr496_test.res\", line 37, characters 12-19", true < false ? true : false, false); diff --git a/jscomp/test/gpr_1154_test.js b/jscomp/test/gpr_1154_test.js index 96e585681a..b951f6fc97 100644 --- a/jscomp/test/gpr_1154_test.js +++ b/jscomp/test/gpr_1154_test.js @@ -52,7 +52,7 @@ function g2(x) { return Caml_int64.or_(x, (v.contents = v.contents + 1 | 0, x)); } -let a = g2(Int64.one); +let a = Caml_int64.or_(Int64.one, (v.contents = v.contents + 1 | 0, Int64.one)); eq("File \"gpr_1154_test.res\", line 28, characters 12-19", v.contents, 1); diff --git a/jscomp/test/gpr_1245_test.js b/jscomp/test/gpr_1245_test.js index 3ad00c8c05..2219bc5c2c 100644 --- a/jscomp/test/gpr_1245_test.js +++ b/jscomp/test/gpr_1245_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -27,7 +28,7 @@ function g() { } function a0(f) { - let u = f(); + let u = Curry._1(f, undefined); if (u !== null) { console.log(u); console.log(u); @@ -40,7 +41,7 @@ function a0(f) { function a1(f) { let E = /* @__PURE__ */Caml_exceptions.create("E"); try { - return f(); + return Curry._1(f, undefined); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); diff --git a/jscomp/test/gpr_1268.js b/jscomp/test/gpr_1268.js index ffc1dafced..883fd90291 100644 --- a/jscomp/test/gpr_1268.js +++ b/jscomp/test/gpr_1268.js @@ -1,17 +1,18 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f_add2(a, b, x, y) { - return add(b(y), a(x)); + return add(Curry._1(b, y), Curry._1(a, x)); } function f(a, b, x, y) { - return a(x) + b(y) | 0; + return Curry._1(a, x) + Curry._1(b, y) | 0; } function f1(a, b, x, y) { - return add(a(x), b(y)); + return add(Curry._1(a, x), Curry._1(b, y)); } function f2(x) { diff --git a/jscomp/test/gpr_1409_test.js b/jscomp/test/gpr_1409_test.js index ec0b717f46..a615c1147a 100644 --- a/jscomp/test/gpr_1409_test.js +++ b/jscomp/test/gpr_1409_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let String_set = require("./string_set.js"); let Caml_option = require("../../lib/js/caml_option.js"); @@ -39,7 +40,7 @@ let b = { function map(f, x) { if (x !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(x))); + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(x))); } } @@ -101,11 +102,11 @@ function test5(f, x) { let tmp = { hi: 2 }; - let tmp$1 = f(x); + let tmp$1 = Curry._1(f, x); if (tmp$1 !== undefined) { tmp._open = tmp$1; } - let tmp$2 = f(x); + let tmp$2 = Curry._1(f, x); if (tmp$2 !== undefined) { tmp.xx__hi = tmp$2; } @@ -124,7 +125,7 @@ function test6(f, x) { if (tmp$1 !== undefined) { tmp._open = tmp$1; } - let tmp$2 = f(x$1); + let tmp$2 = Curry._1(f, x$1); if (tmp$2 !== undefined) { tmp.xx__hi = tmp$2; } diff --git a/jscomp/test/gpr_1423_app_test.js b/jscomp/test/gpr_1423_app_test.js index fee9718e51..0e89c61761 100644 --- a/jscomp/test/gpr_1423_app_test.js +++ b/jscomp/test/gpr_1423_app_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -29,7 +30,7 @@ function eq(loc, x, y) { } function foo(f) { - console.log(f("a1", undefined)); + console.log(Curry._2(f, "a1", undefined)); } foo(function (none, extra) { @@ -37,12 +38,10 @@ foo(function (none, extra) { }); function foo2(f) { - return f("a1", undefined); + return Curry._2(f, "a1", undefined); } -eq("File \"gpr_1423_app_test.res\", line 15, characters 12-19", (function (none, extra) { - return none + "a2"; -})("a1", undefined), "a1a2"); +eq("File \"gpr_1423_app_test.res\", line 15, characters 12-19", "a1a2", "a1a2"); Mt.from_pair_suites("Gpr_1423_app_test", suites.contents); diff --git a/jscomp/test/gpr_1667_test.js b/jscomp/test/gpr_1667_test.js index 75efb35a82..a1f9c44493 100644 --- a/jscomp/test/gpr_1667_test.js +++ b/jscomp/test/gpr_1667_test.js @@ -28,10 +28,6 @@ function eq(loc, x, y) { }; } -(function (z) { - return 0; -})(false) === 0; - eq("File \"gpr_1667_test.res\", line 24, characters 5-12", 0, 0); Mt.from_pair_suites("Gpr_1667_test", suites.contents); diff --git a/jscomp/test/gpr_1692_test.js b/jscomp/test/gpr_1692_test.js index ba792ec3b4..6b9bc38ad1 100644 --- a/jscomp/test/gpr_1692_test.js +++ b/jscomp/test/gpr_1692_test.js @@ -1,11 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); -(function (x) { - return function (f) { +(Curry._1((function (f) { return 0; - }; -})("")(""); + }), "")); /* Not a pure module */ diff --git a/jscomp/test/gpr_1891_test.js b/jscomp/test/gpr_1891_test.js index 0be949d234..2237c480ad 100644 --- a/jscomp/test/gpr_1891_test.js +++ b/jscomp/test/gpr_1891_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function foo(x) { if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { @@ -28,7 +29,7 @@ function foo3(x) { function foo4(x, h) { if (typeof x === "object" && x.NAME === "Foo" && x.VAL === 3) { - return h(); + return Curry._1(h, undefined); } } diff --git a/jscomp/test/gpr_2352_test.js b/jscomp/test/gpr_2352_test.js index 887a6902cf..c82a40c8ae 100644 --- a/jscomp/test/gpr_2352_test.js +++ b/jscomp/test/gpr_2352_test.js @@ -1,9 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f(x) { - x.hey = 22; + Curry._1(x.hey, 22); } exports.f = f; diff --git a/jscomp/test/gpr_2633_test.js b/jscomp/test/gpr_2633_test.js index 43ff22b9d0..ac7f5d007c 100644 --- a/jscomp/test/gpr_2633_test.js +++ b/jscomp/test/gpr_2633_test.js @@ -1,13 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function on1(foo, event) { foo.on(event.NAME, event.VAL); } function on2(foo, h, event) { - foo.on(h(event).NAME, h(event).VAL); + foo.on(Curry._1(h, event).NAME, Curry._1(h, event).VAL); } exports.on1 = on1; diff --git a/jscomp/test/gpr_2682_test.js b/jscomp/test/gpr_2682_test.js index c7fceff492..0a3b2bd26d 100644 --- a/jscomp/test/gpr_2682_test.js +++ b/jscomp/test/gpr_2682_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let sum = ((a,b) => a + b); @@ -43,7 +44,7 @@ forIn({ let f3 = (()=>true); -let bbbb = f3(); +let bbbb = Curry._1(f3, undefined); if (!bbbb) { throw new Error("Assert_failure", { diff --git a/jscomp/test/gpr_3536_test.js b/jscomp/test/gpr_3536_test.js index e07b0156a2..51f486cf3f 100644 --- a/jscomp/test/gpr_3536_test.js +++ b/jscomp/test/gpr_3536_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -18,7 +19,7 @@ function eq(loc, x, y) { let X = {}; function xx(obj, a0, a1, a2, a3, a4, a5) { - return (a4(a2(a0(obj, a1), a3), a5) - 1 | 0) - 3 | 0; + return (Curry._2(a4, Curry._2(a2, Curry._2(a0, obj, a1), a3), a5) - 1 | 0) - 3 | 0; } eq("File \"gpr_3536_test.res\", line 18, characters 12-19", 5, 5); diff --git a/jscomp/test/gpr_3566_test.js b/jscomp/test/gpr_3566_test.js index 5604508e53..6bcf903005 100644 --- a/jscomp/test/gpr_3566_test.js +++ b/jscomp/test/gpr_3566_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_option = require("../../lib/js/caml_option.js"); @@ -104,24 +105,24 @@ function Test7($star) { } function Test8($star) { - let Curry = {}; + let Curry$1 = {}; let f = function (x) { - return x(1); + return Curry._1(x, 1); }; return { - Curry: Curry, + Curry: Curry$1, f: f }; } function Test9($star) { let f = function (x) { - return x(1); + return Curry._1(x, 1); }; - let Curry = {}; + let Curry$1 = {}; return { f: f, - Curry: Curry + Curry: Curry$1 }; } diff --git a/jscomp/test/gpr_3697_test.js b/jscomp/test/gpr_3697_test.js index 1d38845ec9..884b7b1a50 100644 --- a/jscomp/test/gpr_3697_test.js +++ b/jscomp/test/gpr_3697_test.js @@ -1,13 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Lazy = require("../../lib/js/lazy.js"); let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); function fix() { return { TAG: "Fix", - _0: Lazy.from_fun(fix) + _0: CamlinternalLazy.from_fun(function () { + return fix(); + }) }; } diff --git a/jscomp/test/gpr_3875_test.js b/jscomp/test/gpr_3875_test.js index abb933adc3..f3a5efdbdf 100644 --- a/jscomp/test/gpr_3875_test.js +++ b/jscomp/test/gpr_3875_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let result = { contents: "" @@ -17,32 +18,33 @@ let Xx = { function compilerBug(a, b, c, f) { let exit = 0; - let exit$1 = 0; - if (a === "x") { + if (a !== "x") { exit = 2; - } else { - exit$1 = 3; - } - if (exit$1 === 3) { - exit = b === "x" ? 2 : 1; } - switch (exit) { - case 1 : - if (c) { - result.contents = "No x, c is true"; - } else { - result.contents = "No x, c is false"; - } - return; - case 2 : - if (f()) { - result.contents = "Some x, f returns true"; - } else { - result.contents = "Some x, f returns false"; - } - return; + if (exit === 2) { + if (b === undefined) { + if (c) { + result.contents = "No x, c is true"; + } else { + result.contents = "No x, c is false"; + } + return; + } + if (b !== "x") { + if (c) { + result.contents = "No x, c is true"; + } else { + result.contents = "No x, c is false"; + } + return; + } } + if (Curry._1(f, undefined)) { + result.contents = "Some x, f returns true"; + } else { + result.contents = "Some x, f returns false"; + } } let suites = { diff --git a/jscomp/test/gpr_3931_test.js b/jscomp/test/gpr_3931_test.js index cba2beac9b..7c6e386b5f 100644 --- a/jscomp/test/gpr_3931_test.js +++ b/jscomp/test/gpr_3931_test.js @@ -2,6 +2,7 @@ 'use strict'; let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_module = require("../../lib/js/caml_module.js"); let PA = Caml_module.init_mod([ @@ -56,7 +57,7 @@ Caml_module.update_mod({ print: print$1 }); -PA.print([ +Curry._1(PA.print, [ 1, 2 ]); diff --git a/jscomp/test/gpr_405_test.js b/jscomp/test/gpr_405_test.js index a27fad4498..072699a11f 100644 --- a/jscomp/test/gpr_405_test.js +++ b/jscomp/test/gpr_405_test.js @@ -2,6 +2,7 @@ 'use strict'; let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); let Hashtbl = require("../../lib/js/hashtbl.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -13,7 +14,7 @@ function Make(funarg) { }); let find_default = function (htbl, x) { try { - return H.find(htbl, x); + return Curry._2(H.find, htbl, x); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -26,10 +27,10 @@ function Make(funarg) { } }; let min_cutset = function (gr, first_node) { - let n_labels = H.create(97); - let l_labels = H.create(97); - let already_processed = H.create(97); - let on_the_stack = H.create(97); + let n_labels = Curry._1(H.create, 97); + let l_labels = Curry._1(H.create, 97); + let already_processed = Curry._1(H.create, 97); + let on_the_stack = Curry._1(H.create, 97); let cut_set = { contents: /* [] */0 }; @@ -61,12 +62,12 @@ function Make(funarg) { } }); } - H.add(on_the_stack, top, true); - H.add(n_labels, top, counter.contents); + Curry._3(H.add, on_the_stack, top, true); + Curry._3(H.add, n_labels, top, counter.contents); counter.contents = counter.contents + 1 | 0; - H.add(l_labels, top, 0); - H.add(already_processed, top, true); - let _successors = funarg.succ(gr, top); + Curry._3(H.add, l_labels, top, 0); + Curry._3(H.add, already_processed, top, true); + let _successors = Curry._2(funarg.succ, gr, top); let _top = top; let _rest_of_stack = rest_of_stack; while(true) { @@ -84,19 +85,19 @@ function Make(funarg) { tl: rest_of_stack$1 }); } - let x = find_default(on_the_stack, successor) ? H.find(n_labels, successor) : H.find(l_labels, successor); - H.add(l_labels, top$1, Caml.int_max(H.find(l_labels, top$1), x)); + let x = find_default(on_the_stack, successor) ? Curry._2(H.find, n_labels, successor) : Curry._2(H.find, l_labels, successor); + Curry._3(H.add, l_labels, top$1, Caml.int_max(Curry._2(H.find, l_labels, top$1), x)); _successors = successors.tl; continue; } - if (H.find(l_labels, top$1) === H.find(n_labels, top$1)) { + if (Curry._2(H.find, l_labels, top$1) === Curry._2(H.find, n_labels, top$1)) { cut_set.contents = { hd: top$1, tl: cut_set.contents }; - H.add(l_labels, top$1, 0); + Curry._3(H.add, l_labels, top$1, 0); } - if (H.find(l_labels, top$1) > H.find(n_labels, top$1)) { + if (Curry._2(H.find, l_labels, top$1) > Curry._2(H.find, n_labels, top$1)) { throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", @@ -109,8 +110,8 @@ function Make(funarg) { } let match = rest_of_stack$1.hd; let new_top = match[0]; - H.add(on_the_stack, top$1, false); - H.add(l_labels, new_top, Caml.int_max(H.find(l_labels, top$1), H.find(l_labels, new_top))); + Curry._3(H.add, on_the_stack, top$1, false); + Curry._3(H.add, l_labels, new_top, Caml.int_max(Curry._2(H.find, l_labels, top$1), Curry._2(H.find, l_labels, new_top))); _rest_of_stack = rest_of_stack$1.tl; _top = new_top; _successors = match[1]; @@ -125,4 +126,4 @@ function Make(funarg) { } exports.Make = Make; -/* Hashtbl Not a pure module */ +/* No side effect */ diff --git a/jscomp/test/gpr_4069_test.js b/jscomp/test/gpr_4069_test.js index 6f99c9ae1b..bbb85781f4 100644 --- a/jscomp/test/gpr_4069_test.js +++ b/jscomp/test/gpr_4069_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f(value) { if (value == null) { @@ -11,7 +12,7 @@ function f(value) { } function fxx(v) { - let match = v(); + let match = Curry._1(v, undefined); switch (match) { case 1 : return /* 'a' */97; @@ -25,7 +26,7 @@ function fxx(v) { } function fxxx2(v) { - if (v()) { + if (Curry._1(v, undefined)) { return 2; } else { return 1; @@ -33,7 +34,7 @@ function fxxx2(v) { } function fxxx3(v) { - if (v()) { + if (Curry._1(v, undefined)) { return 2; } else { return 1; diff --git a/jscomp/test/gpr_4265_test.js b/jscomp/test/gpr_4265_test.js index f40f38c687..56b6ad3757 100644 --- a/jscomp/test/gpr_4265_test.js +++ b/jscomp/test/gpr_4265_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let Belt_MutableMapInt = require("../../lib/js/belt_MutableMapInt.js"); +let Belt_internalMapInt = require("../../lib/js/belt_internalMapInt.js"); let suites = { contents: /* [] */0 @@ -37,7 +38,7 @@ add(486); Belt_MutableMapInt.remove(mockMap, 1726); -let n1 = Belt_MutableMapInt.getExn(mockMap, 6667); +let n1 = Belt_internalMapInt.getExn(mockMap.data, 6667); eq("File \"gpr_4265_test.res\", line 18, characters 3-10", n, n1); @@ -51,4 +52,4 @@ exports.add = add; exports.remove = remove; exports.n = n; exports.n1 = n1; -/* mockMap Not a pure module */ +/* Not a pure module */ diff --git a/jscomp/test/gpr_4274_test.js b/jscomp/test/gpr_4274_test.js index 395c96e869..51f473a418 100644 --- a/jscomp/test/gpr_4274_test.js +++ b/jscomp/test/gpr_4274_test.js @@ -1,13 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Belt_List = require("../../lib/js/belt_List.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); let N = {}; function f(X, xs) { - X.forEach(xs, { + Curry._2(X.forEach, xs, { i: (function (x) { console.log(x.x); }) diff --git a/jscomp/test/gpr_858_unit2_test.js b/jscomp/test/gpr_858_unit2_test.js index 5a84b19c17..1ce0450df7 100644 --- a/jscomp/test/gpr_858_unit2_test.js +++ b/jscomp/test/gpr_858_unit2_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let delayed = { contents: (function () { @@ -13,7 +14,7 @@ for(let i = 1; i <= 2; ++i){ if (x !== 0) { let prev = delayed.contents; delayed.contents = (function () { - prev(); + Curry._1(prev, undefined); f(((n + 1 | 0) + i | 0) - i | 0, x - 1 | 0); }); return; @@ -35,6 +36,6 @@ for(let i = 1; i <= 2; ++i){ f(0, i); } -delayed.contents(); +Curry._1(delayed.contents, undefined); /* Not a pure module */ diff --git a/jscomp/test/hash_sugar_desugar.js b/jscomp/test/hash_sugar_desugar.js index 32667634e3..3f3ed71018 100644 --- a/jscomp/test/hash_sugar_desugar.js +++ b/jscomp/test/hash_sugar_desugar.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function h1(u) { return u.p; @@ -8,15 +9,15 @@ function h1(u) { function h3(u) { let f = u.hi; - return f(1, 2); + return Curry._2(f, 1, 2); } function g5(u) { - u.hi = 3; + Curry._1(u.hi, 3); } function h5(u) { - u.hi = 3; + Curry._1(u.hi, 3); } function h6(u) { @@ -24,12 +25,12 @@ function h6(u) { } function h7(u) { - return u.m(1, 2); + return Curry._2(u.m, 1, 2); } function h8(u) { let f = u.hi; - return f(1, 2); + return Curry._2(f, 1, 2); } function chain_g(h) { diff --git a/jscomp/test/hashtbl_test.js b/jscomp/test/hashtbl_test.js index c64c09f5b9..979cf206eb 100644 --- a/jscomp/test/hashtbl_test.js +++ b/jscomp/test/hashtbl_test.js @@ -39,10 +39,9 @@ function g(count) { Hashtbl.replace(tbl, (i$1 << 1), String(i$1)); } let v = to_list(tbl); - let v$1 = List.sort((function (param, param$1) { + return $$Array.of_list(List.sort((function (param, param$1) { return Caml.int_compare(param[0], param$1[0]); - }), v); - return $$Array.of_list(v$1); + }), v)); } let suites_0 = [ diff --git a/jscomp/test/inline_map2_test.js b/jscomp/test/inline_map2_test.js index cbf6192f59..6f68d660f0 100644 --- a/jscomp/test/inline_map2_test.js +++ b/jscomp/test/inline_map2_test.js @@ -4,6 +4,7 @@ let Mt = require("./mt.js"); let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); function Make(Ord) { @@ -124,7 +125,7 @@ function Make(Ord) { let d = x_._2; let v = x_._1; let l = x_._0; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return { TAG: "Node", @@ -150,7 +151,7 @@ function Make(Ord) { } }); } - let c = Ord.compare(x, x_._1); + let c = Curry._2(Ord.compare, x, x_._1); if (c === 0) { return x_._2; } @@ -164,7 +165,7 @@ function Make(Ord) { if (typeof x_ !== "object") { return false; } - let c = Ord.compare(x, x_._1); + let c = Curry._2(Ord.compare, x, x_._1); if (c === 0) { return true; } @@ -238,7 +239,7 @@ function Make(Ord) { let d = x_._2; let v = x_._1; let l = x_._0; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { if (typeof l !== "object") { return r; @@ -261,7 +262,7 @@ function Make(Ord) { return; } iter(f, x._0); - f(x._1, x._2); + Curry._2(f, x._1, x._2); _x = x._3; continue; }; @@ -271,7 +272,7 @@ function Make(Ord) { return "Empty"; } let l$p = map(f, x._0); - let d$p = f(x._2); + let d$p = Curry._1(f, x._2); let r$p = map(f, x._3); return { TAG: "Node", @@ -288,7 +289,7 @@ function Make(Ord) { } let v = x._1; let l$p = mapi(f, x._0); - let d$p = f(v, x._2); + let d$p = Curry._2(f, v, x._2); let r$p = mapi(f, x._3); return { TAG: "Node", @@ -306,7 +307,7 @@ function Make(Ord) { if (typeof m !== "object") { return accu; } - _accu = f(m._1, m._2, fold(f, m._0, accu)); + _accu = Curry._3(f, m._1, m._2, fold(f, m._0, accu)); _m = m._3; continue; }; @@ -317,7 +318,7 @@ function Make(Ord) { if (typeof x !== "object") { return true; } - if (!p(x._1, x._2)) { + if (!Curry._2(p, x._1, x._2)) { return false; } if (!for_all(p, x._0)) { @@ -333,7 +334,7 @@ function Make(Ord) { if (typeof x !== "object") { return false; } - if (p(x._1, x._2)) { + if (Curry._2(p, x._1, x._2)) { return true; } if (exists(p, x._0)) { @@ -403,7 +404,7 @@ function Make(Ord) { let d = x_._2; let v = x_._1; let l = x_._0; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return [ l, @@ -436,7 +437,7 @@ function Make(Ord) { let v1 = s1._1; if (s1._4 >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge(f, s1._0, match[0]), v1, f(v1, Caml_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); + return concat_or_join(merge(f, s1._0, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); } } @@ -454,7 +455,7 @@ function Make(Ord) { } let v2 = s2._1; let match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[0], s2._0), v2, f(v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); + return concat_or_join(merge(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); }; let filter = function (p, x) { if (typeof x !== "object") { @@ -463,7 +464,7 @@ function Make(Ord) { let d = x._2; let v = x._1; let l$p = filter(p, x._0); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, x._3); if (pvd) { return join(l$p, v, d, r$p); @@ -483,7 +484,7 @@ function Make(Ord) { let match = partition(p, x._0); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, x._3); let rf = match$1[1]; let rt = match$1[0]; @@ -533,11 +534,11 @@ function Make(Ord) { if (typeof e2 !== "object") { return 1; } - let c = Ord.compare(e1._0, e2._0); + let c = Curry._2(Ord.compare, e1._0, e2._0); if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -562,10 +563,10 @@ function Make(Ord) { if (typeof e2 !== "object") { return false; } - if (Ord.compare(e1._0, e2._0) !== 0) { + if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); @@ -906,7 +907,7 @@ function iter(f, _x) { return; } iter(f, x._0); - f(x._1, x._2); + Curry._2(f, x._1, x._2); _x = x._3; continue; }; @@ -917,7 +918,7 @@ function map(f, x) { return "Empty"; } let l$p = map(f, x._0); - let d$p = f(x._2); + let d$p = Curry._1(f, x._2); let r$p = map(f, x._3); return { TAG: "Node", @@ -935,7 +936,7 @@ function mapi(f, x) { } let v = x._1; let l$p = mapi(f, x._0); - let d$p = f(v, x._2); + let d$p = Curry._2(f, v, x._2); let r$p = mapi(f, x._3); return { TAG: "Node", @@ -954,7 +955,7 @@ function fold(f, _m, _accu) { if (typeof m !== "object") { return accu; } - _accu = f(m._1, m._2, fold(f, m._0, accu)); + _accu = Curry._3(f, m._1, m._2, fold(f, m._0, accu)); _m = m._3; continue; }; @@ -966,7 +967,7 @@ function for_all(p, _x) { if (typeof x !== "object") { return true; } - if (!p(x._1, x._2)) { + if (!Curry._2(p, x._1, x._2)) { return false; } if (!for_all(p, x._0)) { @@ -983,7 +984,7 @@ function exists(p, _x) { if (typeof x !== "object") { return false; } - if (p(x._1, x._2)) { + if (Curry._2(p, x._1, x._2)) { return true; } if (exists(p, x._0)) { @@ -1093,7 +1094,7 @@ function merge(f, s1, s2) { let v1 = s1._1; if (s1._4 >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge(f, s1._0, match[0]), v1, f(v1, Caml_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); + return concat_or_join(merge(f, s1._0, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1._2), match[1]), merge(f, s1._3, match[2])); } } @@ -1111,7 +1112,7 @@ function merge(f, s1, s2) { } let v2 = s2._1; let match$1 = split(v2, s1); - return concat_or_join(merge(f, match$1[0], s2._0), v2, f(v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); + return concat_or_join(merge(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); } function filter(p, x) { @@ -1121,7 +1122,7 @@ function filter(p, x) { let d = x._2; let v = x._1; let l$p = filter(p, x._0); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, x._3); if (pvd) { return join(l$p, v, d, r$p); @@ -1142,7 +1143,7 @@ function partition(p, x) { let match = partition(p, x._0); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, x._3); let rf = match$1[1]; let rt = match$1[0]; @@ -1198,7 +1199,7 @@ function compare(cmp, m1, m2) { if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -1227,7 +1228,7 @@ function equal(cmp, m1, m2) { if (e1._0 !== e2._0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); @@ -1599,7 +1600,7 @@ function iter$1(f, _x) { return; } iter$1(f, x._0); - f(x._1, x._2); + Curry._2(f, x._1, x._2); _x = x._3; continue; }; @@ -1610,7 +1611,7 @@ function map$1(f, x) { return "Empty"; } let l$p = map$1(f, x._0); - let d$p = f(x._2); + let d$p = Curry._1(f, x._2); let r$p = map$1(f, x._3); return { TAG: "Node", @@ -1628,7 +1629,7 @@ function mapi$1(f, x) { } let v = x._1; let l$p = mapi$1(f, x._0); - let d$p = f(v, x._2); + let d$p = Curry._2(f, v, x._2); let r$p = mapi$1(f, x._3); return { TAG: "Node", @@ -1647,7 +1648,7 @@ function fold$1(f, _m, _accu) { if (typeof m !== "object") { return accu; } - _accu = f(m._1, m._2, fold$1(f, m._0, accu)); + _accu = Curry._3(f, m._1, m._2, fold$1(f, m._0, accu)); _m = m._3; continue; }; @@ -1659,7 +1660,7 @@ function for_all$1(p, _x) { if (typeof x !== "object") { return true; } - if (!p(x._1, x._2)) { + if (!Curry._2(p, x._1, x._2)) { return false; } if (!for_all$1(p, x._0)) { @@ -1676,7 +1677,7 @@ function exists$1(p, _x) { if (typeof x !== "object") { return false; } - if (p(x._1, x._2)) { + if (Curry._2(p, x._1, x._2)) { return true; } if (exists$1(p, x._0)) { @@ -1786,7 +1787,7 @@ function merge$1(f, s1, s2) { let v1 = s1._1; if (s1._4 >= height$1(s2)) { let match = split$1(v1, s2); - return concat_or_join$1(merge$1(f, s1._0, match[0]), v1, f(v1, Caml_option.some(s1._2), match[1]), merge$1(f, s1._3, match[2])); + return concat_or_join$1(merge$1(f, s1._0, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1._2), match[1]), merge$1(f, s1._3, match[2])); } } @@ -1804,7 +1805,7 @@ function merge$1(f, s1, s2) { } let v2 = s2._1; let match$1 = split$1(v2, s1); - return concat_or_join$1(merge$1(f, match$1[0], s2._0), v2, f(v2, match$1[1], Caml_option.some(s2._2)), merge$1(f, match$1[2], s2._3)); + return concat_or_join$1(merge$1(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge$1(f, match$1[2], s2._3)); } function filter$1(p, x) { @@ -1814,7 +1815,7 @@ function filter$1(p, x) { let d = x._2; let v = x._1; let l$p = filter$1(p, x._0); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter$1(p, x._3); if (pvd) { return join$1(l$p, v, d, r$p); @@ -1835,7 +1836,7 @@ function partition$1(p, x) { let match = partition$1(p, x._0); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition$1(p, x._3); let rf = match$1[1]; let rt = match$1[0]; @@ -1891,7 +1892,7 @@ function compare$1(cmp, m1, m2) { if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -1920,7 +1921,7 @@ function equal$1(cmp, m1, m2) { if (Caml.string_compare(e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum$1(e2._2, e2._3); diff --git a/jscomp/test/inline_regression_test.js b/jscomp/test/inline_regression_test.js index f67cdb3232..edc92a61f6 100644 --- a/jscomp/test/inline_regression_test.js +++ b/jscomp/test/inline_regression_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let $$String = require("../../lib/js/string.js"); let Filename = require("../../lib/js/filename.js"); let Caml_string = require("../../lib/js/caml_string.js"); @@ -16,7 +17,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - if (!is_dir_sep(name, n)) { + if (!Curry._2(is_dir_sep, name, n)) { let _n$1 = n; let p = n + 1 | 0; while(true) { @@ -24,7 +25,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n$1 < 0) { return $$String.sub(name, 0, p); } - if (is_dir_sep(name, n$1)) { + if (Curry._2(is_dir_sep, name, n$1)) { return $$String.sub(name, n$1 + 1 | 0, (p - n$1 | 0) - 1 | 0); } _n$1 = n$1 - 1 | 0; diff --git a/jscomp/test/inline_string_test.js b/jscomp/test/inline_string_test.js index 09713e1294..c81d1e60ac 100644 --- a/jscomp/test/inline_string_test.js +++ b/jscomp/test/inline_string_test.js @@ -22,19 +22,7 @@ console.log([ console.log([ "A", - (function (x) { - switch (x.TAG) { - case "A" : - return "A"; - case "B" : - return "B"; - default: - return "?"; - } - })({ - TAG: "A", - _0: 3 - }) + "A" ]); /* Not a pure module */ diff --git a/jscomp/test/int_hashtbl_test.js b/jscomp/test/int_hashtbl_test.js index d6c1d924b2..d372054b09 100644 --- a/jscomp/test/int_hashtbl_test.js +++ b/jscomp/test/int_hashtbl_test.js @@ -5,13 +5,14 @@ let Mt = require("./mt.js"); let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Hashtbl = require("../../lib/js/hashtbl.js"); function f(H) { - let tbl = H.create(17); - H.add(tbl, 1, /* '1' */49); - H.add(tbl, 2, /* '2' */50); - let extra = H.fold((function (k, v, acc) { + let tbl = Curry._1(H.create, 17); + Curry._3(H.add, tbl, 1, /* '1' */49); + Curry._3(H.add, tbl, 2, /* '2' */50); + let extra = Curry._3(H.fold, (function (k, v, acc) { return { hd: [ k, @@ -26,14 +27,14 @@ function f(H) { } function g(H, count) { - let tbl = H.create(17); + let tbl = Curry._1(H.create, 17); for(let i = 0; i <= count; ++i){ - H.replace(tbl, (i << 1), String(i)); + Curry._3(H.replace, tbl, (i << 1), String(i)); } for(let i$1 = 0; i$1 <= count; ++i$1){ - H.replace(tbl, (i$1 << 1), String(i$1)); + Curry._3(H.replace, tbl, (i$1 << 1), String(i$1)); } - let v = H.fold((function (k, v, acc) { + let v = Curry._3(H.fold, (function (k, v, acc) { return { hd: [ k, @@ -42,15 +43,12 @@ function g(H, count) { tl: acc }; }), tbl, /* [] */0); - let v$1 = List.sort((function (param, param$1) { + return $$Array.of_list(List.sort((function (param, param$1) { return Caml.int_compare(param[0], param$1[0]); - }), v); - return $$Array.of_list(v$1); + }), v)); } -function hash(x) { - return Hashtbl.hash(x); -} +let hash = Hashtbl.hash; function equal(x, y) { return x === y; diff --git a/jscomp/test/int_map.js b/jscomp/test/int_map.js index 4e161c5c06..b776fbda6d 100644 --- a/jscomp/test/int_map.js +++ b/jscomp/test/int_map.js @@ -2,6 +2,7 @@ 'use strict'; let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); function height(param) { @@ -187,7 +188,7 @@ function find_first(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -202,7 +203,7 @@ function find_first(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -224,7 +225,7 @@ function find_first_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -239,7 +240,7 @@ function find_first_opt(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -265,7 +266,7 @@ function find_last(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -280,7 +281,7 @@ function find_last(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -302,7 +303,7 @@ function find_last_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -317,7 +318,7 @@ function find_last_opt(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -500,7 +501,7 @@ function remove(x, param) { function update(x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -520,7 +521,7 @@ function update(x, f, param) { let l = param.l; let c = Caml.int_compare(x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -561,7 +562,7 @@ function iter(f, _param) { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -572,7 +573,7 @@ function map(f, param) { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -590,7 +591,7 @@ function mapi(f, param) { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -609,7 +610,7 @@ function fold(f, _m, _accu) { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -621,7 +622,7 @@ function for_all(p, _param) { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -638,7 +639,7 @@ function exists(p, _param) { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -748,7 +749,7 @@ function merge$1(f, s1, s2) { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -766,7 +767,7 @@ function merge$1(f, s1, s2) { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } function union(f, s1, s2) { @@ -786,7 +787,7 @@ function union(f, s1, s2) { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -796,7 +797,7 @@ function union(f, s1, s2) { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -811,7 +812,7 @@ function filter(p, param) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -836,7 +837,7 @@ function partition(p, param) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -892,7 +893,7 @@ function compare(cmp, m1, m2) { if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -921,7 +922,7 @@ function equal(cmp, m1, m2) { if (e1._0 !== e2._0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); diff --git a/jscomp/test/int_switch_test.js b/jscomp/test/int_switch_test.js index caff715926..e289b646f8 100644 --- a/jscomp/test/int_switch_test.js +++ b/jscomp/test/int_switch_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -20,7 +21,7 @@ function b(loc, x) { } function f(x) { - let match = x(); + let match = Curry._1(x, undefined); switch (match) { case 1 : return /* 'a' */97; @@ -34,7 +35,7 @@ function f(x) { } function f22(x) { - let match = x(); + let match = Curry._1(x, undefined); switch (match) { case 1 : return /* 'a' */97; @@ -48,7 +49,7 @@ function f22(x) { } function f33(x) { - let match = x(); + let match = Curry._1(x, undefined); switch (match) { case "A" : return /* 'a' */97; diff --git a/jscomp/test/js_exception_catch_test.js b/jscomp/test/js_exception_catch_test.js index 0d08a67689..49f44cfb0c 100644 --- a/jscomp/test/js_exception_catch_test.js +++ b/jscomp/test/js_exception_catch_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Js_exn = require("../../lib/js/js_exn.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -95,7 +96,7 @@ let C = /* @__PURE__ */Caml_exceptions.create("Js_exception_catch_test.C"); function test(f) { try { - f(); + Curry._1(f, undefined); return "No_error"; } catch (raw_e){ diff --git a/jscomp/test/js_json_test.js b/jscomp/test/js_json_test.js index e9533d4cbb..92bd902fb2 100644 --- a/jscomp/test/js_json_test.js +++ b/jscomp/test/js_json_test.js @@ -82,34 +82,21 @@ add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { }; } let ty2 = Js_json.classify(v$1); - if (typeof ty2 !== "object" || ty2.TAG !== "JSONArray") { + if (typeof ty2 !== "object") { return { TAG: "Ok", _0: false }; - } else { - return (function () { - return { - TAG: "Ok", - _0: true - }; - })((ty2._0.forEach(function (x) { - let ty3 = Js_json.classify(x); - if (typeof ty3 !== "object") { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 37, - 19 - ] - } - }); - } - if (ty3.TAG === "JSONNumber") { - return; - } + } + if (ty2.TAG !== "JSONArray") { + return { + TAG: "Ok", + _0: false + }; + } + ty2._0.forEach(function (x) { + let ty3 = Js_json.classify(x); + if (typeof ty3 !== "object") { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -120,8 +107,25 @@ add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { ] } }); - }), undefined)); - } + } + if (ty3.TAG === "JSONNumber") { + return; + } + throw new Error("Assert_failure", { + cause: { + RE_EXN_ID: "Assert_failure", + _1: [ + "js_json_test.res", + 37, + 19 + ] + } + }); + }); + return { + TAG: "Ok", + _0: true + }; })); eq("File \"js_json_test.res\", line 48, characters 5-12", Js_json.test(v, "Object"), true); @@ -740,7 +744,7 @@ function id(obj) { } function idtest(obj) { - eq("File \"js_json_test.res\", line 355, characters 23-30", obj, id(obj)); + eq("File \"js_json_test.res\", line 355, characters 23-30", obj, Js_json.deserializeUnsafe(Js_json.serializeExn(obj))); } idtest(undefined); diff --git a/jscomp/test/label_uncurry.js b/jscomp/test/label_uncurry.js index fcfa996b3e..571687690e 100644 --- a/jscomp/test/label_uncurry.js +++ b/jscomp/test/label_uncurry.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_format = require("../../lib/js/caml_format.js"); function f(x) { @@ -12,8 +13,8 @@ function u(x, y) { } function u1(f) { - console.log(f(2, "x")); - console.log(f(2, "x")); + console.log(Curry._2(f, 2, "x")); + console.log(Curry._2(f, 2, "x")); } function h(x) { diff --git a/jscomp/test/lazy_demo.js b/jscomp/test/lazy_demo.js index d950f3be7d..1d4fa28466 100644 --- a/jscomp/test/lazy_demo.js +++ b/jscomp/test/lazy_demo.js @@ -1,15 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Lazy = require("../../lib/js/lazy.js"); let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); -let lazy1 = Lazy.from_fun(function () { +let lazy1 = CamlinternalLazy.from_fun(function () { console.log("Hello, lazy"); return 1; }); -let lazy2 = Lazy.from_fun(function () { +let lazy2 = CamlinternalLazy.from_fun(function () { return 3; }); @@ -25,4 +24,4 @@ exports.lazy1 = lazy1; exports.lazy2 = lazy2; exports.la = la; exports.lb = lb; -/* lazy1 Not a pure module */ +/* Not a pure module */ diff --git a/jscomp/test/lazy_test.js b/jscomp/test/lazy_test.js index b8e3f1dc4e..217632df99 100644 --- a/jscomp/test/lazy_test.js +++ b/jscomp/test/lazy_test.js @@ -9,7 +9,7 @@ let u = { contents: 3 }; -let v = Lazy.from_fun(function () { +let v = CamlinternalLazy.from_fun(function () { u.contents = 32; }); @@ -27,7 +27,7 @@ let u_v = { contents: 0 }; -let u$1 = Lazy.from_fun(function () { +let u$1 = CamlinternalLazy.from_fun(function () { u_v.contents = 2; }); @@ -35,27 +35,31 @@ CamlinternalLazy.force(u$1); let exotic = CamlinternalLazy.force; -let l_from_fun = Lazy.from_fun(function () { +let l_from_fun = CamlinternalLazy.from_fun(function () { return 3; }); -let forward_test = Lazy.from_fun(function () { +function f() { let u = 3; u = u + 1 | 0; return u; +} + +let forward_test = CamlinternalLazy.from_fun(function () { + return f(); }); -let f005 = Lazy.from_fun(function () { +let f005 = CamlinternalLazy.from_fun(function () { return 6; }); -let f006 = Lazy.from_fun(function () { +let f006 = CamlinternalLazy.from_fun(function () { return function () { return 3; }; }); -let f007 = Lazy.from_fun(function () { +let f007 = CamlinternalLazy.from_fun(function () { throw new Error("Not_found", { cause: { RE_EXN_ID: "Not_found" @@ -63,18 +67,20 @@ let f007 = Lazy.from_fun(function () { }); }); -let f008 = Lazy.from_fun(function () { +function f$1() { console.log("hi"); throw new Error("Not_found", { cause: { RE_EXN_ID: "Not_found" } }); +} + +let f008 = CamlinternalLazy.from_fun(function () { + return f$1(); }); -function a2(x) { - return CamlinternalLazy.from_val(x); -} +let a2 = CamlinternalLazy.from_val; let a3 = CamlinternalLazy.from_val(3); @@ -139,12 +145,11 @@ Mt.from_pair_suites("Lazy_test", { hd: [ "lazy_from_val2", (function () { - let v = Lazy.from_fun(function () { - return 3; - }); return { TAG: "Eq", - _0: CamlinternalLazy.force(CamlinternalLazy.force(CamlinternalLazy.from_val(v))), + _0: CamlinternalLazy.force(CamlinternalLazy.force(CamlinternalLazy.from_val(CamlinternalLazy.from_fun(function () { + return 3; + })))), _1: 3 }; }) @@ -210,7 +215,7 @@ Mt.from_pair_suites("Lazy_test", { (function () { return { TAG: "Ok", - _0: !Lazy.is_val(Lazy.from_fun(function () { + _0: !Lazy.is_val(CamlinternalLazy.from_fun(function () { throw new Error("Not_found", { cause: { RE_EXN_ID: "Not_found" @@ -251,4 +256,4 @@ exports.a5 = a5; exports.a6 = a6; exports.a7 = a7; exports.a8 = a8; -/* v Not a pure module */ +/* Not a pure module */ diff --git a/jscomp/test/libqueue_test.js b/jscomp/test/libqueue_test.js index 9154961b61..146b72d8ea 100644 --- a/jscomp/test/libqueue_test.js +++ b/jscomp/test/libqueue_test.js @@ -2,6 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Queue = require("../../lib/js/queue.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -36,7 +37,7 @@ let Q = { function does_raise(f, q) { try { - f(q); + Curry._1(f, q); return false; } catch (raw_exn){ diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index 2b04082cb6..501aa76e42 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -4,6 +4,7 @@ let Mt = require("./mt.js"); let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); function height(param) { if (typeof param !== "object") { @@ -178,7 +179,7 @@ function compare(cmp, m1, m2) { if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -207,7 +208,7 @@ function equal(cmp, m1, m2) { if (e1._0 !== e2._0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index e9159f4930..17f71aa180 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -3,6 +3,7 @@ let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Random = require("../../lib/js/random.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_int32 = require("../../lib/js/caml_int32.js"); @@ -620,7 +621,7 @@ function make_type(typ, dir) { function make_from_params(params, context) { let img = document.createElement("img"); - img.src = params.img_src; + Curry._1(img.src, params.img_src); return { params: params, context: context, @@ -661,7 +662,7 @@ function transform_enemy(enemy_typ, spr, dir) { dir ]); let img = document.createElement("img"); - img.src = params.img_src; + Curry._1(img.src, params.img_src); spr.params = params; spr.img = img; } @@ -702,7 +703,11 @@ function make_type$1(typ, ctx) { switch (typ) { case "BrickChunkL" : case "BrickChunkR" : - break; + return { + sprite: make_particle$1(typ, ctx), + rot: 0, + lifetime: 300 + }; default: return { sprite: make_particle$1(typ, ctx), @@ -710,11 +715,6 @@ function make_type$1(typ, ctx) { lifetime: 30 }; } - return { - sprite: make_particle$1(typ, ctx), - rot: 0, - lifetime: 300 - }; } function make$1(velOpt, accOpt, part_type, pos, ctx) { @@ -1448,8 +1448,8 @@ function render_bbox(sprite, param) { let context = sprite.context; let match = sprite.params.bbox_offset; let match$1 = sprite.params.bbox_size; - context.strokeStyle = "#FF0000"; - return context.strokeRect(param[0] + match[0], param[1] + match[1], match$1[0], match$1[1]); + Curry._1(context.strokeStyle, "#FF0000"); + return Curry._4(context.strokeRect, param[0] + match[0], param[1] + match[1], match$1[0], match$1[1]); } function render(sprite, param) { @@ -1459,7 +1459,17 @@ function render(sprite, param) { let sw = match$1[0]; let match$2 = sprite.params.frame_size; let sx = match[0] + sprite.frame.contents * sw; - return context.drawImage(sprite.img, sx, match[1], sw, match$1[1], param[0], param[1], match$2[0], match$2[1]); + return Curry.app(context.drawImage, [ + sprite.img, + sx, + match[1], + sw, + match$1[1], + param[0], + param[1], + match$2[0], + match$2[1] + ]); } function draw_bgd(bgd, off_x) { @@ -1474,34 +1484,34 @@ function draw_bgd(bgd, off_x) { } function clear_canvas(canvas) { - let context = canvas.getContext("2d"); + let context = Curry._1(canvas.getContext, "2d"); let cwidth = canvas.width; let cheight = canvas.height; - context.clearRect(0, 0, cwidth, cheight); + Curry._4(context.clearRect, 0, 0, cwidth, cheight); } function hud(canvas, score, coins) { let score_string = String(score); let coin_string = String(coins); - let context = canvas.getContext("2d"); - context.font = "10px 'Press Start 2P'"; - context.fillText("Score: " + score_string, canvas.width - 140, 18); - context.fillText("Coins: " + coin_string, 120, 18); + let context = Curry._1(canvas.getContext, "2d"); + Curry._1(context.font, "10px 'Press Start 2P'"); + Curry._3(context.fillText, "Score: " + score_string, canvas.width - 140, 18); + Curry._3(context.fillText, "Coins: " + coin_string, 120, 18); } function fps(canvas, fps_val) { let fps_str = String(fps_val | 0); - let context = canvas.getContext("2d"); - context.fillText(fps_str, 10, 18); + let context = Curry._1(canvas.getContext, "2d"); + Curry._3(context.fillText, fps_str, 10, 18); } function game_win(ctx) { - ctx.rect(0, 0, 512, 512); - ctx.fillStyle = "black"; - ctx.fill(); - ctx.fillStyle = "white"; - ctx.font = "20px 'Press Start 2P'"; - ctx.fillText("You win!", 180, 128); + Curry._4(ctx.rect, 0, 0, 512, 512); + Curry._1(ctx.fillStyle, "black"); + Curry._1(ctx.fill, undefined); + Curry._1(ctx.fillStyle, "white"); + Curry._1(ctx.font, "20px 'Press Start 2P'"); + Curry._3(ctx.fillText, "You win!", 180, 128); throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", @@ -1511,12 +1521,12 @@ function game_win(ctx) { } function game_loss(ctx) { - ctx.rect(0, 0, 512, 512); - ctx.fillStyle = "black"; - ctx.fill(); - ctx.fillStyle = "white"; - ctx.font = "20px 'Press Start 2P'"; - ctx.fillText("GAME OVER. You lose!", 60, 128); + Curry._4(ctx.rect, 0, 0, 512, 512); + Curry._1(ctx.fillStyle, "black"); + Curry._1(ctx.fill, undefined); + Curry._1(ctx.fillStyle, "white"); + Curry._1(ctx.font, "20px 'Press Start 2P'"); + Curry._3(ctx.fillText, "GAME OVER. You lose!", 60, 128); throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", @@ -1652,10 +1662,9 @@ function process_collision(dir, c1, c2, state) { let o1$2; let t2$1; let o2$2; - let o1$3; switch (c1.TAG) { case "Player" : - let o1$4 = c1._2; + let o1$3 = c1._2; let s1$2 = c1._1; switch (c2.TAG) { case "Player" : @@ -1669,14 +1678,14 @@ function process_collision(dir, c1, c2, state) { let typ$1 = c2._0; if (dir === "South") { s1 = s1$2; - o1 = o1$4; + o1 = o1$3; typ = typ$1; s2 = s2$2; o2 = o2$3; exit = 1; } else { s1$1 = s1$2; - o1$1 = o1$4; + o1$1 = o1$3; t2 = typ$1; s2$1 = s2$2; o2$1 = o2$3; @@ -1684,7 +1693,7 @@ function process_collision(dir, c1, c2, state) { } break; case "Item" : - o1$2 = o1$4; + o1$2 = o1$3; t2$1 = c2._0; o2$2 = c2._2; exit = 3; @@ -1697,14 +1706,14 @@ function process_collision(dir, c1, c2, state) { switch (t) { case "Brick" : if (c1._0 === "BigM") { - collide_block(undefined, dir, o1$4); + collide_block(undefined, dir, o1$3); dec_health(o2$4); return [ undefined, undefined ]; } else { - collide_block(undefined, dir, o1$4); + collide_block(undefined, dir, o1$3); return [ undefined, undefined @@ -1717,7 +1726,7 @@ function process_collision(dir, c1, c2, state) { undefined ]; default: - collide_block(undefined, dir, o1$4); + collide_block(undefined, dir, o1$3); return [ undefined, undefined @@ -1725,8 +1734,8 @@ function process_collision(dir, c1, c2, state) { } } else { let updated_block = evolve_block(o2$4, context); - let spawned_item = spawn_above(o1$4.dir, o2$4, t._0, context); - collide_block(undefined, dir, o1$4); + let spawned_item = spawn_above(o1$3.dir, o2$4, t._0, context); + collide_block(undefined, dir, o1$3); return [ spawned_item, updated_block @@ -1742,20 +1751,20 @@ function process_collision(dir, c1, c2, state) { undefined ]; } - exit$1 = 5; + exit$1 = 4; } else { - exit$1 = 5; + exit$1 = 4; } - if (exit$1 === 5) { + if (exit$1 === 4) { if (dir === "South") { state.multiplier = 1; - collide_block(undefined, dir, o1$4); + collide_block(undefined, dir, o1$3); return [ undefined, undefined ]; } - collide_block(undefined, dir, o1$4); + collide_block(undefined, dir, o1$3); return [ undefined, undefined @@ -1768,26 +1777,26 @@ function process_collision(dir, c1, c2, state) { } break; case "Enemy" : - let o1$5 = c1._2; + let o1$4 = c1._2; let s1$3 = c1._1; let t1 = c1._0; switch (c2.TAG) { case "Player" : - let o1$6 = c2._2; + let o1$5 = c2._2; let s1$4 = c2._1; if (dir === "North") { s1 = s1$4; - o1 = o1$6; + o1 = o1$5; typ = t1; s2 = s1$3; - o2 = o1$5; + o2 = o1$4; exit = 1; } else { s1$1 = s1$4; - o1$1 = o1$6; + o1$1 = o1$5; t2 = t1; s2$1 = s1$3; - o2$1 = o1$5; + o2$1 = o1$4; exit = 2; } break; @@ -1839,7 +1848,7 @@ function process_collision(dir, c1, c2, state) { } if (exit$3 === 4) { - rev_dir(o1$5, t1, s1$3); + rev_dir(o1$4, t1, s1$3); rev_dir(o2$5, t2$2, s2$3); return [ undefined, @@ -1851,14 +1860,14 @@ function process_collision(dir, c1, c2, state) { } switch (exit$2) { case 1 : - dec_health(o1$5); + dec_health(o1$4); dec_health(o2$5); return [ undefined, undefined ]; case 2 : - if (o1$5.vel.x === 0) { + if (o1$4.vel.x === 0) { rev_dir(o2$5, t2$2, s2$3); return [ undefined, @@ -1873,13 +1882,13 @@ function process_collision(dir, c1, c2, state) { } case 3 : if (o2$5.vel.x === 0) { - rev_dir(o1$5, t1, s1$3); + rev_dir(o1$4, t1, s1$3); return [ undefined, undefined ]; } else { - dec_health(o1$5); + dec_health(o1$4); return [ undefined, undefined @@ -1899,56 +1908,67 @@ function process_collision(dir, c1, c2, state) { switch (dir) { case "North" : case "South" : - o1$3 = o1$5; - exit = 4; - break; + collide_block(undefined, dir, o1$4); + return [ + undefined, + undefined + ]; case "East" : case "West" : - exit$4 = 5; + exit$4 = 4; break; } - if (exit$4 === 5) { + if (exit$4 === 4) { let exit$5 = 0; let typ$2; switch (t1) { case "GKoopaShell" : if (typeof t2$3 !== "object") { - exit$5 = t2$3 === "Brick" ? 7 : 6; + if (t2$3 === "Brick") { + dec_health(o2$6); + reverse_left_right(o1$4); + return [ + undefined, + undefined + ]; + } + exit$5 = 5; } else { typ$2 = t2$3._0; - exit$5 = 8; + exit$5 = 6; } break; case "RKoopaShell" : if (typeof t2$3 !== "object") { - exit$5 = t2$3 === "Brick" ? 7 : 6; + if (t2$3 === "Brick") { + dec_health(o2$6); + reverse_left_right(o1$4); + return [ + undefined, + undefined + ]; + } + exit$5 = 5; } else { typ$2 = t2$3._0; - exit$5 = 8; + exit$5 = 6; } break; default: - exit$5 = 6; + exit$5 = 5; } switch (exit$5) { - case 6 : - rev_dir(o1$5, t1, s1$3); + case 5 : + rev_dir(o1$4, t1, s1$3); return [ undefined, undefined ]; - case 7 : - dec_health(o2$6); - reverse_left_right(o1$5); - return [ - undefined, - undefined - ]; - case 8 : + case 6 : let updated_block$1 = evolve_block(o2$6, context); - let spawned_item$1 = spawn_above(o1$5.dir, o2$6, typ$2, context); - rev_dir(o1$5, t1, s1$3); + let spawned_item$1 = spawn_above(o1$4.dir, o2$6, typ$2, context); + rev_dir(o1$4, t1, s1$3); return [ updated_block$1, spawned_item$1 @@ -1979,9 +1999,11 @@ function process_collision(dir, c1, c2, state) { switch (dir) { case "North" : case "South" : - o1$3 = o2$7; - exit = 4; - break; + collide_block(undefined, dir, o2$7); + return [ + undefined, + undefined + ]; case "East" : case "West" : reverse_left_right(o2$7); @@ -1991,7 +2013,6 @@ function process_collision(dir, c1, c2, state) { ]; } - break; } break; @@ -2076,7 +2097,7 @@ function process_collision(dir, c1, c2, state) { ]; case "FireFlower" : case "Star" : - exit$6 = 5; + exit$6 = 4; break; case "Coin" : state.coins = state.coins + 1 | 0; @@ -2088,7 +2109,7 @@ function process_collision(dir, c1, c2, state) { ]; } - if (exit$6 === 5) { + if (exit$6 === 4) { dec_health(o2$2); update_score(state, 1000); return [ @@ -2097,12 +2118,6 @@ function process_collision(dir, c1, c2, state) { ]; } break; - case 4 : - collide_block(undefined, dir, o1$3); - return [ - undefined, - undefined - ]; } } @@ -2279,7 +2294,7 @@ function run_update_collid(state, collid, all_collids) { function update_loop(canvas, param, map_dim) { let player = param[0]; - let ctx = canvas.getContext("2d"); + let ctx = Curry._1(canvas.getContext, "2d"); let cwidth = canvas.width / 1; let cheight = canvas.height / 1; let viewport = make$3([ @@ -2296,7 +2311,7 @@ function update_loop(canvas, param, map_dim) { multiplier: 1, game_over: false }; - state.ctx.scale(1, 1); + Curry._2(state.ctx.scale, 1, 1); let update_helper = function (time, state, player, objs, parts) { if (state.game_over === true) { return game_win(state.ctx); @@ -3316,7 +3331,7 @@ function load(param) { } }); } - let context = canvas.getContext("2d"); + let context = Curry._1(canvas.getContext, "2d"); document.addEventListener("keydown", keydown, true); document.addEventListener("keyup", keyup, true); Random.self_init(); @@ -3339,7 +3354,7 @@ function preload(param) { return List.map((function (img_src) { let img_src$1 = "sprites/" + img_src; let img = document.createElement("img"); - img.src = img_src$1; + Curry._1(img.src, img_src$1); img.addEventListener("load", (function (ev) { inc_counter(); return true; @@ -3359,10 +3374,10 @@ function preload(param) { }); } -window.onload = (function (param) { +Curry._1(window.onload, (function (param) { preload(); return true; -}); +})); let Main = { Html: undefined, diff --git a/jscomp/test/marshal.js b/jscomp/test/marshal.js index dc884923cd..5a1dcc9aff 100644 --- a/jscomp/test/marshal.js +++ b/jscomp/test/marshal.js @@ -5,27 +5,27 @@ let Bytes = require("../../lib/js/bytes.js"); let Caml_external_polyfill = require("../../lib/js/caml_external_polyfill.js"); function to_buffer(buff, ofs, len, v, flags) { - if (!(ofs < 0 || len < 0 || ofs > (buff.length - len | 0))) { - return Caml_external_polyfill.resolve("output_value_to_buffer")(buff, ofs, len, v, flags); + if (ofs < 0 || len < 0 || ofs > (buff.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.to_buffer: substring out of bounds" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Marshal.to_buffer: substring out of bounds" - } - }); + return Caml_external_polyfill.resolve("output_value_to_buffer")(buff, ofs, len, v, flags); } function data_size(buff, ofs) { - if (!(ofs < 0 || ofs > (buff.length - 20 | 0))) { - return Caml_external_polyfill.resolve("marshal_data_size")(buff, ofs); + if (ofs < 0 || ofs > (buff.length - 20 | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.data_size" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Marshal.data_size" - } - }); + return Caml_external_polyfill.resolve("marshal_data_size")(buff, ofs); } function total_size(buff, ofs) { @@ -42,15 +42,15 @@ function from_bytes(buff, ofs) { }); } let len = Caml_external_polyfill.resolve("marshal_data_size")(buff, ofs); - if (ofs <= (buff.length - (20 + len | 0) | 0)) { - return Caml_external_polyfill.resolve("input_value_from_string")(buff, ofs); + if (ofs > (buff.length - (20 + len | 0) | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.from_bytes" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Marshal.from_bytes" - } - }); + return Caml_external_polyfill.resolve("input_value_from_string")(buff, ofs); } function from_string(buff, ofs) { diff --git a/jscomp/test/meth_annotation.js b/jscomp/test/meth_annotation.js index 3471959ac4..d17f914446 100644 --- a/jscomp/test/meth_annotation.js +++ b/jscomp/test/meth_annotation.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); -john.say("hey", "jude"); +Curry._2(john.say, "hey", "jude"); /* Not a pure module */ diff --git a/jscomp/test/method_name_test.js b/jscomp/test/method_name_test.js index 3c0e9a5a9d..b79b78f770 100644 --- a/jscomp/test/method_name_test.js +++ b/jscomp/test/method_name_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -29,18 +30,18 @@ function eq(loc, x, y) { } function f(x, i, file, v) { - x.case(i); - x.case__set(i, v); - x._open(file); - x.open__(file); + Curry._1(x.case, i); + Curry._2(x.case__set, i, v); + Curry._1(x._open, file); + Curry._1(x.open__, file); return x._MAX_LENGTH; } function ff(x, i, v) { - x.make__config = v; - x.make_config = v; - x.case__unsafe(i); - return x._open__(3); + Curry._1(x.make__config, v); + Curry._1(x.make_config, v); + Curry._1(x.case__unsafe, i); + return Curry._1(x._open__, 3); } let u = { diff --git a/jscomp/test/method_string_name.js b/jscomp/test/method_string_name.js index 96e725df69..878021ac0d 100644 --- a/jscomp/test/method_string_name.js +++ b/jscomp/test/method_string_name.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let f = { "Content-Type": 3 @@ -9,7 +10,7 @@ let f = { console.log(f["Content-Type"]); function ff(x) { - x["Content-Type"] = "hello"; + Curry._1(x["Content-Type"], "hello"); console.log(({ "Content-Type": "hello" })["Content-Type"]); diff --git a/jscomp/test/mock_mt.js b/jscomp/test/mock_mt.js index 70eea7c7fc..3fed04d922 100644 --- a/jscomp/test/mock_mt.js +++ b/jscomp/test/mock_mt.js @@ -2,6 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); function from_pair_suites(name, suites) { console.log([ @@ -10,7 +11,7 @@ function from_pair_suites(name, suites) { ]); List.iter((function (param) { let name = param[0]; - let fn = param[1](); + let fn = Curry._1(param[1], undefined); switch (fn.TAG) { case "Eq" : console.log([ diff --git a/jscomp/test/module_alias_test.js b/jscomp/test/module_alias_test.js index ad1d061bc7..f80976c3a0 100644 --- a/jscomp/test/module_alias_test.js +++ b/jscomp/test/module_alias_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -37,7 +38,7 @@ function f(x) { let h = f(/* [] */0); -let a = h.length({ +let a = Curry._1(h.length, { hd: 1, tl: { hd: 2, diff --git a/jscomp/test/more_poly_variant_test.js b/jscomp/test/more_poly_variant_test.js index 7e9057076a..13dc1abaf5 100644 --- a/jscomp/test/more_poly_variant_test.js +++ b/jscomp/test/more_poly_variant_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function map(f) { return function (x) { @@ -11,8 +12,8 @@ function map(f) { return { NAME: "Cons", VAL: [ - f(match[0]), - map(f)(match[1]) + Curry._1(f, match[0]), + Curry._1(map(f), match[1]) ] }; }; diff --git a/jscomp/test/mpr_6033_test.js b/jscomp/test/mpr_6033_test.js index a0b19a29a0..9c1d14ef49 100644 --- a/jscomp/test/mpr_6033_test.js +++ b/jscomp/test/mpr_6033_test.js @@ -2,7 +2,6 @@ 'use strict'; let Mt = require("./mt.js"); -let Lazy = require("../../lib/js/lazy.js"); let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); let suites = { @@ -34,7 +33,7 @@ function f(x) { return CamlinternalLazy.force(x) + "abc"; } -let x = Lazy.from_fun(function () { +let x = CamlinternalLazy.from_fun(function () { return "def"; }); @@ -51,4 +50,4 @@ exports.test_id = test_id; exports.eq = eq; exports.f = f; exports.u = u; -/* x Not a pure module */ +/* Not a pure module */ diff --git a/jscomp/test/mutable_obj_test.js b/jscomp/test/mutable_obj_test.js index d8a8805455..97184571d9 100644 --- a/jscomp/test/mutable_obj_test.js +++ b/jscomp/test/mutable_obj_test.js @@ -1,14 +1,15 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f(x) { - x.dec = (function (x) { + Curry._1(x.dec, (function (x) { return { x: x, y: x }; - }); + })); } exports.f = f; diff --git a/jscomp/test/name_mangle_test.js b/jscomp/test/name_mangle_test.js index 23d9221ab0..09ca47e52d 100644 --- a/jscomp/test/name_mangle_test.js +++ b/jscomp/test/name_mangle_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -30,79 +31,79 @@ function eq(loc, x, y) { function f0(x) { let old = x._open; - x._open = old + 1 | 0; + Curry._1(x._open, old + 1 | 0); return x._open; } function f1(x) { let old = x._in; - x._in = old + 1 | 0; + Curry._1(x._in, old + 1 | 0); return x._in; } function f2(x) { let old = x._MAX_LENGTH; - x._MAX_LENGTH = old + 1 | 0; + Curry._1(x._MAX_LENGTH, old + 1 | 0); return x._MAX_LENGTH; } function f3(x) { let old = x._Capital; - x._Capital = old + 1 | 0; + Curry._1(x._Capital, old + 1 | 0); return x._Capital; } function f4(x) { let old = x._open__; - x._open__ = old + 1 | 0; + Curry._1(x._open__, old + 1 | 0); return x._open__; } function f5(x) { let old = x.open__; - x.open__ = old + 1 | 0; + Curry._1(x.open__, old + 1 | 0); return x.open__; } function f6(x) { let old = x["_'x"]; - x["_'x"] = old + 1 | 0; + Curry._1(x["_'x"], old + 1 | 0); return x["_'x"]; } function f7(x) { let old = x._Capital__; - x._Capital__ = old + 1 | 0; + Curry._1(x._Capital__, old + 1 | 0); return x._Capital__; } function f8(x) { let old = x._MAX__; - x._MAX__ = old + 1 | 0; + Curry._1(x._MAX__, old + 1 | 0); return x._MAX__; } function f9(x) { let old = x.__; - x.__ = old + 1 | 0; + Curry._1(x.__, old + 1 | 0); return x.__; } function f10(x) { let old = x.__x; - x.__x = old + 1 | 0; + Curry._1(x.__x, old + 1 | 0); return x.__x; } function f11(x) { let old = x.___; - x.___ = old + 1 | 0; + Curry._1(x.___, old + 1 | 0); return x.___; } function f12(x) { let old = x.____; - x.____ = old + 1 | 0; + Curry._1(x.____, old + 1 | 0); return x.____; } diff --git a/jscomp/test/number_lexer.js b/jscomp/test/number_lexer.js index 74309374ea..d0042c47fa 100644 --- a/jscomp/test/number_lexer.js +++ b/jscomp/test/number_lexer.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Lexing = require("../../lib/js/lexing.js"); function l(prim) { @@ -120,54 +121,63 @@ let __ocaml_lex_tables = { lex_code: "" }; -function token(l, lexbuf) { - __ocaml_lex_token_rec(l, lexbuf, 0); -} - function __ocaml_lex_token_rec(l, lexbuf, ___ocaml_lex_state) { while(true) { let __ocaml_lex_state = ___ocaml_lex_state; let __ocaml_lex_state$1 = Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); switch (__ocaml_lex_state$1) { case 0 : - l("new line"); - return token(l, lexbuf); + Curry._1(l, "new line"); + ___ocaml_lex_state = 0; + continue; case 1 : - l("number"); - l(Lexing.lexeme(lexbuf)); - return token(l, lexbuf); + Curry._1(l, "number"); + Curry._1(l, Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 0; + continue; case 2 : - l("ident"); - l(Lexing.lexeme(lexbuf)); - return token(l, lexbuf); + Curry._1(l, "ident"); + Curry._1(l, Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 0; + continue; case 3 : - l("+"); - return token(l, lexbuf); + Curry._1(l, "+"); + ___ocaml_lex_state = 0; + continue; case 4 : - l("-"); - return token(l, lexbuf); + Curry._1(l, "-"); + ___ocaml_lex_state = 0; + continue; case 5 : - l("*"); - return token(l, lexbuf); + Curry._1(l, "*"); + ___ocaml_lex_state = 0; + continue; case 6 : - l("/"); - return token(l, lexbuf); + Curry._1(l, "/"); + ___ocaml_lex_state = 0; + continue; case 7 : - l("("); - return token(l, lexbuf); + Curry._1(l, "("); + ___ocaml_lex_state = 0; + continue; case 8 : - l(")"); - return token(l, lexbuf); + Curry._1(l, ")"); + ___ocaml_lex_state = 0; + continue; case 9 : - return l("eof"); + return Curry._1(l, "eof"); default: - lexbuf.refill_buff(lexbuf); + Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; continue; } }; } +function token(l, lexbuf) { + __ocaml_lex_token_rec(l, lexbuf, 0); +} + exports.l = l; exports.__ocaml_lex_tables = __ocaml_lex_tables; exports.token = token; diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 4db87f87cc..24cb054fa0 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -7,6 +7,7 @@ let Char = require("../../lib/js/char.js"); let List = require("../../lib/js/list.js"); let $$Array = require("../../lib/js/array.js"); let Bytes = require("../../lib/js/bytes.js"); +let Curry = require("../../lib/js/curry.js"); let $$String = require("../../lib/js/string.js"); let Hashtbl = require("../../lib/js/hashtbl.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); @@ -211,10 +212,6 @@ function single(c) { }; } -function add(c, l) { - return union(single(c), l); -} - function seq(c, c$p) { if (Caml_obj.lessequal(c, c$p)) { return { @@ -384,7 +381,7 @@ function bal(l, x, d, r) { }); } -function add$1(x, data, param) { +function add(x, data, param) { if (typeof param !== "object") { return { TAG: "Node", @@ -415,14 +412,14 @@ function add$1(x, data, param) { } } if (c < 0) { - let ll = add$1(x, data, l); + let ll = add(x, data, l); if (l === ll) { return param; } else { return bal(ll, v, d, r); } } - let rr = add$1(x, data, r); + let rr = add(x, data, r); if (r === rr) { return param; } else { @@ -430,10 +427,6 @@ function add$1(x, data, param) { } } -function fold_right(t, init, f) { - return List.fold_right(f, t, init); -} - let cany = { hd: [ 0, @@ -586,7 +579,7 @@ function bal$1(l, v, r) { }); } -function add$2(x, param) { +function add$1(x, param) { if (typeof param !== "object") { return { TAG: "Node", @@ -604,14 +597,14 @@ function add$2(x, param) { return param; } if (c < 0) { - let ll = add$2(x, l); + let ll = add$1(x, l); if (l === ll) { return param; } else { return bal$1(ll, v, r); } } - let rr = add$2(x, r); + let rr = add$1(x, r); if (r === rr) { return param; } else { @@ -675,7 +668,7 @@ function first(f, _x) { if (!x) { return; } - let res = f(x.hd); + let res = Curry._1(f, x.hd); if (res !== undefined) { return res; } @@ -781,20 +774,6 @@ function rep(ids, kind, sem, x) { }); } -function mark(ids, m) { - return mk_expr(ids, { - TAG: "Mark", - _0: m - }); -} - -function pmark(ids, i) { - return mk_expr(ids, { - TAG: "Pmark", - _0: i - }); -} - function erase(ids, m, m$p) { return mk_expr(ids, { TAG: "Erase", @@ -803,20 +782,6 @@ function erase(ids, m, m$p) { }); } -function before(ids, c) { - return mk_expr(ids, { - TAG: "Before", - _0: c - }); -} - -function after(ids, c) { - return mk_expr(ids, { - TAG: "After", - _0: c - }); -} - function rename(ids, x) { let l = x.def; if (typeof l !== "object") { @@ -1047,7 +1012,7 @@ function mark_used_indices(tbl) { return List.iter((function (x) { switch (x.TAG) { case "TSeq" : - return mark_used_indices(tbl)(x._0); + return Curry._1(mark_used_indices(tbl), x._0); case "TExp" : case "TMatch" : break; @@ -1078,7 +1043,7 @@ function find_free(tbl, _idx, len) { function free_index(tbl_ref, l) { let tbl = tbl_ref.contents; reset_table(tbl); - mark_used_indices(tbl)(l); + Curry._1(mark_used_indices(tbl), l); let len = tbl.length; let idx = find_free(tbl, 0, len); if (idx === len) { @@ -1109,7 +1074,12 @@ function split_at_match_rec(_l$p, _x) { switch (x$1.TAG) { case "TSeq" : case "TExp" : - break; + _x = x.tl; + _l$p = { + hd: x$1, + tl: l$p + }; + continue; case "TMatch" : return [ List.rev(l$p), @@ -1117,23 +1087,18 @@ function split_at_match_rec(_l$p, _x) { ]; } - _x = x.tl; - _l$p = { - hd: x$1, - tl: l$p - }; - continue; + } else { + throw new Error("Assert_failure", { + cause: { + RE_EXN_ID: "Assert_failure", + _1: [ + "ocaml_re_test.res", + 816, + 16 + ] + } + }); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "ocaml_re_test.res", - 816, - 16 - ] - } - }); }; } @@ -1380,7 +1345,7 @@ function delta_1(marks, c, next_cat, prev_cat, x, rem) { } case "Pmark" : let marks_marks$1 = marks.marks; - let marks_pmarks$1 = add$2(s._0, marks.pmarks); + let marks_pmarks$1 = add$1(s._0, marks.pmarks); let marks$2 = { marks: marks_marks$1, pmarks: marks_pmarks$1 @@ -1525,7 +1490,7 @@ function iter(_n, f, _v) { if (n === 0) { return v; } - _v = f(v); + _v = Curry._1(f, v); _n = n - 1 | 0; continue; }; @@ -1535,9 +1500,9 @@ function category(re, c) { if (c === -1) { return Re_automata_Category.inexistant; } else if (c === re.lnl) { - return Re_automata_Category.$plus$plus(Re_automata_Category.$plus$plus(Re_automata_Category.lastnewline, Re_automata_Category.newline), Re_automata_Category.not_letter); + return Curry._2(Re_automata_Category.$plus$plus, Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.lastnewline, Re_automata_Category.newline), Re_automata_Category.not_letter); } else { - return Re_automata_Category.from_char(Caml_bytes.get(re.col_repr, c)); + return Curry._1(Re_automata_Category.from_char, Caml_bytes.get(re.col_repr, c)); } } @@ -1566,13 +1531,13 @@ function mk_state(ncol, desc) { function find_state(re, desc) { try { - return Re_automata_State.Table.find(re.states, desc); + return Curry._2(Re_automata_State.Table.find, re.states, desc); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === "Not_found") { let st = mk_state(re.ncol, desc); - Re_automata_State.Table.add(re.states, desc, st); + Curry._3(Re_automata_State.Table.add, re.states, desc, st); return st; } throw new Error(exn.RE_EXN_ID, { @@ -1671,7 +1636,7 @@ function find_initial_state(re, cat) { catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === "Not_found") { - let st = find_state(re, Re_automata_State.create(cat, re.initial)); + let st = find_state(re, Curry._2(Re_automata_State.create, cat, re.initial)); re.initial_states = { hd: [ cat, @@ -1768,7 +1733,7 @@ function scan_str(info, s, initial_state, groups) { } function cadd(c, s) { - return add(c, s); + return union(single(c), s); } function trans_set(cache, cm, s) { @@ -1803,10 +1768,10 @@ function trans_set(cache, cm, s) { catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === "Not_found") { - let l = fold_right(s, /* [] */0, (function (param, l) { + let l = List.fold_right((function (param, l) { return union(seq(Caml_bytes.get(cm, param[0]), Caml_bytes.get(cm, param[1])), l); - })); - cache.contents = add$1(v, l, cache.contents); + }), s, /* [] */0); + cache.contents = add(v, l, cache.contents); return l; } throw new Error(exn.RE_EXN_ID, { @@ -1836,7 +1801,7 @@ function is_charset(_x) { case "Alternative" : case "Intersection" : case "Complement" : - break; + return List.for_all(is_charset, x._0); case "Difference" : if (!is_charset(x._0)) { return false; @@ -1846,7 +1811,6 @@ function is_charset(_x) { default: return false; } - return List.for_all(is_charset, x._0); }; } @@ -1862,7 +1826,7 @@ function split(s, cm) { return; } let match = t.hd; - f(match[0], match[1]); + Curry._2(f, match[0], match[1]); _t = t.tl; continue; }; @@ -1893,7 +1857,13 @@ let cdigit = seq(/* '0' */48, /* '9' */57); let calnum = union(calpha, cdigit); -let cword = add(/* '_' */95, calnum); +let cword = union({ + hd: [ + /* '_' */95, + /* '_' */95 + ], + tl: /* [] */0 +}, calnum); function colorize(c, regexp) { let lnl = { @@ -2334,31 +2304,67 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _x) if (typeof x !== "object") { switch (x) { case "Beg_of_line" : + let c$1 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.newline); return [ - after(ids, Re_automata_Category.$plus$plus(Re_automata_Category.inexistant, Re_automata_Category.newline)), + mk_expr(ids, { + TAG: "After", + _0: c$1 + }), kind ]; case "End_of_line" : + let c$2 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.newline); return [ - before(ids, Re_automata_Category.$plus$plus(Re_automata_Category.inexistant, Re_automata_Category.newline)), + mk_expr(ids, { + TAG: "Before", + _0: c$2 + }), kind ]; case "Beg_of_word" : + let c$3 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.not_letter); + let c$4 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.letter); return [ - seq$1(ids, "First", after(ids, Re_automata_Category.$plus$plus(Re_automata_Category.inexistant, Re_automata_Category.not_letter)), before(ids, Re_automata_Category.$plus$plus(Re_automata_Category.inexistant, Re_automata_Category.letter))), + seq$1(ids, "First", mk_expr(ids, { + TAG: "After", + _0: c$3 + }), mk_expr(ids, { + TAG: "Before", + _0: c$4 + })), kind ]; case "End_of_word" : + let c$5 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.letter); + let c$6 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.not_letter); return [ - seq$1(ids, "First", after(ids, Re_automata_Category.$plus$plus(Re_automata_Category.inexistant, Re_automata_Category.letter)), before(ids, Re_automata_Category.$plus$plus(Re_automata_Category.inexistant, Re_automata_Category.not_letter))), + seq$1(ids, "First", mk_expr(ids, { + TAG: "After", + _0: c$5 + }), mk_expr(ids, { + TAG: "Before", + _0: c$6 + })), kind ]; case "Not_bound" : return [ alt(ids, { - hd: seq$1(ids, "First", after(ids, Re_automata_Category.letter), before(ids, Re_automata_Category.letter)), + hd: seq$1(ids, "First", mk_expr(ids, { + TAG: "After", + _0: Re_automata_Category.letter + }), mk_expr(ids, { + TAG: "Before", + _0: Re_automata_Category.letter + })), tl: { - hd: seq$1(ids, "First", after(ids, Re_automata_Category.letter), before(ids, Re_automata_Category.letter)), + hd: seq$1(ids, "First", mk_expr(ids, { + TAG: "After", + _0: Re_automata_Category.letter + }), mk_expr(ids, { + TAG: "Before", + _0: Re_automata_Category.letter + })), tl: /* [] */0 } }), @@ -2366,27 +2372,43 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _x) ]; case "Beg_of_str" : return [ - after(ids, Re_automata_Category.inexistant), + mk_expr(ids, { + TAG: "After", + _0: Re_automata_Category.inexistant + }), kind ]; case "End_of_str" : return [ - before(ids, Re_automata_Category.inexistant), + mk_expr(ids, { + TAG: "Before", + _0: Re_automata_Category.inexistant + }), kind ]; case "Last_end_of_line" : + let c$7 = Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.inexistant, Re_automata_Category.lastnewline); return [ - before(ids, Re_automata_Category.$plus$plus(Re_automata_Category.inexistant, Re_automata_Category.lastnewline)), + mk_expr(ids, { + TAG: "Before", + _0: c$7 + }), kind ]; case "Start" : return [ - after(ids, Re_automata_Category.search_boundary), + mk_expr(ids, { + TAG: "After", + _0: Re_automata_Category.search_boundary + }), kind ]; case "Stop" : return [ - before(ids, Re_automata_Category.search_boundary), + mk_expr(ids, { + TAG: "Before", + _0: Re_automata_Category.search_boundary + }), kind ]; @@ -2475,7 +2497,13 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _x) pos.contents = pos.contents + 2 | 0; let match$3 = translate(ids, kind, ign_group, ign_case, greedy, pos, cache, c, r$p); return [ - seq$1(ids, "First", mark(ids, p), seq$1(ids, "First", match$3[0], mark(ids, p + 1 | 0))), + seq$1(ids, "First", mk_expr(ids, { + TAG: "Mark", + _0: p + }), seq$1(ids, "First", match$3[0], mk_expr(ids, { + TAG: "Mark", + _0: p + 1 | 0 + }))), match$3[1] ]; case "No_group" : @@ -2502,7 +2530,10 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _x) case "Pmark" : let match$5 = translate(ids, kind, ign_group, ign_case, greedy, pos, cache, c, x._1); return [ - seq$1(ids, "First", pmark(ids, x._0), match$5[0]), + seq$1(ids, "First", mk_expr(ids, { + TAG: "Pmark", + _0: x._0 + }), match$5[0]), match$5[1] ]; default: @@ -2808,18 +2839,6 @@ function repn(r, i, j) { }; } -function rep$1(r) { - return repn(r, 0, undefined); -} - -function rep1(r) { - return repn(r, 1, undefined); -} - -function opt(r) { - return repn(r, 0, 1); -} - function set(str) { let s = /* [] */0; for(let i = 0 ,i_finish = str.length; i < i_finish; ++i){ @@ -2831,13 +2850,6 @@ function set(str) { }; } -function rg(c, c$p) { - return { - TAG: "Set", - _0: seq(c, c$p) - }; -} - function compl(l) { let r = { TAG: "Complement", @@ -2871,7 +2883,10 @@ let notnl = { }; let lower = alt$1({ - hd: rg(/* 'a' */97, /* 'z' */122), + hd: { + TAG: "Set", + _0: seq(/* 'a' */97, /* 'z' */122) + }, tl: { hd: { TAG: "Set", @@ -2884,9 +2899,15 @@ let lower = alt$1({ } }, tl: { - hd: rg(/* '\223' */223, /* '\246' */246), + hd: { + TAG: "Set", + _0: seq(/* '\223' */223, /* '\246' */246) + }, tl: { - hd: rg(/* '\248' */248, /* '\255' */255), + hd: { + TAG: "Set", + _0: seq(/* '\248' */248, /* '\255' */255) + }, tl: /* [] */0 } } @@ -2894,11 +2915,20 @@ let lower = alt$1({ }); let upper = alt$1({ - hd: rg(/* 'A' */65, /* 'Z' */90), + hd: { + TAG: "Set", + _0: seq(/* 'A' */65, /* 'Z' */90) + }, tl: { - hd: rg(/* '\192' */192, /* '\214' */214), + hd: { + TAG: "Set", + _0: seq(/* '\192' */192, /* '\214' */214) + }, tl: { - hd: rg(/* '\216' */216, /* '\222' */222), + hd: { + TAG: "Set", + _0: seq(/* '\216' */216, /* '\222' */222) + }, tl: /* [] */0 } } @@ -2936,7 +2966,10 @@ let alpha = alt$1({ } }); -let digit = rg(/* '0' */48, /* '9' */57); +let digit = { + TAG: "Set", + _0: seq(/* '0' */48, /* '9' */57) +}; let alnum = alt$1({ hd: alpha, @@ -2963,50 +2996,95 @@ let wordc = alt$1({ } }); -let ascii = rg(/* '\000' */0, /* '\127' */127); +let ascii = { + TAG: "Set", + _0: seq(/* '\000' */0, /* '\127' */127) +}; let blank = set("\t "); let cntrl = alt$1({ - hd: rg(/* '\000' */0, /* '\031' */31), + hd: { + TAG: "Set", + _0: seq(/* '\000' */0, /* '\031' */31) + }, tl: { - hd: rg(/* '\127' */127, /* '\159' */159), + hd: { + TAG: "Set", + _0: seq(/* '\127' */127, /* '\159' */159) + }, tl: /* [] */0 } }); let graph = alt$1({ - hd: rg(/* '!' */33, /* '~' */126), + hd: { + TAG: "Set", + _0: seq(/* '!' */33, /* '~' */126) + }, tl: { - hd: rg(/* '\160' */160, /* '\255' */255), + hd: { + TAG: "Set", + _0: seq(/* '\160' */160, /* '\255' */255) + }, tl: /* [] */0 } }); let print = alt$1({ - hd: rg(/* ' ' */32, /* '~' */126), + hd: { + TAG: "Set", + _0: seq(/* ' ' */32, /* '~' */126) + }, tl: { - hd: rg(/* '\160' */160, /* '\255' */255), + hd: { + TAG: "Set", + _0: seq(/* '\160' */160, /* '\255' */255) + }, tl: /* [] */0 } }); let punct = alt$1({ - hd: rg(/* '!' */33, /* '/' */47), + hd: { + TAG: "Set", + _0: seq(/* '!' */33, /* '/' */47) + }, tl: { - hd: rg(/* ':' */58, /* '@' */64), + hd: { + TAG: "Set", + _0: seq(/* ':' */58, /* '@' */64) + }, tl: { - hd: rg(/* '[' */91, /* '`' */96), + hd: { + TAG: "Set", + _0: seq(/* '[' */91, /* '`' */96) + }, tl: { - hd: rg(/* '{' */123, /* '~' */126), + hd: { + TAG: "Set", + _0: seq(/* '{' */123, /* '~' */126) + }, tl: { - hd: rg(/* '\160' */160, /* '\169' */169), + hd: { + TAG: "Set", + _0: seq(/* '\160' */160, /* '\169' */169) + }, tl: { - hd: rg(/* '\171' */171, /* '\180' */180), + hd: { + TAG: "Set", + _0: seq(/* '\171' */171, /* '\180' */180) + }, tl: { - hd: rg(/* '\182' */182, /* '\185' */185), + hd: { + TAG: "Set", + _0: seq(/* '\182' */182, /* '\185' */185) + }, tl: { - hd: rg(/* '\187' */187, /* '\191' */191), + hd: { + TAG: "Set", + _0: seq(/* '\187' */187, /* '\191' */191) + }, tl: { hd: { TAG: "Set", @@ -3053,7 +3131,10 @@ let space = alt$1({ } }, tl: { - hd: rg(/* '\t' */9, /* '\r' */13), + hd: { + TAG: "Set", + _0: seq(/* '\t' */9, /* '\r' */13) + }, tl: /* [] */0 } }); @@ -3061,14 +3142,73 @@ let space = alt$1({ let xdigit = alt$1({ hd: digit, tl: { - hd: rg(/* 'a' */97, /* 'f' */102), + hd: { + TAG: "Set", + _0: seq(/* 'a' */97, /* 'f' */102) + }, tl: { - hd: rg(/* 'A' */65, /* 'F' */70), + hd: { + TAG: "Set", + _0: seq(/* 'A' */65, /* 'F' */70) + }, tl: /* [] */0 } } }); +function compile(r) { + let regexp = anchored(r) ? ({ + TAG: "Group", + _0: r + }) : seq$2({ + hd: { + TAG: "Sem", + _0: "Shortest", + _1: repn(any, 0, undefined) + }, + tl: { + hd: { + TAG: "Group", + _0: r + }, + tl: /* [] */0 + } + }); + let regexp$1 = handle_case(false, regexp); + let c = Bytes.make(257, /* '\000' */0); + let need_lnl = colorize(c, regexp$1); + let match = flatten_cmap(c); + let ncol = match[2]; + let col = match[0]; + let lnl = need_lnl ? ncol : -1; + let ncol$1 = need_lnl ? ncol + 1 | 0 : ncol; + let ids = { + contents: 0 + }; + let pos = { + contents: 0 + }; + let match$1 = translate(ids, "First", false, false, "Greedy", pos, { + contents: "Empty" + }, col, regexp$1); + let r$1 = enforce_kind(ids, "First", match$1[1], match$1[0]); + let col_repr = match[1]; + let group_count = pos.contents / 2 | 0; + return { + initial: r$1, + initial_states: /* [] */0, + cols: col, + col_repr: col_repr, + ncol: ncol$1, + lnl: lnl, + tbl: { + contents: [false] + }, + states: Curry._1(Re_automata_State.Table.create, 97), + group_count: group_count + }; +} + function exec_internal(name, posOpt, lenOpt, groups, re, s) { let pos = posOpt !== undefined ? posOpt : 0; let len = lenOpt !== undefined ? lenOpt : -1; @@ -3108,14 +3248,14 @@ function exec_internal(name, posOpt, lenOpt, groups, re, s) { pos: pos, last: last }; - let initial_cat = pos === 0 ? Re_automata_Category.$plus$plus(Re_automata_Category.search_boundary, Re_automata_Category.inexistant) : Re_automata_Category.$plus$plus(Re_automata_Category.search_boundary, category(re, get_color(re, s, pos - 1 | 0))); + let initial_cat = pos === 0 ? Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.search_boundary, Re_automata_Category.inexistant) : Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.search_boundary, category(re, get_color(re, s, pos - 1 | 0))); let initial_state = find_initial_state(re, initial_cat); let st = scan_str(info, s, initial_state, groups); let res; if (st.idx === -3 || partial) { res = status(st.desc); } else { - let final_cat = last === slen ? Re_automata_Category.$plus$plus(Re_automata_Category.search_boundary, Re_automata_Category.inexistant) : Re_automata_Category.$plus$plus(Re_automata_Category.search_boundary, category(re, get_color(re, s, last))); + let final_cat = last === slen ? Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.search_boundary, Re_automata_Category.inexistant) : Curry._2(Re_automata_Category.$plus$plus, Re_automata_Category.search_boundary, category(re, get_color(re, s, last))); let match = final(info, st, final_cat); if (groups) { Caml_array.set(info.positions, match[0], last + 1 | 0); @@ -3205,10 +3345,11 @@ function posix_class_of_string(x) { case "xdigit" : return xdigit; default: + let s = "Invalid pcre class: " + x; throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", - _1: "Invalid pcre class: " + x + _1: s } }); } @@ -3290,8 +3431,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - let regexp = function () { - let _left = branch$p(/* [] */0); + let regexp$p = function (_left) { while(true) { let left = _left; if (!accept(/* '|' */124)) { @@ -3331,7 +3471,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (accept(/* '(' */40)) { if (accept(/* '?' */63)) { if (accept(/* ':' */58)) { - let r = regexp(); + let r = regexp$p(branch()); if (!accept(/* ')' */41)) { throw new Error(Parse_error, { cause: { @@ -3350,7 +3490,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { } }); } - let r$1 = regexp(); + let r$1 = regexp$p(branch()); if (!accept(/* ')' */41)) { throw new Error(Parse_error, { cause: { @@ -3619,13 +3759,13 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { let piece = function () { let r = atom(); if (accept(/* '*' */42)) { - return greedy_mod(rep$1(r)); + return greedy_mod(repn(r, 0, undefined)); } if (accept(/* '+' */43)) { - return greedy_mod(rep1(r)); + return greedy_mod(repn(r, 1, undefined)); } if (accept(/* '?' */63)) { - return greedy_mod(opt(r)); + return greedy_mod(repn(r, 0, 1)); } if (!accept(/* '{' */123)) { return r; @@ -4015,7 +4155,10 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } _s = { - hd: rg(c, match$1.VAL), + hd: { + TAG: "Set", + _0: seq(c, match$1.VAL) + }, tl: s }; continue; @@ -4036,6 +4179,9 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue; }; }; + let branch = function () { + return branch$p(/* [] */0); + }; let comment = function () { while(true) { if (accept(/* ')' */41)) { @@ -4046,7 +4192,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue; }; }; - let res = regexp(); + let res = regexp$p(branch()); if (i.contents !== l) { throw new Error(Parse_error, { cause: { @@ -4088,60 +4234,6 @@ function re(flagsOpt, pat) { } } -function regexp(flags, pat) { - let r = re(flags, pat); - let regexp$1 = anchored(r) ? ({ - TAG: "Group", - _0: r - }) : seq$2({ - hd: { - TAG: "Sem", - _0: "Shortest", - _1: rep$1(any) - }, - tl: { - hd: { - TAG: "Group", - _0: r - }, - tl: /* [] */0 - } - }); - let regexp$2 = handle_case(false, regexp$1); - let c = Bytes.make(257, /* '\000' */0); - let need_lnl = colorize(c, regexp$2); - let match = flatten_cmap(c); - let ncol = match[2]; - let col = match[0]; - let lnl = need_lnl ? ncol : -1; - let ncol$1 = need_lnl ? ncol + 1 | 0 : ncol; - let ids = { - contents: 0 - }; - let pos = { - contents: 0 - }; - let match$1 = translate(ids, "First", false, false, "Greedy", pos, { - contents: "Empty" - }, col, regexp$2); - let r$1 = enforce_kind(ids, "First", match$1[1], match$1[0]); - let col_repr = match[1]; - let group_count = pos.contents / 2 | 0; - return { - initial: r$1, - initial_states: /* [] */0, - cols: col, - col_repr: col_repr, - ncol: ncol$1, - lnl: lnl, - tbl: { - contents: [false] - }, - states: Re_automata_State.Table.create(97), - group_count: group_count - }; -} - function exec(rex, pos, s) { let len; let substr = exec_internal("Re.exec", pos, len, true, rex, s); @@ -4164,7 +4256,7 @@ function exec(rex, pos, s) { let s = "a".repeat(1048575) + "b"; -eq("File \"ocaml_re_test.res\", line 3843, characters 7-14", get(exec(regexp(undefined, "aa?b"), undefined, s), 0), "aab"); +eq("File \"ocaml_re_test.res\", line 3843, characters 7-14", get(exec(compile(re(undefined, "aa?b")), undefined, s), 0), "aab"); Mt.from_pair_suites("Ocaml_re_test", suites.contents); diff --git a/jscomp/test/offset.js b/jscomp/test/offset.js index efec476040..f14004e9c2 100644 --- a/jscomp/test/offset.js +++ b/jscomp/test/offset.js @@ -3,6 +3,7 @@ let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let $$String = require("../../lib/js/string.js"); let Caml_option = require("../../lib/js/caml_option.js"); @@ -524,7 +525,7 @@ function iter(f, _param) { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -537,7 +538,7 @@ function fold(f, _s, _accu) { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -549,7 +550,7 @@ function for_all(p, _param) { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -566,7 +567,7 @@ function exists(p, _param) { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -585,7 +586,7 @@ function filter(p, param) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -609,7 +610,7 @@ function partition(p, param) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -685,7 +686,7 @@ function find_first(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -695,7 +696,7 @@ function find_first(f, _param) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -716,7 +717,7 @@ function find_first_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -726,7 +727,7 @@ function find_first_opt(f, _param) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -751,7 +752,7 @@ function find_last(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -761,7 +762,7 @@ function find_last(f, _param) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -782,7 +783,7 @@ function find_last_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -792,7 +793,7 @@ function find_last_opt(f, _param) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -830,7 +831,7 @@ function map(f, param) { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; diff --git a/jscomp/test/optional_ffi_test.js b/jscomp/test/optional_ffi_test.js index ee8af83093..8174b34ca3 100644 --- a/jscomp/test/optional_ffi_test.js +++ b/jscomp/test/optional_ffi_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); let suites = { @@ -62,11 +63,11 @@ function side_effect(x) { } function bug_to_fix(f, x) { - return hey(f(x), 3); + return hey(Curry._1(f, x), 3); } function bug_to_fix2(f, x) { - return hey(Caml_option.option_get(f(x)), 3); + return hey(Caml_option.option_get(Curry._1(f, x)), 3); } let counter2 = { diff --git a/jscomp/test/pipe_syntax.js b/jscomp/test/pipe_syntax.js index 868d41895b..e532c986ca 100644 --- a/jscomp/test/pipe_syntax.js +++ b/jscomp/test/pipe_syntax.js @@ -1,67 +1,66 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); function t0(x, f) { - return f(f(f(x))); + return Curry._1(f, Curry._1(f, Curry._1(f, x))); } function t1(x, f) { - return f(x); + return Curry._1(f, x); } function t2(x, f, g) { - return f(g(f(x), x, x)); + return Curry._1(f, Curry._3(g, Curry._1(f, x), x, x)); } function t3(x, f) { - return f(x, 1, 2); + return Curry._3(f, x, 1, 2); } function f(a, b, c) { return [ - b(a), - c(a) + Curry._1(b, a), + Curry._1(c, a) ]; } function f1(a, b, c, d) { - let __tuple_internal_obj = a(b); + let __tuple_internal_obj = Curry._1(a, b); return [ - c(__tuple_internal_obj), - d(__tuple_internal_obj) + Curry._1(c, __tuple_internal_obj), + Curry._1(d, __tuple_internal_obj) ]; } function f2(a, b, c, d) { - let __tuple_internal_obj = a(b); - let u = c(__tuple_internal_obj); - let v = d(__tuple_internal_obj); + let __tuple_internal_obj = Curry._1(a, b); + let u = Curry._1(c, __tuple_internal_obj); + let v = Curry._1(d, __tuple_internal_obj); return u + v | 0; } function f3(a, b, c, d, e) { - let __tuple_internal_obj = a(b); - let param = [ - c(__tuple_internal_obj, d), - d(__tuple_internal_obj, 1, 2), - e(__tuple_internal_obj) - ]; - return (param[0] + param[1] | 0) + param[2] | 0; + let __tuple_internal_obj = Curry._1(a, b); + let param_0 = Curry._2(c, __tuple_internal_obj, d); + let param_1 = Curry._3(d, __tuple_internal_obj, 1, 2); + let param_2 = Curry._1(e, __tuple_internal_obj); + return (param_0 + param_1 | 0) + param_2 | 0; } function f4(a, b, c) { return [ - b(a, c), - b(a, c) + Curry._2(b, a, c), + Curry._2(b, a, c) ]; } function f5(a, b, c, d) { - let v0 = b(a, c, c); - let v1 = b(a, c, c); - let v2 = b(a, d, d); + let v0 = Curry._3(b, a, c, c); + let v1 = Curry._3(b, a, c, c); + let v2 = Curry._3(b, a, d, d); return (v0 + v1 | 0) + v2 | 0; } diff --git a/jscomp/test/polymorphism_test.js b/jscomp/test/polymorphism_test.js index 040ba393b5..135478b74a 100644 --- a/jscomp/test/polymorphism_test.js +++ b/jscomp/test/polymorphism_test.js @@ -1,12 +1,13 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function map(f, x) { if (!x) { return /* [] */0; } - let r = f(x.hd); + let r = Curry._1(f, x.hd); return { hd: r, tl: map(f, x.tl) diff --git a/jscomp/test/ppx_apply_test.js b/jscomp/test/ppx_apply_test.js index e3c501ddfe..c8d27383ce 100644 --- a/jscomp/test/ppx_apply_test.js +++ b/jscomp/test/ppx_apply_test.js @@ -56,4 +56,4 @@ exports.nullary = nullary; exports.unary = unary; exports.xx = xx; exports.h = h; -/* u Not a pure module */ +/* Not a pure module */ diff --git a/jscomp/test/print_alpha_test.js b/jscomp/test/print_alpha_test.js index e9f3efb844..fd2baba15c 100644 --- a/jscomp/test/print_alpha_test.js +++ b/jscomp/test/print_alpha_test.js @@ -2,12 +2,11 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); function f(h, param) { console.log(3); - return function (x, y) { - return h(x, y); - }; + return Curry.__2(h); } Mt.from_pair_suites("Print_alpha_test", { @@ -16,9 +15,9 @@ Mt.from_pair_suites("Print_alpha_test", { (function () { return { TAG: "Eq", - _0: f((function (prim0, prim1) { + _0: Curry._2(f((function (prim0, prim1) { return prim0 + prim1 | 0; - }), undefined)(1, 2), + }), undefined), 1, 2), _1: 3 }; }) diff --git a/jscomp/test/queue_402.js b/jscomp/test/queue_402.js index 9adf63c154..a4044126e3 100644 --- a/jscomp/test/queue_402.js +++ b/jscomp/test/queue_402.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); @@ -121,7 +122,7 @@ function iter(f, q) { let _cell = tail.next; while(true) { let cell = _cell; - f(cell.content); + Curry._1(f, cell.content); if (cell === tail) { return; } @@ -140,7 +141,7 @@ function fold(f, accu, q) { while(true) { let cell = _cell; let accu$1 = _accu; - let accu$2 = f(accu$1, cell.content); + let accu$2 = Curry._2(f, accu$1, cell.content); if (cell === tail) { return accu$2; } diff --git a/jscomp/test/queue_test.js b/jscomp/test/queue_test.js index a13947853a..1671b5341b 100644 --- a/jscomp/test/queue_test.js +++ b/jscomp/test/queue_test.js @@ -3,23 +3,24 @@ let Mt = require("./mt.js"); let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Queue = require("../../lib/js/queue.js"); let Queue_402 = require("./queue_402.js"); let Caml_array = require("../../lib/js/caml_array.js"); function Test(Queue) { let to_array = function (q) { - let v = Caml_array.make(Queue.length(q), 0); - Queue.fold((function (i, e) { + let v = Caml_array.make(Curry._1(Queue.length, q), 0); + Curry._3(Queue.fold, (function (i, e) { Caml_array.set(v, i, e); return i + 1 | 0; }), 0, q); return v; }; let queue_1 = function (x) { - let q = Queue.create(); + let q = Curry._1(Queue.create, undefined); $$Array.iter((function (x) { - Queue.add(x, q); + Curry._2(Queue.add, x, q); }), x); return to_array(q); }; diff --git a/jscomp/test/random_test.js b/jscomp/test/random_test.js index 2aa27ff159..2dfa988eb6 100644 --- a/jscomp/test/random_test.js +++ b/jscomp/test/random_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Int64 = require("../../lib/js/int64.js"); let Random = require("../../lib/js/random.js"); let Mt_global = require("./mt_global.js"); @@ -33,9 +34,7 @@ function approx(f) { }; } -((function (extra, extra$1) { - return Mt_global.collect_neq(id, suites, "File \"random_test.res\", line 9, characters 2-9", extra, extra$1); - })((Random.self_init(), Random.int(10000)), (Random.self_init(), Random.int(1000)))); +Curry._2(neq("File \"random_test.res\", line 9, characters 2-9"), (Random.self_init(), Random.int(10000)), (Random.self_init(), Random.int(1000))); Random.init(0); @@ -45,20 +44,18 @@ for(let i = 0; i <= 9; ++i){ Caml_array.set(v, i, Random.bool()); } -((function (extra, extra$1) { - return Mt_global.collect_eq(id, suites, "File \"random_test.res\", line 28, characters 12-19", extra, extra$1); - })(v, [ - true, - true, - true, - true, - true, - false, - true, - true, - true, - false - ])); +Curry._2(eq("File \"random_test.res\", line 28, characters 12-19"), v, [ + true, + true, + true, + true, + true, + false, + true, + true, + true, + false +]); let f = Random.int64(Int64.max_int); diff --git a/jscomp/test/raw_output_test.js b/jscomp/test/raw_output_test.js index 9322ea7fd8..7654ebf6ea 100644 --- a/jscomp/test/raw_output_test.js +++ b/jscomp/test/raw_output_test.js @@ -1,16 +1,15 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function mk(fn) { - return fn(); + return Curry._1(fn, undefined); } (((_)=> console.log('should works'))()); -console.log((function () { - return 1; -})()); +console.log(1); exports.mk = mk; /* Not a pure module */ diff --git a/jscomp/test/reactTestUtils.js b/jscomp/test/reactTestUtils.js index 05a3759b7c..b94a28de95 100644 --- a/jscomp/test/reactTestUtils.js +++ b/jscomp/test/reactTestUtils.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); let Belt_Option = require("../../lib/js/belt_Option.js"); let Caml_option = require("../../lib/js/caml_option.js"); @@ -8,14 +9,14 @@ let TestUtils = require("react-dom/test-utils"); function act(func) { let reactFunc = function () { - func(); + Curry._1(func, undefined); }; TestUtils.act(reactFunc); } function actAsync(func) { return TestUtils.act(function () { - return func(); + return Curry._1(func, undefined); }); } diff --git a/jscomp/test/reasonReact.js b/jscomp/test/reasonReact.js index fcd2352d0f..4df8f696ab 100644 --- a/jscomp/test/reasonReact.js +++ b/jscomp/test/reasonReact.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let React = require("react"); function createDomElement(s, props, children) { @@ -8,7 +9,7 @@ function createDomElement(s, props, children) { s, props ].concat(children); - return React.createElement.apply(null, vararg); + return Curry._2(React.createElement.apply, null, vararg); } function anyToUnit(param) { @@ -56,21 +57,13 @@ function basicComponent(debugName) { }; } -function statelessComponent(debugName) { - return basicComponent(debugName); -} +let statelessComponent = basicComponent; -function statelessComponentWithRetainedProps(debugName) { - return basicComponent(debugName); -} +let statelessComponentWithRetainedProps = basicComponent; -function reducerComponent(debugName) { - return basicComponent(debugName); -} +let reducerComponent = basicComponent; -function reducerComponentWithRetainedProps(debugName) { - return basicComponent(debugName); -} +let reducerComponentWithRetainedProps = basicComponent; function element(keyOpt, refOpt, component) { let key = keyOpt !== undefined ? keyOpt : undefined; @@ -81,7 +74,7 @@ function element(keyOpt, refOpt, component) { }; let jsElementWrapped = component.jsElementWrapped; if (jsElementWrapped !== undefined) { - return jsElementWrapped(key, ref); + return Curry._2(jsElementWrapped, key, ref); } else { return React.createElement(component.reactClassInternal, { key: key, @@ -92,10 +85,8 @@ function element(keyOpt, refOpt, component) { } function wrapReasonForJs(component, jsPropsToReason) { - let uncurriedJsPropsToReason = function (jsProps) { - return jsPropsToReason(jsProps); - }; - component.reactClassInternal.prototype.jsPropsToReason = uncurriedJsPropsToReason; + let uncurriedJsPropsToReason = Curry.__1(jsPropsToReason); + Curry._1(component.reactClassInternal.prototype.jsPropsToReason, uncurriedJsPropsToReason); return component.reactClassInternal; } @@ -111,7 +102,7 @@ function wrapJsForReason(reactClass, props, children) { reactClass, props$1 ].concat(children); - return React.createElement.apply(null, varargs); + return Curry._2(React.createElement.apply, null, varargs); }); return { debugName: dummyInteropComponent.debugName, diff --git a/jscomp/test/reasonReactCompat.js b/jscomp/test/reasonReactCompat.js index cde9d8b3ad..43f178a76d 100644 --- a/jscomp/test/reasonReactCompat.js +++ b/jscomp/test/reasonReactCompat.js @@ -3,13 +3,9 @@ let ReasonReact = require("./reasonReact.js"); -function wrapReactForReasonReact(component, props, children) { - return ReasonReact.wrapJsForReason(component, props, children); -} +let wrapReactForReasonReact = ReasonReact.wrapJsForReason; -function wrapReasonReactForReact(component, propsConverter) { - return ReasonReact.wrapReasonForJs(component, propsConverter); -} +let wrapReasonReactForReact = ReasonReact.wrapReasonForJs; exports.wrapReactForReasonReact = wrapReactForReasonReact; exports.wrapReasonReactForReact = wrapReasonReactForReact; diff --git a/jscomp/test/reasonReactRouter.js b/jscomp/test/reasonReactRouter.js index 16a967a133..234e6c534b 100644 --- a/jscomp/test/reasonReactRouter.js +++ b/jscomp/test/reasonReactRouter.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let React = require("react"); function safeMakeEvent(eventName) { @@ -142,7 +143,7 @@ function watchUrl(callback) { }; } let watcherID = function () { - callback(url()); + Curry._1(callback, url()); }; window.addEventListener("popstate", watcherID); return watcherID; @@ -169,15 +170,15 @@ function useUrl(serverUrl, param) { let url$1 = match[0]; React.useEffect((function () { let watcherId = watchUrl(function (url) { - setUrl(function (param) { + Curry._1(setUrl, (function (param) { return url; - }); + })); }); let newUrl = url(); if (urlNotEqual(newUrl, url$1)) { - setUrl(function (param) { + Curry._1(setUrl, (function (param) { return newUrl; - }); + })); } return (function () { unwatchUrl(watcherId); diff --git a/jscomp/test/rec_fun_test.js b/jscomp/test/rec_fun_test.js index 43b6b52903..7d2e007f27 100644 --- a/jscomp/test/rec_fun_test.js +++ b/jscomp/test/rec_fun_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let suites = { @@ -38,7 +39,7 @@ function g() { let next = function (i, b) { called.contents = called.contents + 1 | 0; if (b) { - v.contents(i, false); + Curry._2(v.contents, i, false); } return i + 1 | 0; }; diff --git a/jscomp/test/rec_module_opt.js b/jscomp/test/rec_module_opt.js index 61b06f835b..f8d0ba2c31 100644 --- a/jscomp/test/rec_module_opt.js +++ b/jscomp/test/rec_module_opt.js @@ -3,6 +3,7 @@ let $$Set = require("../../lib/js/set.js"); let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_module = require("../../lib/js/caml_module.js"); let A = Caml_module.init_mod([ @@ -29,7 +30,7 @@ function compare(t1, t2) { } else if (t2.TAG === "Leaf") { return -1; } else { - return ASet.compare(t1._0, t2._0); + return Curry._2(ASet.compare, t1._0, t2._0); } } diff --git a/jscomp/test/rec_module_test.js b/jscomp/test/rec_module_test.js index 2e22414f15..7dc570996a 100644 --- a/jscomp/test/rec_module_test.js +++ b/jscomp/test/rec_module_test.js @@ -4,6 +4,7 @@ let Mt = require("./mt.js"); let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_module = require("../../lib/js/caml_module.js"); let Caml_option = require("../../lib/js/caml_option.js"); @@ -37,7 +38,7 @@ function even(n) { } else if (n === 1) { return false; } else { - return B.odd(n - 1 | 0); + return Curry._1(B.odd, n - 1 | 0); } } @@ -57,7 +58,7 @@ function odd(n) { } else if (n === 0) { return false; } else { - return A.even(n - 1 | 0); + return Curry._1(A.even, n - 1 | 0); } } @@ -113,12 +114,12 @@ function even$1(n) { } else if (n === 1) { return false; } else { - return BB.odd(n - 1 | 0); + return Curry._1(BB.odd, n - 1 | 0); } } function x() { - return BB.y() + 3 | 0; + return Curry._1(BB.y, undefined) + 3 | 0; } Caml_module.update_mod({ @@ -144,7 +145,7 @@ function odd$1(n) { } else if (n === 0) { return false; } else { - return AA.even(n - 1 | 0); + return Curry._1(AA.even, n - 1 | 0); } } @@ -284,7 +285,7 @@ function add(x, param) { let r = param.r; let v = param.v; let l = param.l; - let c = AAA.compare(x, v); + let c = Curry._2(AAA.compare, x, v); if (c === 0) { return param; } @@ -454,7 +455,7 @@ function split(x, param) { let r = param.r; let v = param.v; let l = param.l; - let c = AAA.compare(x, v); + let c = Curry._2(AAA.compare, x, v); if (c === 0) { return [ l, @@ -492,7 +493,7 @@ function mem(x, _param) { if (typeof param !== "object") { return false; } - let c = AAA.compare(x, param.v); + let c = Curry._2(AAA.compare, x, param.v); if (c === 0) { return true; } @@ -508,7 +509,7 @@ function remove(x, param) { let r = param.r; let v = param.v; let l = param.l; - let c = AAA.compare(x, v); + let c = Curry._2(AAA.compare, x, v); if (c === 0) { if (typeof l !== "object") { return r; @@ -631,7 +632,7 @@ function compare(s1, s2) { if (typeof e2 !== "object") { return 1; } - let c = AAA.compare(e1._0, e2._0); + let c = Curry._2(AAA.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -660,7 +661,7 @@ function subset(_s1, _s2) { } let r2 = s2.r; let l2 = s2.l; - let c = AAA.compare(v1, s2.v); + let c = Curry._2(AAA.compare, v1, s2.v); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -703,7 +704,7 @@ function iter(f, _param) { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -716,7 +717,7 @@ function fold(f, _s, _accu) { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -728,7 +729,7 @@ function for_all(p, _param) { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -745,7 +746,7 @@ function exists(p, _param) { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -764,7 +765,7 @@ function filter(p, param) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -788,7 +789,7 @@ function partition(p, param) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -844,7 +845,7 @@ function find(x, _param) { }); } let v = param.v; - let c = AAA.compare(x, v); + let c = Curry._2(AAA.compare, x, v); if (c === 0) { return v; } @@ -864,7 +865,7 @@ function find_first(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -874,7 +875,7 @@ function find_first(f, _param) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -895,7 +896,7 @@ function find_first_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -905,7 +906,7 @@ function find_first_opt(f, _param) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -930,7 +931,7 @@ function find_last(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -940,7 +941,7 @@ function find_last(f, _param) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -961,7 +962,7 @@ function find_last_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -971,7 +972,7 @@ function find_last_opt(f, _param) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -992,7 +993,7 @@ function find_opt(x, _param) { return; } let v = param.v; - let c = AAA.compare(x, v); + let c = Curry._2(AAA.compare, x, v); if (c === 0) { return Caml_option.some(v); } @@ -1009,11 +1010,11 @@ function map(f, param) { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; - } else if ((l$p === "Empty" || AAA.compare(max_elt(l$p), v$p) < 0) && (r$p === "Empty" || AAA.compare(v$p, min_elt(r$p)) < 0)) { + } else if ((l$p === "Empty" || Curry._2(AAA.compare, max_elt(l$p), v$p) < 0) && (r$p === "Empty" || Curry._2(AAA.compare, v$p, min_elt(r$p)) < 0)) { return join(l$p, v$p, r$p); } else { return union(l$p, add(v$p, r$p)); @@ -1230,10 +1231,10 @@ let suites_0 = [ false ], _1: [ - A.even(2), - AA.even(4), - B.odd(2), - BB.odd(4) + Curry._1(A.even, 2), + Curry._1(AA.even, 4), + Curry._1(B.odd, 2), + Curry._1(BB.odd, 4) ] }; }) @@ -1245,7 +1246,7 @@ let suites_1 = { (function (param) { return { TAG: "Eq", - _0: BB.y(), + _0: Curry._1(BB.y, undefined), _1: 32 }; }) @@ -1256,7 +1257,7 @@ let suites_1 = { (function (param) { return { TAG: "Eq", - _0: AA.x(), + _0: Curry._1(AA.x, undefined), _1: 35 }; }) @@ -1268,7 +1269,7 @@ let suites_1 = { return { TAG: "Eq", _0: true, - _1: A.even(2) + _1: Curry._1(A.even, 2) }; }) ], @@ -1279,7 +1280,7 @@ let suites_1 = { return { TAG: "Eq", _0: true, - _1: AA.even(4) + _1: Curry._1(AA.even, 4) }; }) ], @@ -1290,7 +1291,7 @@ let suites_1 = { return { TAG: "Eq", _0: false, - _1: B.odd(2) + _1: Curry._1(B.odd, 2) }; }) ], diff --git a/jscomp/test/recmodule.js b/jscomp/test/recmodule.js index c5b9cec6fc..5169b4380d 100644 --- a/jscomp/test/recmodule.js +++ b/jscomp/test/recmodule.js @@ -1,13 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_module = require("../../lib/js/caml_module.js"); let Entity = {}; function MakeLayer(Deps) { let getLight = function (id) { - return Deps.presentLight({ + return Curry._1(Deps.presentLight, { id: id, name: "Light 1" }); @@ -23,10 +24,10 @@ let UseCase = { function MakeLayer$1(Deps, UC) { let presentLight = function (light) { - return Deps.presentJson(light, 200); + return Curry._2(Deps.presentJson, light, 200); }; let handleGetLight = function (req) { - return UC.getLight(req.params.id); + return Curry._1(UC.getLight, req.params.id); }; return { handleGetLight: handleGetLight, @@ -153,11 +154,11 @@ Caml_module.update_mod({ }); function presentLight(light) { - return I.presentJson(light, 200); + return Curry._2(I.presentJson, light, 200); } function handleGetLight(req) { - return U.getLight(req.params.id); + return Curry._1(U.getLight, req.params.id); } Caml_module.update_mod({ @@ -178,7 +179,7 @@ Caml_module.update_mod({ }); function getLight(id) { - return A.presentLight({ + return Curry._1(A.presentLight, { id: id, name: "Light 1" }); diff --git a/jscomp/test/record_extension_test.js b/jscomp/test/record_extension_test.js index 2067603615..9e6b29e605 100644 --- a/jscomp/test/record_extension_test.js +++ b/jscomp/test/record_extension_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_format = require("../../lib/js/caml_format.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -63,7 +64,7 @@ let C = /* @__PURE__ */Caml_exceptions.create("Record_extension_test.C"); function u(f) { try { - return f(); + return Curry._1(f, undefined); } catch (raw_x){ let x = Caml_js_exceptions.internalToOCamlException(raw_x); diff --git a/jscomp/test/record_with_test.js b/jscomp/test/record_with_test.js index 045fc38e5b..c1cadd2cad 100644 --- a/jscomp/test/record_with_test.js +++ b/jscomp/test/record_with_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let v = { syntax: undefined, @@ -24,7 +25,7 @@ let u_v = { }; function f(g, h) { - let init = g(h); + let init = Curry._1(g, h); return { syntax: init.syntax, imports: 0, diff --git a/jscomp/test/recursive_module.js b/jscomp/test/recursive_module.js index c28f063fcd..2574e8eeb4 100644 --- a/jscomp/test/recursive_module.js +++ b/jscomp/test/recursive_module.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let Lazy = require("../../lib/js/lazy.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_module = require("../../lib/js/caml_module.js"); let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -70,7 +71,7 @@ let Intb = Caml_module.init_mod([ ]] }); -let a = Lazy.from_fun(function () { +let a = CamlinternalLazy.from_fun(function () { return CamlinternalLazy.force(Intb.a); }); @@ -84,7 +85,7 @@ Caml_module.update_mod({ a: a }); -let a$1 = Lazy.from_fun(function () { +let a$1 = CamlinternalLazy.from_fun(function () { return CamlinternalLazy.force(Inta.a) + 1 | 0; }); @@ -140,7 +141,7 @@ let Intb$1 = Caml_module.init_mod([ ]] }); -let a$2 = Lazy.from_fun(function () { +let a$2 = CamlinternalLazy.from_fun(function () { return CamlinternalLazy.force(Intb$1.a) + 1 | 0; }); @@ -154,7 +155,7 @@ Caml_module.update_mod({ a: a$2 }); -let a$3 = Lazy.from_fun(function () { +let a$3 = CamlinternalLazy.from_fun(function () { return 2; }); @@ -178,7 +179,7 @@ eq("File \"recursive_module.res\", line 59, characters 3-10", CamlinternalLazy.f let tmp$1; try { - Int3.u(3); + Curry._1(Int3.u, 3); tmp$1 = 3; } catch (raw_exn$1){ diff --git a/jscomp/test/recursive_module_test.js b/jscomp/test/recursive_module_test.js index 6edee60332..fc4bf1f9d0 100644 --- a/jscomp/test/recursive_module_test.js +++ b/jscomp/test/recursive_module_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_module = require("../../lib/js/caml_module.js"); let suites = { @@ -72,7 +73,7 @@ function fact(n) { if (n <= 1) { return 1; } else { - return Math.imul(n, M.fact(n - 1 | 0)); + return Math.imul(n, Curry._1(M.fact, n - 1 | 0)); } } @@ -93,7 +94,7 @@ let Fact = { fact: fact$1 }; -eq("File \"recursive_module_test.res\", line 29, characters 12-19", 120, fact$1(5)); +eq("File \"recursive_module_test.res\", line 29, characters 12-19", 120, Curry._1(fact$1, 5)); add([ "File \"recursive_module_test.res\", line 31, characters 14-21", @@ -101,7 +102,7 @@ add([ return { TAG: "ThrowAny", _0: (function () { - Int3.u(3); + Curry._1(Int3.u, 3); }) }; }) diff --git a/jscomp/test/res_debug.js b/jscomp/test/res_debug.js index da1289ce18..0ff8b6dbb2 100644 --- a/jscomp/test/res_debug.js +++ b/jscomp/test/res_debug.js @@ -1,11 +1,12 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_option = require("../../lib/js/caml_option.js"); function f(window, a, b) { - return window.location(a, b); + return Curry._2(window.location, a, b); } let v0 = { @@ -28,7 +29,7 @@ function testMatch(v) { function optionMap(x, f) { if (x !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(x))); + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(x))); } } diff --git a/jscomp/test/set_annotation.js b/jscomp/test/set_annotation.js index ac80862af3..d6d3cbb118 100644 --- a/jscomp/test/set_annotation.js +++ b/jscomp/test/set_annotation.js @@ -1,8 +1,9 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let MyJSFile = require("MyJSFile"); -MyJSFile.student1.name = "Mary"; +Curry._1(MyJSFile.student1.name, "Mary"); /* Not a pure module */ diff --git a/jscomp/test/set_gen.js b/jscomp/test/set_gen.js index 4c211f46ae..ab3ba89780 100644 --- a/jscomp/test/set_gen.js +++ b/jscomp/test/set_gen.js @@ -2,6 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Pervasives = require("../../lib/js/pervasives.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); @@ -121,7 +122,7 @@ function iter(f, _x) { return; } iter(f, x._0); - f(x._1); + Curry._1(f, x._1); _x = x._2; continue; }; @@ -134,7 +135,7 @@ function fold(f, _s, _accu) { if (typeof s !== "object") { return accu; } - _accu = f(s._1, fold(f, s._0, accu)); + _accu = Curry._2(f, s._1, fold(f, s._0, accu)); _s = s._2; continue; }; @@ -146,7 +147,7 @@ function for_all(p, _x) { if (typeof x !== "object") { return true; } - if (!p(x._1)) { + if (!Curry._1(p, x._1)) { return false; } if (!for_all(p, x._0)) { @@ -163,7 +164,7 @@ function exists(p, _x) { if (typeof x !== "object") { return false; } - if (p(x._1)) { + if (Curry._1(p, x._1)) { return true; } if (exists(p, x._0)) { @@ -410,7 +411,7 @@ function filter(p, x) { } let v = x._1; let l$p = filter(p, x._0); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, x._2); if (pv) { return internal_join(l$p, v, r$p); @@ -430,7 +431,7 @@ function partition(p, x) { let match = partition(p, x._0); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, x._2); let rf = match$1[1]; let rt = match$1[0]; @@ -634,7 +635,7 @@ function is_ordered(cmp, tree) { let min_v = match$1[0]; let match$2 = is_ordered_min_max(r); if (typeof match$2 !== "object") { - if (match$2 === "Empty" && cmp(max_v, v) < 0) { + if (match$2 === "Empty" && Curry._2(cmp, max_v, v) < 0) { return { NAME: "V", VAL: [ @@ -647,7 +648,7 @@ function is_ordered(cmp, tree) { } } let match$3 = match$2.VAL; - if (cmp(max_v, match$3[0]) < 0) { + if (Curry._2(cmp, max_v, match$3[0]) < 0) { return { NAME: "V", VAL: [ @@ -677,7 +678,7 @@ function is_ordered(cmp, tree) { } } let match$5 = match$4.VAL; - if (cmp(v, match$5[0]) < 0) { + if (Curry._2(cmp, v, match$5[0]) < 0) { return { NAME: "V", VAL: [ @@ -711,7 +712,7 @@ function compare_aux(cmp, _e1, _e2) { if (typeof e2 !== "object") { return 1; } - let c = cmp(e1._0, e2._0); + let c = Curry._2(cmp, e1._0, e2._0); if (c !== 0) { return c; } diff --git a/jscomp/test/sexp.js b/jscomp/test/sexp.js index cc631d3a3a..0b90d79a65 100644 --- a/jscomp/test/sexp.js +++ b/jscomp/test/sexp.js @@ -2,6 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Hashtbl = require("../../lib/js/hashtbl.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Pervasives = require("../../lib/js/pervasives.js"); @@ -12,9 +13,7 @@ let equal = Caml_obj.equal; let compare = Caml_obj.compare; -function hash(a) { - return Hashtbl.hash(a); -} +let hash = Hashtbl.hash; function of_int(x) { return { @@ -150,14 +149,14 @@ function $$return(x) { function $great$pipe$eq(e, f) { if (e !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(e))); + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(e))); } } function $great$great$eq(e, f) { if (e !== undefined) { - return f(Caml_option.valFromOption(e)); + return Curry._1(f, Caml_option.valFromOption(e)); } } @@ -171,7 +170,7 @@ function map_opt(f, l) { if (!l$1) { return List.rev(acc); } - let y = f(l$1.hd); + let y = Curry._1(f, l$1.hd); if (y === undefined) { return; } @@ -192,7 +191,7 @@ function list_any(f, e) { if (!l) { return; } - let res = f(l.hd); + let res = Curry._1(f, l.hd); if (res !== undefined) { return res; } @@ -214,7 +213,7 @@ function list_all(f, e) { return List.rev(acc); } let tl = l.tl; - let y = f(l.hd); + let y = Curry._1(f, l.hd); if (y !== undefined) { _l = tl; _acc = { @@ -236,7 +235,7 @@ function _try_atom(e, f) { return; } try { - return Caml_option.some(f(e.VAL)); + return Caml_option.some(Curry._1(f, e.VAL)); } catch (exn){ return; @@ -286,8 +285,8 @@ function to_pair_with(f1, f2) { return function (e) { return $great$great$eq(to_pair(e), (function (param) { let y = param[1]; - return $great$great$eq(f1(param[0]), (function (x) { - return $great$great$eq(f2(y), (function (y) { + return $great$great$eq(Curry._1(f1, param[0]), (function (x) { + return $great$great$eq(Curry._1(f2, y), (function (y) { return [ x, y @@ -329,9 +328,9 @@ function to_triple_with(f1, f2, f3) { return $great$great$eq(to_triple(e), (function (param) { let z = param[2]; let y = param[1]; - return $great$great$eq(f1(param[0]), (function (x) { - return $great$great$eq(f2(y), (function (y) { - return $great$great$eq(f3(z), (function (z) { + return $great$great$eq(Curry._1(f1, param[0]), (function (x) { + return $great$great$eq(Curry._1(f2, y), (function (y) { + return $great$great$eq(Curry._1(f3, z), (function (z) { return [ x, y, @@ -370,20 +369,39 @@ function get_field(name) { return; } let match = l.hd; - if (typeof match === "object" && match.NAME === "List") { - let match$1 = match.VAL; - if (match$1) { - let match$2 = match$1.hd; - if (typeof match$2 === "object" && match$2.NAME === "Atom") { - let match$3 = match$1.tl; - if (match$3 && !match$3.tl && Caml_obj.equal(name, match$2.VAL)) { - return match$3.hd; + if (typeof match === "object") { + if (match.NAME === "List") { + let match$1 = match.VAL; + if (match$1) { + let match$2 = match$1.hd; + if (typeof match$2 === "object") { + if (match$2.NAME === "Atom") { + let match$3 = match$1.tl; + if (match$3) { + if (match$3.tl) { + _l = l.tl; + continue; + } + if (Caml_obj.equal(name, match$2.VAL)) { + return match$3.hd; + } + _l = l.tl; + continue; + } + _l = l.tl; + continue; + } + _l = l.tl; + continue; } - + _l = l.tl; + continue; } - + _l = l.tl; + continue; } - + _l = l.tl; + continue; } _l = l.tl; continue; @@ -395,7 +413,7 @@ function get_field(name) { function field(name, f) { return function (e) { - return $great$great$eq(get_field(name)(e), f); + return $great$great$eq(Curry._1(get_field(name), e), f); }; } @@ -406,16 +424,30 @@ function _get_field_list(name, _l) { return; } let match = l.hd; - if (typeof match === "object" && match.NAME === "List") { - let match$1 = match.VAL; - if (match$1) { - let match$2 = match$1.hd; - if (typeof match$2 === "object" && match$2.NAME === "Atom" && Caml_obj.equal(name, match$2.VAL)) { - return match$1.tl; + if (typeof match === "object") { + if (match.NAME === "List") { + let match$1 = match.VAL; + if (match$1) { + let match$2 = match$1.hd; + if (typeof match$2 === "object") { + if (match$2.NAME === "Atom") { + if (Caml_obj.equal(name, match$2.VAL)) { + return match$1.tl; + } + _l = l.tl; + continue; + } + _l = l.tl; + continue; + } + _l = l.tl; + continue; } - + _l = l.tl; + continue; } - + _l = l.tl; + continue; } _l = l.tl; continue; @@ -439,7 +471,7 @@ function _get_variant(s, args, _l) { } let match = l.hd; if (Caml_obj.equal(s, match[0])) { - return match[1](args); + return Curry._1(match[1], args); } _l = l.tl; continue; @@ -521,4 +553,4 @@ exports.of_variant = of_variant; exports.of_field = of_field; exports.of_record = of_record; exports.Traverse = Traverse; -/* Hashtbl Not a pure module */ +/* No side effect */ diff --git a/jscomp/test/sexpm.js b/jscomp/test/sexpm.js index 44de13f8fd..b593f96512 100644 --- a/jscomp/test/sexpm.js +++ b/jscomp/test/sexpm.js @@ -6,6 +6,7 @@ let Caml = require("../../lib/js/caml.js"); let Char = require("../../lib/js/char.js"); let List = require("../../lib/js/list.js"); let Bytes = require("../../lib/js/bytes.js"); +let Curry = require("../../lib/js/curry.js"); let Buffer = require("../../lib/js/buffer.js"); let $$String = require("../../lib/js/string.js"); let Caml_bytes = require("../../lib/js/caml_bytes.js"); @@ -151,13 +152,13 @@ function _is_digit(c) { } function _refill(t, k_succ, k_fail) { - let n = t.refill(t.buf, 0, t.buf.length); + let n = Curry._3(t.refill, t.buf, 0, t.buf.length); t.i = 0; t.len = n; if (n === 0) { - return k_fail(t); + return Curry._1(k_fail, t); } else { - return k_succ(t); + return Curry._1(k_succ, t); } } @@ -291,7 +292,7 @@ function expr_list(acc, k, t) { let c = _get(t); if (c > 32 || c < 9) { if (c === 41) { - return k(undefined, { + return Curry._2(k, undefined, { NAME: "List", VAL: List.rev(acc) }); @@ -302,7 +303,22 @@ function expr_list(acc, k, t) { } return expr_starting_with(c, (function (last, e) { if (last !== undefined) { - if (last === 40) { + if (last !== 40) { + if (last !== 41) { + return expr_list({ + hd: e, + tl: acc + }, k, t); + } else { + return Curry._2(k, undefined, { + NAME: "List", + VAL: List.rev({ + hd: e, + tl: acc + }) + }); + } + } else { return expr_list(/* [] */0, (function (param, l) { return expr_list({ hd: l, @@ -310,21 +326,12 @@ function expr_list(acc, k, t) { }, k, t); }), t); } - if (last === 41) { - return k(undefined, { - NAME: "List", - VAL: List.rev({ - hd: e, - tl: acc - }) - }); - } - + } else { + return expr_list({ + hd: e, + tl: acc + }, k, t); } - return expr_list({ - hd: e, - tl: acc - }, k, t); }), t); }; } @@ -332,7 +339,7 @@ function expr_list(acc, k, t) { function _return_atom(last, k, t) { let s = Buffer.contents(t.atom); t.atom.position = 0; - return k(last, { + return Curry._2(k, last, { NAME: "Atom", VAL: s }); @@ -421,13 +428,13 @@ function escaped(k, t) { if (c < 117) { switch (c) { case 92 : - return k(/* '\\' */92); + return Curry._1(k, /* '\\' */92); case 98 : - return k(/* '\b' */8); + return Curry._1(k, /* '\b' */8); case 110 : - return k(/* '\n' */10); + return Curry._1(k, /* '\n' */10); case 114 : - return k(/* '\r' */13); + return Curry._1(k, /* '\r' */13); case 93 : case 94 : case 95 : @@ -450,17 +457,17 @@ function escaped(k, t) { case 115 : break; case 116 : - return k(/* '\t' */9); + return Curry._1(k, /* '\t' */9); } } } else if (c === 34) { - return k(/* '"' */34); + return Curry._1(k, /* '"' */34); } if (_is_digit(c)) { return read2int(c - /* '0' */48 | 0, (function (n) { - return k(Char.chr(n)); + return Curry._1(k, Char.chr(n)); }), t); } else { return _error(t, "unexpected escaped char '" + (c + "'")); @@ -489,7 +496,7 @@ function read1int(i, k, t) { } let c = _get(t); if (_is_digit(c)) { - return k(Math.imul(10, i) + (c - /* '0' */48 | 0) | 0); + return Curry._1(k, Math.imul(10, i) + (c - /* '0' */48 | 0) | 0); } else { return _error(t, "unexpected escaped char '" + (c + "' when reading byte")); } @@ -504,7 +511,7 @@ function skip_comment(k, t) { } let match = _get(t); if (match === 10) { - return k(undefined, undefined); + return Curry._2(k, undefined, undefined); } continue; }; diff --git a/jscomp/test/small_inline_test.js b/jscomp/test/small_inline_test.js index 9e13d19432..f68a3a8a52 100644 --- a/jscomp/test/small_inline_test.js +++ b/jscomp/test/small_inline_test.js @@ -1,29 +1,30 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function $pipe$great(x, f) { - return f(x); + return Curry._1(f, x); } function hello1(y, f) { - return f(y); + return Curry._1(f, y); } function hello2(y, f) { - return f(y); + return Curry._1(f, y); } function hello3(y, f) { - return f(y); + return Curry._1(f, y); } function hello4(y, f) { - return f(y); + return Curry._1(f, y); } function hello5(y, f) { - return f(y); + return Curry._1(f, y); } function f(_x) { diff --git a/jscomp/test/stack_comp_test.js b/jscomp/test/stack_comp_test.js index 5f384a3582..d44a82031f 100644 --- a/jscomp/test/stack_comp_test.js +++ b/jscomp/test/stack_comp_test.js @@ -2,6 +2,8 @@ 'use strict'; let Mt = require("./mt.js"); +let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Stack = require("../../lib/js/stack.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Mt_global = require("./mt_global.js"); @@ -30,12 +32,12 @@ function to_list(s) { let l = { contents: /* [] */0 }; - Stack.iter((function (x) { + List.iter((function (x) { l.contents = { hd: x, tl: l.contents }; - }), s); + }), s.c); return l.contents; } @@ -56,7 +58,7 @@ let S = { function does_raise(f, s) { try { - f(s); + Curry._1(f, s); return false; } catch (raw_exn){ @@ -358,10 +360,10 @@ let i$7 = { contents: 1 }; -Stack.iter((function (j) { +List.iter((function (j) { assert_("File \"stack_comp_test.res\", line 143, characters 12-19", i$7.contents === j); i$7.contents = i$7.contents + 1 | 0; -}), s$5); +}), s$5.c); let s1$1 = { c: /* [] */0, diff --git a/jscomp/test/stream_parser_test.js b/jscomp/test/stream_parser_test.js index 63128f88f2..87ec80ec7f 100644 --- a/jscomp/test/stream_parser_test.js +++ b/jscomp/test/stream_parser_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Queue = require("../../lib/js/queue.js"); let Genlex = require("../../lib/js/genlex.js"); let Stream = require("../../lib/js/stream.js"); @@ -21,7 +22,7 @@ function parse(token) { return Queue.pop(look_ahead); } try { - return token(); + return Curry._1(token, undefined); } catch (exn){ return { @@ -35,7 +36,7 @@ function parse(token) { switch (n.TAG) { case "Kwd" : if (n._0 === "(") { - let v = parse_expr(); + let v = parse_expr_aux(parse_term()); let match = token$1(); if (match.TAG === "Kwd") { if (match._0 === ")") { @@ -75,14 +76,16 @@ function parse(token) { } }; let parse_term = function () { - let e1 = parse_atom(); + return parse_term_aux(parse_atom()); + }; + let parse_expr_aux = function (e1) { let e = token$1(); if (e.TAG === "Kwd") { switch (e._0) { - case "*" : - return Math.imul(e1, parse_term()); - case "/" : - return Caml_int32.div(e1, parse_term()); + case "+" : + return e1 + parse_expr_aux(parse_term()) | 0; + case "-" : + return e1 - parse_expr_aux(parse_term()) | 0; default: Queue.push(e, look_ahead); return e1; @@ -92,15 +95,14 @@ function parse(token) { return e1; } }; - let parse_expr = function () { - let e1 = parse_term(); + let parse_term_aux = function (e1) { let e = token$1(); if (e.TAG === "Kwd") { switch (e._0) { - case "+" : - return e1 + parse_expr() | 0; - case "-" : - return e1 - parse_expr() | 0; + case "*" : + return Math.imul(e1, parse_term_aux(parse_atom())); + case "/" : + return Caml_int32.div(e1, parse_term_aux(parse_atom())); default: Queue.push(e, look_ahead); return e1; @@ -110,7 +112,7 @@ function parse(token) { return e1; } }; - let r = parse_expr(); + let r = parse_expr_aux(parse_term()); return [ r, Queue.fold((function (acc, x) { @@ -160,7 +162,7 @@ function l_parse(token) { return Queue.pop(look_ahead); } try { - return token(); + return Curry._1(token, undefined); } catch (exn){ return { @@ -169,58 +171,12 @@ function l_parse(token) { }; } }; - let parse_e = function () { - let _a = parse_t(); - while(true) { - let a = _a; - let t = token$1(); - if (t.TAG === "Kwd") { - switch (t._0) { - case "+" : - _a = a + parse_t() | 0; - continue; - case "-" : - _a = a - parse_t() | 0; - continue; - default: - Queue.push(t, look_ahead); - return a; - } - } else { - Queue.push(t, look_ahead); - return a; - } - }; - }; - let parse_t = function () { - let _a = parse_f(); - while(true) { - let a = _a; - let t = token$1(); - if (t.TAG === "Kwd") { - switch (t._0) { - case "*" : - _a = Math.imul(a, parse_f()); - continue; - case "/" : - _a = Caml_int32.div(a, parse_f()); - continue; - default: - Queue.push(t, look_ahead); - return a; - } - } else { - Queue.push(t, look_ahead); - return a; - } - }; - }; let parse_f = function () { let i = token$1(); switch (i.TAG) { case "Kwd" : if (i._0 === "(") { - let v = parse_e(); + let v = parse_t_aux(parse_t()); let t = token$1(); if (t.TAG === "Kwd") { if (t._0 === ")") { @@ -257,7 +213,54 @@ function l_parse(token) { }); } }; - let r = parse_e(); + let parse_f_aux = function (_a) { + while(true) { + let a = _a; + let t = token$1(); + if (t.TAG === "Kwd") { + switch (t._0) { + case "*" : + _a = Math.imul(a, parse_f()); + continue; + case "/" : + _a = Caml_int32.div(a, parse_f()); + continue; + default: + Queue.push(t, look_ahead); + return a; + } + } else { + Queue.push(t, look_ahead); + return a; + } + }; + }; + let parse_t_aux = function (_a) { + while(true) { + let a = _a; + let t = token$1(); + if (t.TAG === "Kwd") { + switch (t._0) { + case "+" : + _a = a + parse_f_aux(parse_f()) | 0; + continue; + case "-" : + _a = a - parse_f_aux(parse_f()) | 0; + continue; + default: + Queue.push(t, look_ahead); + return a; + } + } else { + Queue.push(t, look_ahead); + return a; + } + }; + }; + let parse_t = function () { + return parse_f_aux(parse_f()); + }; + let r = parse_t_aux(parse_t()); return [ r, Queue.fold((function (acc, x) { diff --git a/jscomp/test/string_runtime_test.js b/jscomp/test/string_runtime_test.js index e875088074..f63935b895 100644 --- a/jscomp/test/string_runtime_test.js +++ b/jscomp/test/string_runtime_test.js @@ -4,7 +4,6 @@ let Mt = require("./mt.js"); let List = require("../../lib/js/list.js"); let Bytes = require("../../lib/js/bytes.js"); -let $$String = require("../../lib/js/string.js"); let Test_char = require("./test_char.js"); let Caml_bytes = require("../../lib/js/caml_bytes.js"); @@ -28,9 +27,9 @@ let suites_1 = { Bytes.fill(b, 0, x, /* 'c' */99); return [ Bytes.to_string(b), - $$String.init(x, (function (param) { + Bytes.unsafe_to_string(Bytes.init(x, (function (param) { return /* 'c' */99; - })) + }))) ]; }), { hd: 1000, diff --git a/jscomp/test/string_set.js b/jscomp/test/string_set.js index 985bc64571..7103bdbfba 100644 --- a/jscomp/test/string_set.js +++ b/jscomp/test/string_set.js @@ -165,7 +165,7 @@ function compare(s1, s2) { } function equal(s1, s2) { - return compare(s1, s2) === 0; + return Set_gen.compare($$String.compare, s1, s2) === 0; } function subset(_s1, _s2) { diff --git a/jscomp/test/string_test.js b/jscomp/test/string_test.js index b26b614d53..f68a72d7b0 100644 --- a/jscomp/test/string_test.js +++ b/jscomp/test/string_test.js @@ -3,6 +3,7 @@ let Mt = require("./mt.js"); let List = require("../../lib/js/list.js"); +let $$Array = require("../../lib/js/array.js"); let Bytes = require("../../lib/js/bytes.js"); let $$String = require("../../lib/js/string.js"); let Ext_string_test = require("./ext_string_test.js"); @@ -129,7 +130,7 @@ function string_of_chars(x) { let extra = List.map((function (prim) { return String.fromCharCode(prim); }), x); - return $$String.concat("", extra); + return $$Array.of_list(extra).join(""); } Mt.from_pair_suites("String_test", { diff --git a/jscomp/test/submodule_call.js b/jscomp/test/submodule_call.js index 6bbfb22c22..abc1e34326 100644 --- a/jscomp/test/submodule_call.js +++ b/jscomp/test/submodule_call.js @@ -1,17 +1,18 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Submodule = require("./submodule.js"); let a0 = Submodule.A0.a0(1, 2); -let a1 = Submodule.A0.A1.a1(1, 2); +let a1 = Curry._2(Submodule.A0.A1.a1, 1, 2); -let a2 = Submodule.A0.A1.A2.a2(1, 2); +let a2 = Curry._2(Submodule.A0.A1.A2.a2, 1, 2); -let a3 = Submodule.A0.A1.A2.A3.a3(1, 2); +let a3 = Curry._2(Submodule.A0.A1.A2.A3.a3, 1, 2); -let a4 = Submodule.A0.A1.A2.A3.A4.a4(1, 2); +let a4 = Curry._2(Submodule.A0.A1.A2.A3.A4.a4, 1, 2); exports.a0 = a0; exports.a1 = a1; diff --git a/jscomp/test/test_ari.js b/jscomp/test/test_ari.js index 32407d6233..aa63ea0ad0 100644 --- a/jscomp/test/test_ari.js +++ b/jscomp/test/test_ari.js @@ -4,6 +4,7 @@ let U = require("U"); let VV = require("VV"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); function f(x, y) { return x + y | 0; @@ -14,7 +15,7 @@ function f1(x, y) { } function f3(g, x) { - return g(x); + return Curry._1(g, x); } function f2(extra) { diff --git a/jscomp/test/test_array_primitive.js b/jscomp/test/test_array_primitive.js index 69819d9239..d1dc53858d 100644 --- a/jscomp/test/test_array_primitive.js +++ b/jscomp/test/test_array_primitive.js @@ -12,27 +12,27 @@ function caml_array_sub(x, offset, len) { } function caml_array_set(xs, index, newval) { - if (!(index < 0 || index >= xs.length)) { - return Caml_array.set(xs, index, newval); + if (index < 0 || index >= xs.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); + Caml_array.set(xs, index, newval); } function caml_array_get(xs, index) { - if (!(index < 0 || index >= xs.length)) { - return Caml_array.get(xs, index); + if (index < 0 || index >= xs.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); + return Caml_array.get(xs, index); } function caml_make_vect(len, init) { diff --git a/jscomp/test/test_bs_this.js b/jscomp/test/test_bs_this.js index a2890643aa..6a4f7e4f05 100644 --- a/jscomp/test/test_bs_this.js +++ b/jscomp/test/test_bs_this.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function uux_this(x, y) { let o = this ; @@ -35,11 +36,11 @@ let js_obj = { }; function f(x) { - x.onload = (function () { + Curry._1(x.onload, (function () { let o = this ; console.log(o); - }); - return x.addEventListener("onload", (function () { + })); + return Curry._2(x.addEventListener, "onload", (function () { let o = this ; console.log(o.response); })); diff --git a/jscomp/test/test_bytes.js b/jscomp/test/test_bytes.js index b48ab6d8c8..9d625d0f65 100644 --- a/jscomp/test/test_bytes.js +++ b/jscomp/test/test_bytes.js @@ -3,9 +3,7 @@ let Bytes = require("../../lib/js/bytes.js"); -function f(v) { - return Bytes.unsafe_to_string(v); -} +let f = Bytes.unsafe_to_string; let ff = Bytes.to_string; diff --git a/jscomp/test/test_case_set.js b/jscomp/test/test_case_set.js index 7b74291121..9ef3c23702 100644 --- a/jscomp/test/test_case_set.js +++ b/jscomp/test/test_case_set.js @@ -1,13 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f(x) { - x.case = 3; + Curry._1(x.case, 3); } function g(x) { - return x.item(3); + return Curry._1(x.item, 3); } exports.f = f; diff --git a/jscomp/test/test_closure.js b/jscomp/test/test_closure.js index d19b24cb89..6cdfa5133e 100644 --- a/jscomp/test/test_closure.js +++ b/jscomp/test/test_closure.js @@ -2,6 +2,7 @@ 'use strict'; let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); let v = { @@ -23,7 +24,7 @@ function f() { let u = f(); $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), u); if (v.contents !== 45) { diff --git a/jscomp/test/test_cps.js b/jscomp/test/test_cps.js index f1dff037ec..4b1ecfd676 100644 --- a/jscomp/test/test_cps.js +++ b/jscomp/test/test_cps.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); function f(_n, _acc) { @@ -8,11 +9,11 @@ function f(_n, _acc) { let acc = _acc; let n = _n; if (n === 0) { - return acc(); + return Curry._1(acc, undefined); } _acc = (function () { console.log(String(n)); - return acc(); + return Curry._1(acc, undefined); }); _n = n - 1 | 0; continue; diff --git a/jscomp/test/test_demo.js b/jscomp/test/test_demo.js index 0724edaa9a..75af4c0fc1 100644 --- a/jscomp/test/test_demo.js +++ b/jscomp/test/test_demo.js @@ -2,6 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); function fib(x) { if (x === 2 || x === 1) { @@ -25,7 +26,7 @@ function map(f, x) { } else { return { TAG: "Cons", - _0: f(x._0), + _0: Curry._1(f, x._0), _1: map(f, x._1) }; } @@ -57,11 +58,7 @@ function g1(x, y) { }; } -let u = 8; - -let x = (function (z) { - return u + z | 0; -})(6); +let x = Curry._1(g(3, 5), 6); function v(extra) { let u = 7; diff --git a/jscomp/test/test_external.js b/jscomp/test/test_external.js index 6267a58ca0..13d3d54156 100644 --- a/jscomp/test/test_external.js +++ b/jscomp/test/test_external.js @@ -1,12 +1,13 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let xx = document(); alert("hehha"); -let b = ff("x")(3); +let b = Curry._1(ff("x"), 3); exports.xx = xx; exports.b = b; diff --git a/jscomp/test/test_fib.js b/jscomp/test/test_fib.js index ccc19ec289..1b6c660c76 100644 --- a/jscomp/test/test_fib.js +++ b/jscomp/test/test_fib.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function fib(x) { if (x === 0 || x === 1) { @@ -56,7 +57,7 @@ function map(f, x) { } else { return { TAG: "Cons", - _0: f(x._0), + _0: Curry._1(f, x._0), _1: map(f, x._1) }; } diff --git a/jscomp/test/test_for_loop.js b/jscomp/test/test_for_loop.js index 343bc858c5..9934349ded 100644 --- a/jscomp/test/test_for_loop.js +++ b/jscomp/test/test_for_loop.js @@ -2,6 +2,7 @@ 'use strict'; let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); function for_(x) { @@ -32,7 +33,7 @@ function for_3(x) { })); } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return v.contents; } @@ -54,7 +55,7 @@ function for_4(x) { })); } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return v.contents; } @@ -75,7 +76,7 @@ function for_5(x, u) { })); } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return v.contents; } @@ -111,7 +112,7 @@ function for_6(x, u) { } } $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); return v.contents; } diff --git a/jscomp/test/test_for_map.js b/jscomp/test/test_for_map.js index 6c0aa0b9e9..125d43872e 100644 --- a/jscomp/test/test_for_map.js +++ b/jscomp/test/test_for_map.js @@ -2,6 +2,7 @@ 'use strict'; let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); function height(param) { @@ -187,7 +188,7 @@ function find_first(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -202,7 +203,7 @@ function find_first(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -224,7 +225,7 @@ function find_first_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -239,7 +240,7 @@ function find_first_opt(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -265,7 +266,7 @@ function find_last(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -280,7 +281,7 @@ function find_last(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -302,7 +303,7 @@ function find_last_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -317,7 +318,7 @@ function find_last_opt(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -500,7 +501,7 @@ function remove(x, param) { function update(x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -520,7 +521,7 @@ function update(x, f, param) { let l = param.l; let c = Caml.int_compare(x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -561,7 +562,7 @@ function iter(f, _param) { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -572,7 +573,7 @@ function map(f, param) { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -590,7 +591,7 @@ function mapi(f, param) { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -609,7 +610,7 @@ function fold(f, _m, _accu) { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -621,7 +622,7 @@ function for_all(p, _param) { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -638,7 +639,7 @@ function exists(p, _param) { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -748,7 +749,7 @@ function merge$1(f, s1, s2) { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -766,7 +767,7 @@ function merge$1(f, s1, s2) { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } function union(f, s1, s2) { @@ -786,7 +787,7 @@ function union(f, s1, s2) { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -796,7 +797,7 @@ function union(f, s1, s2) { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -811,7 +812,7 @@ function filter(p, param) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -836,7 +837,7 @@ function partition(p, param) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -892,7 +893,7 @@ function compare(cmp, m1, m2) { if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -921,7 +922,7 @@ function equal(cmp, m1, m2) { if (e1._0 !== e2._0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); diff --git a/jscomp/test/test_google_closure.js b/jscomp/test/test_google_closure.js index 4867382b5a..5ca02ed7de 100644 --- a/jscomp/test/test_google_closure.js +++ b/jscomp/test/test_google_closure.js @@ -2,6 +2,7 @@ 'use strict'; let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); function f(a, b, param) { @@ -20,7 +21,7 @@ function f3(extra) { return 101; } -let b = f3(2); +let b = Curry._1(f3, 2); let arr = $$Array.init(2, (function (param) { return 0; @@ -28,7 +29,7 @@ let arr = $$Array.init(2, (function (param) { for(let i = 0; i <= 1; ++i){ let f3$1 = f2(i); - Caml_array.set(arr, i, f3$1(2)); + Caml_array.set(arr, i, Curry._1(f3$1, 2)); } console.log([ diff --git a/jscomp/test/test_list.js b/jscomp/test/test_list.js index 36532409f3..2822fd6b14 100644 --- a/jscomp/test/test_list.js +++ b/jscomp/test/test_list.js @@ -2,6 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Pervasives = require("../../lib/js/pervasives.js"); @@ -109,7 +110,7 @@ function map(f, x) { if (!x) { return /* [] */0; } - let r = f(x.hd); + let r = Curry._1(f, x.hd); return { hd: r, tl: map(f, x.tl) @@ -120,7 +121,7 @@ function mapi(i, f, x) { if (!x) { return /* [] */0; } - let r = f(i, x.hd); + let r = Curry._2(f, i, x.hd); return { hd: r, tl: mapi(i + 1 | 0, f, x.tl) @@ -142,7 +143,7 @@ function rev_map(f, l) { } _x = x.tl; _accu = { - hd: f(x.hd), + hd: Curry._1(f, x.hd), tl: accu }; continue; @@ -155,7 +156,7 @@ function iter(f, _x) { if (!x) { return; } - f(x.hd); + Curry._1(f, x.hd); _x = x.tl; continue; }; @@ -170,7 +171,7 @@ function iteri(f, l) { if (!x) { return; } - f(i, x.hd); + Curry._2(f, i, x.hd); _x = x.tl; _i = i + 1 | 0; continue; @@ -185,14 +186,14 @@ function fold_left(f, _accu, _l) { return accu; } _l = l.tl; - _accu = f(accu, l.hd); + _accu = Curry._2(f, accu, l.hd); continue; }; } function fold_right(f, l, accu) { if (l) { - return f(l.hd, fold_right(f, l.tl, accu)); + return Curry._2(f, l.hd, fold_right(f, l.tl, accu)); } else { return accu; } @@ -201,7 +202,7 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - let r = f(l1.hd, l2.hd); + let r = Curry._2(f, l1.hd, l2.hd); return { hd: r, tl: map2(f, l1.tl, l2.tl) @@ -238,7 +239,7 @@ function rev_map2(f, l1, l2) { _l2 = l2$1.tl; _l1 = l1$1.tl; _accu = { - hd: f(l1$1.hd, l2$1.hd), + hd: Curry._2(f, l1$1.hd, l2$1.hd), tl: accu }; continue; @@ -250,15 +251,15 @@ function rev_map2(f, l1, l2) { } }); } - if (!l2$1) { - return accu; + if (l2$1) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.rev_map2" - } - }); + return accu; }; } @@ -268,7 +269,7 @@ function iter2(f, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - f(l1.hd, l2.hd); + Curry._2(f, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -301,7 +302,7 @@ function fold_left2(f, _accu, _l1, _l2) { if (l2) { _l2 = l2.tl; _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); + _accu = Curry._3(f, accu, l1.hd, l2.hd); continue; } throw new Error("Invalid_argument", { @@ -311,22 +312,22 @@ function fold_left2(f, _accu, _l1, _l2) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_left2" - } - }); + return accu; }; } function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + return Curry._3(f, l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } throw new Error("Invalid_argument", { cause: { @@ -335,15 +336,15 @@ function fold_right2(f, l1, l2, accu) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2" - } - }); + return accu; } function for_all(p, _x) { @@ -352,7 +353,7 @@ function for_all(p, _x) { if (!x) { return true; } - if (!p(x.hd)) { + if (!Curry._1(p, x.hd)) { return false; } _x = x.tl; @@ -366,7 +367,7 @@ function exists(p, _x) { if (!x) { return false; } - if (p(x.hd)) { + if (Curry._1(p, x.hd)) { return true; } _x = x.tl; @@ -380,7 +381,7 @@ function for_all2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -412,7 +413,7 @@ function exists2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (p(l1.hd, l2.hd)) { + if (Curry._2(p, l1.hd, l2.hd)) { return true; } _l2 = l2.tl; @@ -569,7 +570,7 @@ function find(p, _x) { let x = _x; if (x) { let x$1 = x.hd; - if (p(x$1)) { + if (Curry._1(p, x$1)) { return x$1; } _x = x.tl; @@ -595,7 +596,7 @@ function find_all(p) { } let l = x.tl; let x$1 = x.hd; - if (p(x$1)) { + if (Curry._1(p, x$1)) { _x = l; _accu = { hd: x$1, @@ -625,7 +626,7 @@ function partition(p, l) { } let l$1 = x.tl; let x$1 = x.hd; - if (p(x$1)) { + if (Curry._1(p, x$1)) { _x = l$1; _yes = { hd: x$1, @@ -701,7 +702,7 @@ function merge(cmp, l1, l2) { } let h2 = l2.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { return { hd: h1, tl: merge(cmp, l1.tl, l2) @@ -750,8 +751,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { + if (Curry._2(cmp, x1, x2) <= 0) { + if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x1, tl: { @@ -762,7 +763,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x1, tl: { @@ -785,7 +786,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x2, tl: { @@ -796,7 +797,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) <= 0) { + } else if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x2, tl: { @@ -830,7 +831,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) <= 0) { + if (Curry._2(cmp, x1$1, x2$1) <= 0) { return { hd: x1$1, tl: { @@ -870,7 +871,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) > 0) { + if (Curry._2(cmp, h1, h2) > 0) { _accu = { hd: h1, tl: accu @@ -896,8 +897,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { + if (Curry._2(cmp, x1, x2) > 0) { + if (Curry._2(cmp, x2, x3) > 0) { return { hd: x1, tl: { @@ -908,7 +909,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x1, tl: { @@ -931,7 +932,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x2, tl: { @@ -942,7 +943,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) > 0) { + } else if (Curry._2(cmp, x2, x3) > 0) { return { hd: x2, tl: { @@ -976,7 +977,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) > 0) { + if (Curry._2(cmp, x1$1, x2$1) > 0) { return { hd: x1$1, tl: { @@ -1016,7 +1017,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { _accu = { hd: h1, tl: accu @@ -1051,9 +1052,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1078,7 +1079,7 @@ function sort_uniq(cmp, l) { } } if (c < 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1100,7 +1101,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1133,7 +1134,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1155,7 +1156,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1198,7 +1199,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1246,7 +1247,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, @@ -1282,9 +1283,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1309,7 +1310,7 @@ function sort_uniq(cmp, l) { } } if (c > 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1331,7 +1332,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1364,7 +1365,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1386,7 +1387,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1429,7 +1430,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1477,7 +1478,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, diff --git a/jscomp/test/test_match_exception.js b/jscomp/test/test_match_exception.js index 4fa365dee3..3e2ab2cf40 100644 --- a/jscomp/test/test_match_exception.js +++ b/jscomp/test/test_match_exception.js @@ -1,11 +1,12 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); function f(g, x) { try { - return g(x); + return Curry._1(g, x); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); diff --git a/jscomp/test/test_nested_print.js b/jscomp/test/test_nested_print.js index d74ed08696..a7e5bfb8d1 100644 --- a/jscomp/test/test_nested_print.js +++ b/jscomp/test/test_nested_print.js @@ -1,13 +1,14 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function u(x, x$1) { return x$1 + x$1 | 0; } function f(g, x) { - let u = g(x); + let u = Curry._1(g, x); return u + u | 0; } diff --git a/jscomp/test/test_per.js b/jscomp/test/test_per.js index 0f46ead324..5b471c91dc 100644 --- a/jscomp/test/test_per.js +++ b/jscomp/test/test_per.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_sys = require("../../lib/js/caml_sys.js"); let Caml_bytes = require("../../lib/js/caml_bytes.js"); @@ -442,17 +443,17 @@ let exit_function = { function at_exit(f) { let g = exit_function.contents; exit_function.contents = (function () { - f(); - g(); + Curry._1(f, undefined); + Curry._1(g, undefined); }); } function do_at_exit() { - exit_function.contents(); + Curry._1(exit_function.contents, undefined); } function exit(retcode) { - exit_function.contents(); + Curry._1(exit_function.contents, undefined); return Caml_sys.sys_exit(retcode); } diff --git a/jscomp/test/test_primitive.js b/jscomp/test/test_primitive.js index 7ac5a138b3..a61a29b06b 100644 --- a/jscomp/test/test_primitive.js +++ b/jscomp/test/test_primitive.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); let Caml_string = require("../../lib/js/caml_string.js"); let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); @@ -54,7 +55,7 @@ function u(b) { } function f2(h, b, param) { - return h(b ? 32 : 7); + return Curry._1(h, b ? 32 : 7); } Caml_array.set(v, 1, 3.0); diff --git a/jscomp/test/test_seq.js b/jscomp/test/test_seq.js index fe6bb57c1a..8d6b6861c6 100644 --- a/jscomp/test/test_seq.js +++ b/jscomp/test/test_seq.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Pervasives = require("../../lib/js/pervasives.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); @@ -49,7 +50,7 @@ function v(speclist) { } function f(g, speclist) { - return g(assoc3("-help", speclist)); + return Curry._1(g, assoc3("-help", speclist)); } function add_help(speclist) { diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index b20f62893c..064c3ee923 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -2,6 +2,7 @@ 'use strict'; let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); function Make(Ord) { let height = function (x) { @@ -100,7 +101,7 @@ function Make(Ord) { let r = x_._2; let v = x_._1; let l = x_._0; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return x_; } else if (c < 0) { @@ -230,7 +231,7 @@ function Make(Ord) { let r = x_._2; let v = x_._1; let l = x_._0; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return [ l, @@ -266,7 +267,7 @@ function Make(Ord) { if (typeof x_ !== "object") { return false; } - let c = Ord.compare(x, x_._1); + let c = Curry._2(Ord.compare, x, x_._1); if (c === 0) { return true; } @@ -281,7 +282,7 @@ function Make(Ord) { let r = x_._2; let v = x_._1; let l = x_._0; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return merge(l, r); } else if (c < 0) { @@ -381,7 +382,7 @@ function Make(Ord) { if (typeof e2 !== "object") { return 1; } - let c = Ord.compare(e1._0, e2._0); + let c = Curry._2(Ord.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -411,7 +412,7 @@ function Make(Ord) { } let r2 = s2._2; let l2 = s2._0; - let c = Ord.compare(v1, s2._1); + let c = Curry._2(Ord.compare, v1, s2._1); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -453,7 +454,7 @@ function Make(Ord) { return; } iter(f, x_._0); - f(x_._1); + Curry._1(f, x_._1); _x_ = x_._2; continue; }; @@ -465,7 +466,7 @@ function Make(Ord) { if (typeof s !== "object") { return accu; } - _accu = f(s._1, fold(f, s._0, accu)); + _accu = Curry._2(f, s._1, fold(f, s._0, accu)); _s = s._2; continue; }; @@ -476,7 +477,7 @@ function Make(Ord) { if (typeof x !== "object") { return true; } - if (!p(x._1)) { + if (!Curry._1(p, x._1)) { return false; } if (!for_all(p, x._0)) { @@ -492,7 +493,7 @@ function Make(Ord) { if (typeof x !== "object") { return false; } - if (p(x._1)) { + if (Curry._1(p, x._1)) { return true; } if (exists(p, x._0)) { @@ -508,7 +509,7 @@ function Make(Ord) { } let v = x._1; let l$p = filter(p, x._0); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, x._2); if (pv) { return join(l$p, v, r$p); @@ -527,7 +528,7 @@ function Make(Ord) { let match = partition(p, x._0); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, x._2); let rf = match$1[1]; let rt = match$1[0]; @@ -579,7 +580,7 @@ function Make(Ord) { }); } let v = x_._1; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return v; } diff --git a/jscomp/test/test_simple_ref.js b/jscomp/test/test_simple_ref.js index 3fd4056ff3..1aa08a2aae 100644 --- a/jscomp/test/test_simple_ref.js +++ b/jscomp/test/test_simple_ref.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let v = { contents: 0 @@ -24,7 +25,7 @@ let c = { let not_real_escape = a; function real_escape(f, v) { - return f(c); + return Curry._1(f, c); } let u = h; diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index 9aa866bb25..4c0b077ed7 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -2,6 +2,7 @@ 'use strict'; let Caml = require("../../lib/js/caml.js"); +let Curry = require("../../lib/js/curry.js"); function height(param) { if (typeof param !== "object") { @@ -158,7 +159,7 @@ function find(x, _param) { function timing(label, f) { console.time(label); - f(); + Curry._1(f, undefined); console.timeEnd(label); } diff --git a/jscomp/test/test_switch.js b/jscomp/test/test_switch.js index cf69436849..6cd0bab8e5 100644 --- a/jscomp/test/test_switch.js +++ b/jscomp/test/test_switch.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f(x) { if (typeof x !== "object") { @@ -27,7 +28,7 @@ function bind(x, f) { if (x.TAG === "Left") { return { TAG: "Left", - _0: f(x._0) + _0: Curry._1(f, x._0) }; } else { return x; diff --git a/jscomp/test/test_trywith.js b/jscomp/test/test_trywith.js index 1f81560003..8753b5e568 100644 --- a/jscomp/test/test_trywith.js +++ b/jscomp/test/test_trywith.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -14,7 +15,7 @@ let Sys_blocked_io = /* @__PURE__ */Caml_exceptions.create("Test_trywith.Sys_blo function ff(g, x) { try { - g(x); + Curry._1(g, x); } catch (raw_exn){ let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -26,7 +27,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$1){ let exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); @@ -38,7 +39,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$2){ let exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); @@ -50,7 +51,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$3){ let exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); @@ -62,7 +63,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$4){ let exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); @@ -74,7 +75,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$5){ let exn$5 = Caml_js_exceptions.internalToOCamlException(raw_exn$5); @@ -86,7 +87,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$6){ let exn$6 = Caml_js_exceptions.internalToOCamlException(raw_exn$6); @@ -98,7 +99,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$7){ let exn$7 = Caml_js_exceptions.internalToOCamlException(raw_exn$7); @@ -110,7 +111,7 @@ function ff(g, x) { } try { - g(x); + Curry._1(g, x); } catch (raw_exn$8){ let exn$8 = Caml_js_exceptions.internalToOCamlException(raw_exn$8); @@ -122,7 +123,7 @@ function ff(g, x) { } try { - return g(x); + return Curry._1(g, x); } catch (raw_exn$9){ let exn$9 = Caml_js_exceptions.internalToOCamlException(raw_exn$9); diff --git a/jscomp/test/test_type_based_arity.js b/jscomp/test/test_type_based_arity.js index 89fd9368c5..eb66db3e62 100644 --- a/jscomp/test/test_type_based_arity.js +++ b/jscomp/test/test_type_based_arity.js @@ -1,65 +1,66 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f0(g, x) { - return g(x); + return Curry._1(g, x); } function f1(g, x) { - g(x); + Curry._1(g, x); } let X = {}; function f2(g, x) { - return g(x); + return Curry._1(g, x); } function f3(g, x) { - g(x); + Curry._1(g, x); } function f4(g, x) { - return g(x); + return Curry._1(g, x); } function f5(g, x) { - return g(x); + return Curry._1(g, x); } function f6(g, x) { - return g(x); + return Curry._1(g, x); } function f7(g, x) { - return g(x); + return Curry._1(g, x); } let X0 = {}; function f8(g, x) { - return g(x); + return Curry._1(g, x); } function f9(g, x) { - return g(x); + return Curry._1(g, x); } function f10(g, x) { - return g(x); + return Curry._1(g, x); } function f11(g, x) { - return g(x); + return Curry._1(g, x); } function f12(g, x) { - return g(x); + return Curry._1(g, x); } function f13(g, x) { - return g(x); + return Curry._1(g, x); } let X2 = { @@ -67,7 +68,7 @@ let X2 = { }; function f14(h, g, x) { - h(g, x); + Curry._2(h, g, x); } exports.f0 = f0; diff --git a/jscomp/test/test_unsupported_primitive.js b/jscomp/test/test_unsupported_primitive.js index 9de4f418a1..ac85e30558 100644 --- a/jscomp/test/test_unsupported_primitive.js +++ b/jscomp/test/test_unsupported_primitive.js @@ -4,15 +4,15 @@ let Caml_external_polyfill = require("../../lib/js/caml_external_polyfill.js"); function to_buffer(buff, ofs, len, v, flags) { - if (!(ofs < 0 || len < 0 || ofs > (buff.length - len | 0))) { - return Caml_external_polyfill.resolve("caml_output_value_to_buffer")(buff, ofs, len, v, flags); + if (ofs < 0 || len < 0 || ofs > (buff.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.to_buffer: substring out of bounds" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Marshal.to_buffer: substring out of bounds" - } - }); + return Caml_external_polyfill.resolve("caml_output_value_to_buffer")(buff, ofs, len, v, flags); } exports.to_buffer = to_buffer; diff --git a/jscomp/test/test_while_closure.js b/jscomp/test/test_while_closure.js index ebca37f982..905541aea4 100644 --- a/jscomp/test/test_while_closure.js +++ b/jscomp/test/test_while_closure.js @@ -2,6 +2,7 @@ 'use strict'; let $$Array = require("../../lib/js/array.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_array = require("../../lib/js/caml_array.js"); let v = { @@ -26,7 +27,7 @@ function f() { f(); $$Array.iter((function (x) { - x(); + Curry._1(x, undefined); }), arr); console.log(String(v.contents)); diff --git a/jscomp/test/test_zero_nullable.js b/jscomp/test/test_zero_nullable.js index 72737d80b0..41bdcb3fb3 100644 --- a/jscomp/test/test_zero_nullable.js +++ b/jscomp/test/test_zero_nullable.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Caml_option = require("../../lib/js/caml_option.js"); let suites = { @@ -46,7 +47,7 @@ function f2(x) { } function f5(h, x) { - let u = h(32); + let u = Curry._1(h, 32); if (u !== null) { return u + 1 | 0; } else { @@ -55,7 +56,7 @@ function f5(h, x) { } function f4(h, x) { - let u = h(32); + let u = Curry._1(h, 32); let v = 32 + x | 0; if (u !== null) { return u + 1 | 0; @@ -131,7 +132,7 @@ function f2$1(x) { } function f5$1(h, x) { - let u = h(32); + let u = Curry._1(h, 32); if (u !== undefined) { return u + 1 | 0; } else { @@ -140,7 +141,7 @@ function f5$1(h, x) { } function f4$1(h, x) { - let u = h(32); + let u = Curry._1(h, 32); let v = 32 + x | 0; if (u !== undefined) { return u + 1 | 0; @@ -216,7 +217,7 @@ function f2$2(x) { } function f5$2(h, x) { - let u = h(32); + let u = Curry._1(h, 32); if (u == null) { return 3; } else { @@ -225,7 +226,7 @@ function f5$2(h, x) { } function f4$2(h, x) { - let u = h(32); + let u = Curry._1(h, 32); let v = 32 + x | 0; if (u == null) { return 1 + v | 0; diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index 80e119537a..58c91f9fd1 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -3,6 +3,7 @@ let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let $$String = require("../../lib/js/string.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Pervasives = require("../../lib/js/pervasives.js"); @@ -279,7 +280,7 @@ function find_first(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -294,7 +295,7 @@ function find_first(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -316,7 +317,7 @@ function find_first_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -331,7 +332,7 @@ function find_first_opt(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -357,7 +358,7 @@ function find_last(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -372,7 +373,7 @@ function find_last(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -394,7 +395,7 @@ function find_last_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -409,7 +410,7 @@ function find_last_opt(f, _param) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -592,7 +593,7 @@ function remove(x, param) { function update(x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -612,7 +613,7 @@ function update(x, f, param) { let l = param.l; let c = Caml_obj.compare(x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -653,7 +654,7 @@ function iter(f, _param) { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -664,7 +665,7 @@ function map(f, param) { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -682,7 +683,7 @@ function mapi(f, param) { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -701,7 +702,7 @@ function fold(f, _m, _accu) { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -713,7 +714,7 @@ function for_all(p, _param) { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -730,7 +731,7 @@ function exists(p, _param) { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -840,7 +841,7 @@ function merge$1(f, s1, s2) { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split$1(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -858,7 +859,7 @@ function merge$1(f, s1, s2) { } let v2 = s2.v; let match$1 = split$1(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } function union(f, s1, s2) { @@ -878,7 +879,7 @@ function union(f, s1, s2) { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -888,7 +889,7 @@ function union(f, s1, s2) { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -903,7 +904,7 @@ function filter(p, param) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -928,7 +929,7 @@ function partition(p, param) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -984,7 +985,7 @@ function compare(cmp, m1, m2) { if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -1013,7 +1014,7 @@ function equal(cmp, m1, m2) { if (!Caml_obj.equal(e1._0, e2._0)) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); @@ -1293,21 +1294,21 @@ function process_input_line(ticker_map, all_tickers, line) { if (match$4) { let match$5 = match$4.tl; if (match$5) { - if (!match$5.tl) { - return [ - { - hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), - tl: all_tickers - }, - ticker_map - ]; + if (match$5.tl) { + throw new Error("Failure", { + cause: { + RE_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } - throw new Error("Failure", { - cause: { - RE_EXN_ID: "Failure", - _1: "Invalid input line" - } - }); + return [ + { + hd: make_binary_op(ticker_name, match$4.hd, match$5.hd, "PLUS"), + tl: all_tickers + }, + ticker_map + ]; } throw new Error("Failure", { cause: { @@ -1327,21 +1328,21 @@ function process_input_line(ticker_map, all_tickers, line) { if (match$6) { let match$7 = match$6.tl; if (match$7) { - if (!match$7.tl) { - return [ - { - hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), - tl: all_tickers - }, - ticker_map - ]; + if (match$7.tl) { + throw new Error("Failure", { + cause: { + RE_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } - throw new Error("Failure", { - cause: { - RE_EXN_ID: "Failure", - _1: "Invalid input line" - } - }); + return [ + { + hd: make_binary_op(ticker_name, match$6.hd, match$7.hd, "MINUS"), + tl: all_tickers + }, + ticker_map + ]; } throw new Error("Failure", { cause: { @@ -1357,26 +1358,26 @@ function process_input_line(ticker_map, all_tickers, line) { } }); case "S" : - if (!match$3.tl) { - return [ - { - hd: { - value: undefined, - rank: "Uninitialized", - ticker_name: ticker_name, - type_: "Market" - }, - tl: all_tickers - }, - ticker_map - ]; + if (match$3.tl) { + throw new Error("Failure", { + cause: { + RE_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } - throw new Error("Failure", { - cause: { - RE_EXN_ID: "Failure", - _1: "Invalid input line" - } - }); + return [ + { + hd: { + value: undefined, + rank: "Uninitialized", + ticker_name: ticker_name, + type_: "Market" + }, + tl: all_tickers + }, + ticker_map + ]; default: throw new Error("Failure", { cause: { diff --git a/jscomp/test/to_string_test.js b/jscomp/test/to_string_test.js index 58bf0132ca..1e2099db17 100644 --- a/jscomp/test/to_string_test.js +++ b/jscomp/test/to_string_test.js @@ -4,9 +4,7 @@ let Mt = require("./mt.js"); let Pervasives = require("../../lib/js/pervasives.js"); -function ff(v) { - return Pervasives.string_of_float(v); -} +let ff = Pervasives.string_of_float; function f(v) { return String(v); diff --git a/jscomp/test/topsort_test.js b/jscomp/test/topsort_test.js index 8f6ce9ba4a..e624fc366f 100644 --- a/jscomp/test/topsort_test.js +++ b/jscomp/test/topsort_test.js @@ -3,6 +3,7 @@ let Caml = require("../../lib/js/caml.js"); let List = require("../../lib/js/list.js"); +let Curry = require("../../lib/js/curry.js"); let $$String = require("../../lib/js/string.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Pervasives = require("../../lib/js/pervasives.js"); @@ -409,21 +410,16 @@ function unsafe_topsort(graph) { let visited = { contents: /* [] */0 }; - let sort_nodes = function (nodes) { - List.iter((function (node) { - sort_node(node); - }), nodes); - }; let sort_node = function (node) { - if (!List.mem(node, visited.contents)) { - sort_nodes(nexts(node, graph)); - visited.contents = { - hd: node, - tl: visited.contents - }; + if (List.mem(node, visited.contents)) { return; } - + let nodes = nexts(node, graph); + List.iter(sort_node, nodes); + visited.contents = { + hd: node, + tl: visited.contents + }; }; List.iter((function (param) { sort_node(param[0]); @@ -980,7 +976,7 @@ function iter(f, _param) { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -993,7 +989,7 @@ function fold(f, _s, _accu) { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -1005,7 +1001,7 @@ function for_all(p, _param) { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -1022,7 +1018,7 @@ function exists(p, _param) { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -1041,7 +1037,7 @@ function filter(p, param) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -1065,7 +1061,7 @@ function partition(p, param) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -1141,7 +1137,7 @@ function find_first(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -1151,7 +1147,7 @@ function find_first(f, _param) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -1172,7 +1168,7 @@ function find_first_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -1182,7 +1178,7 @@ function find_first_opt(f, _param) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -1207,7 +1203,7 @@ function find_last(f, _param) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -1217,7 +1213,7 @@ function find_last(f, _param) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -1238,7 +1234,7 @@ function find_last_opt(f, _param) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -1248,7 +1244,7 @@ function find_last_opt(f, _param) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -1286,7 +1282,7 @@ function map(f, param) { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; diff --git a/jscomp/test/tramp_fib.js b/jscomp/test/tramp_fib.js index be13bb677f..e33d838404 100644 --- a/jscomp/test/tramp_fib.js +++ b/jscomp/test/tramp_fib.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let suites = { contents: /* [] */0 @@ -17,14 +18,14 @@ function eq(loc, x, y) { function fib(n, k) { if (n === 0 || n === 1) { - return k(1); + return Curry._1(k, 1); } else { return { TAG: "Suspend", _0: (function () { return fib(n - 1 | 0, (function (v0) { return fib(n - 2 | 0, (function (v1) { - return k(v0 + v1 | 0); + return Curry._1(k, v0 + v1 | 0); })); })); }) @@ -45,7 +46,7 @@ function iter(_bounce) { if (bounce.TAG === "Continue") { return bounce._0; } - _bounce = bounce._0(); + _bounce = Curry._1(bounce._0, undefined); continue; }; } diff --git a/jscomp/test/tuple_alloc.js b/jscomp/test/tuple_alloc.js index 412bddc78b..b664061415 100644 --- a/jscomp/test/tuple_alloc.js +++ b/jscomp/test/tuple_alloc.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let v = { contents: 0 @@ -27,14 +28,14 @@ function incr2() { } function f(a, b, d, e) { - let h = a(b); - let u = d(h); - let v = e(h); + let h = Curry._1(a, b); + let u = Curry._1(d, h); + let v = Curry._1(e, h); return u + v | 0; } function kf(cb, v) { - cb(v); + Curry._1(cb, v); return v + v | 0; } diff --git a/jscomp/test/type_disambiguate.js b/jscomp/test/type_disambiguate.js index 22dd58bcc4..c2c94901be 100644 --- a/jscomp/test/type_disambiguate.js +++ b/jscomp/test/type_disambiguate.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let N = {}; @@ -10,7 +11,7 @@ function f(e) { function f1(e) { let c = e.c; - return ((e.a + e.b | 0) + c | 0) + e.d(c) | 0; + return ((e.a + e.b | 0) + c | 0) + Curry._1(e.d, c) | 0; } exports.N = N; diff --git a/jscomp/test/unboxed_crash.js b/jscomp/test/unboxed_crash.js index f556f3b58a..96af2b0708 100644 --- a/jscomp/test/unboxed_crash.js +++ b/jscomp/test/unboxed_crash.js @@ -1,9 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function g(x) { - return x(x); + return Curry._1(x, x); } let loop = g(g); diff --git a/jscomp/test/unboxed_use_case.js b/jscomp/test/unboxed_use_case.js index a4b2d91ae6..45124f4231 100644 --- a/jscomp/test/unboxed_use_case.js +++ b/jscomp/test/unboxed_use_case.js @@ -1,12 +1,13 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); function map_pair(r, param) { return [ - r(param[0]), - r(param[1]) + Curry._1(r, param[0]), + Curry._1(r, param[1]) ]; } diff --git a/jscomp/test/uncurried_cast.js b/jscomp/test/uncurried_cast.js index 486ea7e6cc..56e3fa54c2 100644 --- a/jscomp/test/uncurried_cast.js +++ b/jscomp/test/uncurried_cast.js @@ -10,9 +10,7 @@ function raise(e) { }); } -function map(l, f) { - return Belt_List.mapU(l, f); -} +let map = Belt_List.mapU; let List = { map: map diff --git a/jscomp/test/uncurried_default.args.js b/jscomp/test/uncurried_default.args.js index 21822c00fe..7eb06af33c 100644 --- a/jscomp/test/uncurried_default.args.js +++ b/jscomp/test/uncurried_default.args.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function withOpt(xOpt, y) { let x = xOpt !== undefined ? xOpt : 1; @@ -10,11 +11,11 @@ function withOpt(xOpt, y) { }; } -let testWithOpt = withOpt(undefined, 3)(undefined, 4); +let testWithOpt = Curry._2(withOpt(undefined, 3), undefined, 4); -let partial = withOpt(10, 3)(4, 11); +let partial = Curry._2(withOpt(10, 3), 4, 11); -let total = withOpt(10, 3)(4, 11); +let total = Curry._2(withOpt(10, 3), 4, 11); function foo1(xOpt, y) { let x = xOpt !== undefined ? xOpt : 3; @@ -62,9 +63,9 @@ function withOpt$1(xOpt, y) { }; } -let testWithOpt$1 = withOpt$1(undefined, 3)(undefined, 4); +let testWithOpt$1 = Curry._2(withOpt$1(undefined, 3), undefined, 4); -let total$1 = withOpt$1(10, 3)(4, 11); +let total$1 = Curry._2(withOpt$1(10, 3), 4, 11); function foo1$1(xOpt, y) { let x = xOpt !== undefined ? xOpt : 3; @@ -92,7 +93,7 @@ function foo3$1(xOpt, yOpt, param) { } function foo(func) { - return func() + 1 | 0; + return Curry._1(func, undefined) + 1 | 0; } let M = { diff --git a/jscomp/test/uncurry_glob_test.js b/jscomp/test/uncurry_glob_test.js index cd2c5f391a..adb2b3035b 100644 --- a/jscomp/test/uncurry_glob_test.js +++ b/jscomp/test/uncurry_glob_test.js @@ -1,9 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function M(U) { - let v = U.f(100, "x"); + let v = Curry._2(U.f, 100, "x"); return { v: v }; @@ -14,11 +15,11 @@ function f() { } function $plus$great(a, h) { - return h(a); + return Curry._1(h, a); } function u(h) { - return h(3); + return Curry._1(h, 3); } exports.M = M; diff --git a/jscomp/test/uncurry_test.js b/jscomp/test/uncurry_test.js index 80632c7bcc..f4b1c0cb4a 100644 --- a/jscomp/test/uncurry_test.js +++ b/jscomp/test/uncurry_test.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); function f0() { return 0; @@ -34,7 +35,7 @@ function xx() { } function log2(logger, message, obj) { - logger.log2(message, obj); + Curry._2(logger.log2, message, obj); } exports.f0 = f0; diff --git a/jscomp/test/unsafe_ppx_test.js b/jscomp/test/unsafe_ppx_test.js index f0e9d4a747..2d053349d0 100644 --- a/jscomp/test/unsafe_ppx_test.js +++ b/jscomp/test/unsafe_ppx_test.js @@ -2,6 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); +let Curry = require("../../lib/js/curry.js"); let Pervasives = require("../../lib/js/pervasives.js"); let Ffi_js_test = require("./ffi_js_test.js"); @@ -24,30 +25,28 @@ function g(a) { }); let regression2 = Math.max; regression(a, Pervasives.failwith); - regression2(3, 2); - regression3(3, 2); - regression4(3, (function (x) { + Curry._2(regression2, 3, 2); + Curry._2(regression3, 3, 2); + Curry._2(regression4, 3, (function (x) { return x; })); } let max2 = Math.max; -function umax(a, b) { - return max2(a, b); -} +let umax = Curry.__2(max2); function u(h) { - return max2(3, h); + return Curry._2(max2, 3, h); } let max3 = Math.max; function uu(h) { - return max2(3, h); + return Curry._2(max2, 3, h); } -let empty = Object.keys(3); +let empty = Curry._1(Object.keys, 3); let v = $$test(1, 2); @@ -58,7 +57,7 @@ Mt.from_pair_suites("Unsafe_ppx_test", { return { TAG: "Eq", _0: 2, - _1: max(1, 2) + _1: Curry._2(max, 1, 2) }; }) ], @@ -80,7 +79,7 @@ Mt.from_pair_suites("Unsafe_ppx_test", { return { TAG: "Eq", _0: 2, - _1: Math.max(1, 2) + _1: Curry._2(Math.max, 1, 2) }; }) ], diff --git a/jscomp/test/variant.js b/jscomp/test/variant.js index 40c6abea1f..27a8b3a8d2 100644 --- a/jscomp/test/variant.js +++ b/jscomp/test/variant.js @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; +let Curry = require("../../lib/js/curry.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); @@ -115,7 +116,7 @@ let ED = /* @__PURE__ */Caml_exceptions.create("Variant.ED"); function fooExn(f) { try { - return f(); + return Curry._1(f, undefined); } catch (raw_n){ let n = Caml_js_exceptions.internalToOCamlException(raw_n); diff --git a/lib/es6/arg.js b/lib/es6/arg.js index c65c77c67f..dcefd7bd82 100644 --- a/lib/es6/arg.js +++ b/lib/es6/arg.js @@ -4,6 +4,7 @@ import * as Sys from "./sys.js"; import * as Caml from "./caml.js"; import * as List from "./list.js"; import * as $$Array from "./array.js"; +import * as Curry from "./curry.js"; import * as Buffer from "./buffer.js"; import * as $$String from "./string.js"; import * as Caml_obj from "./caml_obj.js"; @@ -336,12 +337,12 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let treat_action = function (f) { switch (f.TAG) { case "Unit" : - return f._0(); + return Curry._1(f._0, undefined); case "Bool" : let arg = get_arg(); let s$1 = bool_of_string_opt(arg); if (s$1 !== undefined) { - f._0(s$1); + Curry._1(f._0, s$1); } else { throw new Error(Stop, { cause: { @@ -366,7 +367,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist return; case "String" : let arg$1 = get_arg(); - f._0(arg$1); + Curry._1(f._0, arg$1); return consume_arg(); case "Set_string" : f._0.contents = get_arg(); @@ -375,7 +376,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let arg$2 = get_arg(); let x = int_of_string_opt(arg$2); if (x !== undefined) { - f._0(x); + Curry._1(f._0, x); } else { throw new Error(Stop, { cause: { @@ -413,7 +414,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let arg$4 = get_arg(); let x$2 = float_of_string_opt(arg$4); if (x$2 !== undefined) { - f._0(x$2); + Curry._1(f._0, x$2); } else { throw new Error(Stop, { cause: { @@ -453,7 +454,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let symb = f._0; let arg$6 = get_arg(); if (List.mem(arg$6, symb)) { - f._1(arg$6); + Curry._1(f._1, arg$6); return consume_arg(); } throw new Error(Stop, { @@ -470,7 +471,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist case "Rest" : let f$1 = f._0; while(current.contents < (argv.contents.length - 1 | 0)) { - f$1(Caml_array.get(argv.contents, current.contents + 1 | 0)); + Curry._1(f$1, Caml_array.get(argv.contents, current.contents + 1 | 0)); consume_arg(); }; return; @@ -484,7 +485,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist }); } let arg$7 = get_arg(); - let newarg = f._0(arg$7); + let newarg = Curry._1(f._0, arg$7); consume_arg(); let before = $$Array.sub(argv.contents, 0, current.contents + 1 | 0); let after = $$Array.sub(argv.contents, current.contents + 1 | 0, (argv.contents.length - current.contents | 0) - 1 | 0); @@ -504,7 +505,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist }; treat_action(match[0]); } else { - anonfun(s); + Curry._1(anonfun, s); } } catch (raw_m){ diff --git a/lib/es6/array.js b/lib/es6/array.js index 01edc6755a..9ca9bf4969 100644 --- a/lib/es6/array.js +++ b/lib/es6/array.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_obj from "./caml_obj.js"; import * as Caml_array from "./caml_array.js"; import * as Caml_exceptions from "./caml_exceptions.js"; @@ -21,9 +22,9 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f(0)); + let res = Caml_array.make(l, Curry._1(f, 0)); for(let i = 1; i < l; ++i){ - res[i] = f(i); + res[i] = Curry._1(f, i); } return res; } @@ -57,15 +58,15 @@ function append(a1, a2) { } function sub(a, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (a.length - len | 0))) { - return Caml_array.sub(a, ofs, len); + if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.sub" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); + return Caml_array.sub(a, ofs, len); } function fill(a, ofs, len, v) { @@ -83,20 +84,20 @@ function fill(a, ofs, len, v) { } function blit(a1, ofs1, a2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0))) { - return Caml_array.blit(a1, ofs1, a2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); + Caml_array.blit(a1, ofs1, a2, ofs2, len); } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } @@ -110,7 +111,7 @@ function iter2(f, a, b) { }); } for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i], b[i]); + Curry._2(f, a[i], b[i]); } } @@ -119,9 +120,9 @@ function map(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(a[0])); + let r = Caml_array.make(l, Curry._1(f, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(a[i]); + r[i] = Curry._1(f, a[i]); } return r; } @@ -140,16 +141,16 @@ function map2(f, a, b) { if (la === 0) { return []; } - let r = Caml_array.make(la, f(a[0], b[0])); + let r = Caml_array.make(la, Curry._2(f, a[0], b[0])); for(let i = 1; i < la; ++i){ - r[i] = f(a[i], b[i]); + r[i] = Curry._2(f, a[i], b[i]); } return r; } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -158,9 +159,9 @@ function mapi(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(0, a[0])); + let r = Caml_array.make(l, Curry._2(f, 0, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(i, a[i]); + r[i] = Curry._2(f, i, a[i]); } return r; } @@ -219,7 +220,7 @@ function of_list(param) { function fold_left(f, x, a) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } @@ -227,7 +228,7 @@ function fold_left(f, x, a) { function fold_right(f, a, x) { let r = x; for(let i = a.length - 1 | 0; i >= 0; --i){ - r = f(a[i], r); + r = Curry._2(f, a[i], r); } return r; } @@ -240,7 +241,7 @@ function exists(p, a) { if (i === n) { return false; } - if (p(a[i])) { + if (Curry._1(p, a[i])) { return true; } _i = i + 1 | 0; @@ -256,7 +257,7 @@ function for_all(p, a) { if (i === n) { return true; } - if (!p(a[i])) { + if (!Curry._1(p, a[i])) { return false; } _i = i + 1 | 0; @@ -303,15 +304,15 @@ function sort(cmp, a) { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { x = i31 + 1 | 0; } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { x = i31 + 2 | 0; } return x; } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if ((i31 + 1 | 0) < l && Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { return i31 + 1 | 0; } if (i31 < l) { @@ -330,7 +331,7 @@ function sort(cmp, a) { while(true) { let i$1 = _i; let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { + if (Curry._2(cmp, Caml_array.get(a, j), e) <= 0) { return Caml_array.set(a, i$1, e); } Caml_array.set(a, i$1, Caml_array.get(a, j)); @@ -385,7 +386,7 @@ function sort(cmp, a) { } }); } - if (cmp(Caml_array.get(a, father), e) >= 0) { + if (Curry._2(cmp, Caml_array.get(a, father), e) >= 0) { return Caml_array.set(a, i, e); } Caml_array.set(a, i, Caml_array.get(a, father)); @@ -428,7 +429,7 @@ function stable_sort(cmp, a) { let i2 = _i2; let s1 = _s1; let i1 = _i1; - if (cmp(s1, s2) <= 0) { + if (Curry._2(cmp, s1, s2) <= 0) { Caml_array.set(dst, d, s1); let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -454,7 +455,7 @@ function stable_sort(cmp, a) { for(let i = 0; i < len; ++i){ let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { + while(j >= dstofs && Curry._2(cmp, Caml_array.get(dst, j), e) > 0) { Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); j = j - 1 | 0; }; diff --git a/lib/es6/arrayLabels.js b/lib/es6/arrayLabels.js index a0d1264e04..c938c3b9b1 100644 --- a/lib/es6/arrayLabels.js +++ b/lib/es6/arrayLabels.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_obj from "./caml_obj.js"; import * as Caml_array from "./caml_array.js"; import * as Caml_exceptions from "./caml_exceptions.js"; @@ -21,9 +22,9 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f(0)); + let res = Caml_array.make(l, Curry._1(f, 0)); for(let i = 1; i < l; ++i){ - res[i] = f(i); + res[i] = Curry._1(f, i); } return res; } @@ -57,15 +58,15 @@ function append(a1, a2) { } function sub(a, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (a.length - len | 0))) { - return Caml_array.sub(a, ofs, len); + if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.sub" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); + return Caml_array.sub(a, ofs, len); } function fill(a, ofs, len, v) { @@ -83,20 +84,20 @@ function fill(a, ofs, len, v) { } function blit(a1, ofs1, a2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0))) { - return Caml_array.blit(a1, ofs1, a2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); + Caml_array.blit(a1, ofs1, a2, ofs2, len); } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } @@ -110,7 +111,7 @@ function iter2(f, a, b) { }); } for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i], b[i]); + Curry._2(f, a[i], b[i]); } } @@ -119,9 +120,9 @@ function map(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(a[0])); + let r = Caml_array.make(l, Curry._1(f, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(a[i]); + r[i] = Curry._1(f, a[i]); } return r; } @@ -140,16 +141,16 @@ function map2(f, a, b) { if (la === 0) { return []; } - let r = Caml_array.make(la, f(a[0], b[0])); + let r = Caml_array.make(la, Curry._2(f, a[0], b[0])); for(let i = 1; i < la; ++i){ - r[i] = f(a[i], b[i]); + r[i] = Curry._2(f, a[i], b[i]); } return r; } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -158,9 +159,9 @@ function mapi(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(0, a[0])); + let r = Caml_array.make(l, Curry._2(f, 0, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(i, a[i]); + r[i] = Curry._2(f, i, a[i]); } return r; } @@ -219,7 +220,7 @@ function of_list(param) { function fold_left(f, x, a) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } @@ -227,7 +228,7 @@ function fold_left(f, x, a) { function fold_right(f, a, x) { let r = x; for(let i = a.length - 1 | 0; i >= 0; --i){ - r = f(a[i], r); + r = Curry._2(f, a[i], r); } return r; } @@ -240,7 +241,7 @@ function exists(p, a) { if (i === n) { return false; } - if (p(a[i])) { + if (Curry._1(p, a[i])) { return true; } _i = i + 1 | 0; @@ -256,7 +257,7 @@ function for_all(p, a) { if (i === n) { return true; } - if (!p(a[i])) { + if (!Curry._1(p, a[i])) { return false; } _i = i + 1 | 0; @@ -303,15 +304,15 @@ function sort(cmp, a) { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { x = i31 + 1 | 0; } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { x = i31 + 2 | 0; } return x; } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if ((i31 + 1 | 0) < l && Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { return i31 + 1 | 0; } if (i31 < l) { @@ -330,7 +331,7 @@ function sort(cmp, a) { while(true) { let i$1 = _i; let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { + if (Curry._2(cmp, Caml_array.get(a, j), e) <= 0) { return Caml_array.set(a, i$1, e); } Caml_array.set(a, i$1, Caml_array.get(a, j)); @@ -385,7 +386,7 @@ function sort(cmp, a) { } }); } - if (cmp(Caml_array.get(a, father), e) >= 0) { + if (Curry._2(cmp, Caml_array.get(a, father), e) >= 0) { return Caml_array.set(a, i, e); } Caml_array.set(a, i, Caml_array.get(a, father)); @@ -428,7 +429,7 @@ function stable_sort(cmp, a) { let i2 = _i2; let s1 = _s1; let i1 = _i1; - if (cmp(s1, s2) <= 0) { + if (Curry._2(cmp, s1, s2) <= 0) { Caml_array.set(dst, d, s1); let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -454,7 +455,7 @@ function stable_sort(cmp, a) { for(let i = 0; i < len; ++i){ let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { + while(j >= dstofs && Curry._2(cmp, Caml_array.get(dst, j), e) > 0) { Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); j = j - 1 | 0; }; diff --git a/lib/es6/belt_Array.js b/lib/es6/belt_Array.js index 8a0069be35..58ddfcb68f 100644 --- a/lib/es6/belt_Array.js +++ b/lib/es6/belt_Array.js @@ -1,6 +1,7 @@ import * as Caml from "./caml.js"; +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function get(arr, i) { @@ -107,15 +108,13 @@ function makeByU(l, f) { } let res = new Array(l); for(let i = 0; i < l; ++i){ - res[i] = f(i); + res[i] = Curry._1(f, i); } return res; } function makeBy(l, f) { - return makeByU(l, (function (a) { - return f(a); - })); + return makeByU(l, Curry.__1(f)); } function makeByAndShuffleU(l, f) { @@ -125,9 +124,7 @@ function makeByAndShuffleU(l, f) { } function makeByAndShuffle(l, f) { - return makeByAndShuffleU(l, (function (a) { - return f(a); - })); + return makeByAndShuffleU(l, Curry.__1(f)); } function range(start, finish) { @@ -177,15 +174,13 @@ function zipByU(xs, ys, f) { let len = lenx < leny ? lenx : leny; let s = new Array(len); for(let i = 0; i < len; ++i){ - s[i] = f(xs[i], ys[i]); + s[i] = Curry._2(f, xs[i], ys[i]); } return s; } function zipBy(xs, ys, f) { - return zipByU(xs, ys, (function (a, b) { - return f(a, b); - })); + return zipByU(xs, ys, Curry.__2(f)); } function concat(a1, a2) { @@ -295,29 +290,25 @@ function blit(a1, ofs1, a2, ofs2, len) { function forEachU(a, f) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } function forEach(a, f) { - forEachU(a, (function (a) { - f(a); - })); + forEachU(a, Curry.__1(f)); } function mapU(a, f) { let l = a.length; let r = new Array(l); for(let i = 0; i < l; ++i){ - r[i] = f(a[i]); + r[i] = Curry._1(f, a[i]); } return r; } function map(a, f) { - return mapU(a, (function (a) { - return f(a); - })); + return mapU(a, Curry.__1(f)); } function flatMapU(a, f) { @@ -325,9 +316,7 @@ function flatMapU(a, f) { } function flatMap(a, f) { - return flatMapU(a, (function (a) { - return f(a); - })); + return concatMany(mapU(a, Curry.__1(f))); } function getByU(a, p) { @@ -336,7 +325,7 @@ function getByU(a, p) { let r; while(r === undefined && i < l) { let v = a[i]; - if (p(v)) { + if (Curry._1(p, v)) { r = Caml_option.some(v); } i = i + 1 | 0; @@ -345,9 +334,7 @@ function getByU(a, p) { } function getBy(a, p) { - return getByU(a, (function (a) { - return p(a); - })); + return getByU(a, Curry.__1(p)); } function getIndexByU(a, p) { @@ -356,7 +343,7 @@ function getIndexByU(a, p) { let r; while(r === undefined && i < l) { let v = a[i]; - if (p(v)) { + if (Curry._1(p, v)) { r = i; } i = i + 1 | 0; @@ -365,9 +352,7 @@ function getIndexByU(a, p) { } function getIndexBy(a, p) { - return getIndexByU(a, (function (a) { - return p(a); - })); + return getIndexByU(a, Curry.__1(p)); } function keepU(a, f) { @@ -376,7 +361,7 @@ function keepU(a, f) { let j = 0; for(let i = 0; i < l; ++i){ let v = a[i]; - if (f(v)) { + if (Curry._1(f, v)) { r[j] = v; j = j + 1 | 0; } @@ -387,9 +372,7 @@ function keepU(a, f) { } function keep(a, f) { - return keepU(a, (function (a) { - return f(a); - })); + return keepU(a, Curry.__1(f)); } function keepWithIndexU(a, f) { @@ -398,7 +381,7 @@ function keepWithIndexU(a, f) { let j = 0; for(let i = 0; i < l; ++i){ let v = a[i]; - if (f(v, i)) { + if (Curry._2(f, v, i)) { r[j] = v; j = j + 1 | 0; } @@ -409,9 +392,7 @@ function keepWithIndexU(a, f) { } function keepWithIndex(a, f) { - return keepWithIndexU(a, (function (a, i) { - return f(a, i); - })); + return keepWithIndexU(a, Curry.__2(f)); } function keepMapU(a, f) { @@ -420,7 +401,7 @@ function keepMapU(a, f) { let j = 0; for(let i = 0; i < l; ++i){ let v = a[i]; - let v$1 = f(v); + let v$1 = Curry._1(f, v); if (v$1 !== undefined) { r[j] = Caml_option.valFromOption(v$1); j = j + 1 | 0; @@ -432,93 +413,79 @@ function keepMapU(a, f) { } function keepMap(a, f) { - return keepMapU(a, (function (a) { - return f(a); - })); + return keepMapU(a, Curry.__1(f)); } function forEachWithIndexU(a, f) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } function forEachWithIndex(a, f) { - forEachWithIndexU(a, (function (a, b) { - f(a, b); - })); + forEachWithIndexU(a, Curry.__2(f)); } function mapWithIndexU(a, f) { let l = a.length; let r = new Array(l); for(let i = 0; i < l; ++i){ - r[i] = f(i, a[i]); + r[i] = Curry._2(f, i, a[i]); } return r; } function mapWithIndex(a, f) { - return mapWithIndexU(a, (function (a, b) { - return f(a, b); - })); + return mapWithIndexU(a, Curry.__2(f)); } function reduceU(a, x, f) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } function reduce(a, x, f) { - return reduceU(a, x, (function (a, b) { - return f(a, b); - })); + return reduceU(a, x, Curry.__2(f)); } function reduceReverseU(a, x, f) { let r = x; for(let i = a.length - 1 | 0; i >= 0; --i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } function reduceReverse(a, x, f) { - return reduceReverseU(a, x, (function (a, b) { - return f(a, b); - })); + return reduceReverseU(a, x, Curry.__2(f)); } function reduceReverse2U(a, b, x, f) { let r = x; let len = Caml.int_min(a.length, b.length); for(let i = len - 1 | 0; i >= 0; --i){ - r = f(r, a[i], b[i]); + r = Curry._3(f, r, a[i], b[i]); } return r; } function reduceReverse2(a, b, x, f) { - return reduceReverse2U(a, b, x, (function (a, b, c) { - return f(a, b, c); - })); + return reduceReverse2U(a, b, x, Curry.__3(f)); } function reduceWithIndexU(a, x, f) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i], i); + r = Curry._3(f, r, a[i], i); } return r; } function reduceWithIndex(a, x, f) { - return reduceWithIndexU(a, x, (function (a, b, c) { - return f(a, b, c); - })); + return reduceWithIndexU(a, x, Curry.__3(f)); } function everyU(arr, b) { @@ -529,7 +496,7 @@ function everyU(arr, b) { if (i === len) { return true; } - if (!b(arr[i])) { + if (!Curry._1(b, arr[i])) { return false; } _i = i + 1 | 0; @@ -538,9 +505,7 @@ function everyU(arr, b) { } function every(arr, f) { - return everyU(arr, (function (b) { - return f(b); - })); + return everyU(arr, Curry.__1(f)); } function someU(arr, b) { @@ -551,7 +516,7 @@ function someU(arr, b) { if (i === len) { return false; } - if (b(arr[i])) { + if (Curry._1(b, arr[i])) { return true; } _i = i + 1 | 0; @@ -560,9 +525,7 @@ function someU(arr, b) { } function some(arr, f) { - return someU(arr, (function (b) { - return f(b); - })); + return someU(arr, Curry.__1(f)); } function everyAux2(arr1, arr2, _i, b, len) { @@ -571,7 +534,7 @@ function everyAux2(arr1, arr2, _i, b, len) { if (i === len) { return true; } - if (!b(arr1[i], arr2[i])) { + if (!Curry._2(b, arr1[i], arr2[i])) { return false; } _i = i + 1 | 0; @@ -584,9 +547,7 @@ function every2U(a, b, p) { } function every2(a, b, p) { - return every2U(a, b, (function (a, b) { - return p(a, b); - })); + return every2U(a, b, Curry.__2(p)); } function some2U(a, b, p) { @@ -597,7 +558,7 @@ function some2U(a, b, p) { if (i === len) { return false; } - if (p(a[i], b[i])) { + if (Curry._2(p, a[i], b[i])) { return true; } _i = i + 1 | 0; @@ -606,9 +567,7 @@ function some2U(a, b, p) { } function some2(a, b, p) { - return some2U(a, b, (function (a, b) { - return p(a, b); - })); + return some2U(a, b, Curry.__2(p)); } function eqU(a, b, p) { @@ -622,9 +581,7 @@ function eqU(a, b, p) { } function eq(a, b, p) { - return eqU(a, b, (function (a, b) { - return p(a, b); - })); + return eqU(a, b, Curry.__2(p)); } function cmpU(a, b, p) { @@ -641,7 +598,7 @@ function cmpU(a, b, p) { if (i === lena) { return 0; } - let c = p(a[i], b[i]); + let c = Curry._2(p, a[i], b[i]); if (c !== 0) { return c; } @@ -652,9 +609,7 @@ function cmpU(a, b, p) { } function cmp(a, b, p) { - return cmpU(a, b, (function (a, b) { - return p(a, b); - })); + return cmpU(a, b, Curry.__2(p)); } function partitionU(a, f) { @@ -665,7 +620,7 @@ function partitionU(a, f) { let a2 = new Array(l); for(let ii = 0; ii < l; ++ii){ let v = a[ii]; - if (f(v)) { + if (Curry._1(f, v)) { a1[i] = v; i = i + 1 | 0; } else { @@ -682,9 +637,7 @@ function partitionU(a, f) { } function partition(a, f) { - return partitionU(a, (function (x) { - return f(x); - })); + return partitionU(a, Curry.__1(f)); } function unzip(a) { @@ -714,32 +667,28 @@ function joinWithU(a, sep, toString) { let res = _res; let i = _i; if (i === lastIndex) { - return res + toString(a[i]); + return res + Curry._1(toString, a[i]); } - _res = res + (toString(a[i]) + sep); + _res = res + (Curry._1(toString, a[i]) + sep); _i = i + 1 | 0; continue; }; } function joinWith(a, sep, toString) { - return joinWithU(a, sep, (function (x) { - return toString(x); - })); + return joinWithU(a, sep, Curry.__1(toString)); } function initU(n, f) { let v = new Array(n); for(let i = 0; i < n; ++i){ - v[i] = f(i); + v[i] = Curry._1(f, i); } return v; } function init(n, f) { - return initU(n, (function (i) { - return f(i); - })); + return initU(n, Curry.__1(f)); } export { diff --git a/lib/es6/belt_HashMap.js b/lib/es6/belt_HashMap.js index abefcddf27..6039cadba7 100644 --- a/lib/es6/belt_HashMap.js +++ b/lib/es6/belt_HashMap.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_internalBuckets from "./belt_internalBuckets.js"; import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; @@ -14,7 +15,7 @@ function copyBucketReHash(hash, h_buckets, ndata_tail, _old_bucket) { if (old_bucket === undefined) { return; } - let nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); + let nidx = Curry._1(hash, old_bucket.key) & (h_buckets.length - 1 | 0); let tail = ndata_tail[nidx]; if (tail !== undefined) { tail.next = old_bucket; @@ -30,7 +31,7 @@ function copyBucketReHash(hash, h_buckets, ndata_tail, _old_bucket) { function replaceInBucket(eq, key, info, _cell) { while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { cell.value = info; return false; } @@ -46,7 +47,7 @@ function replaceInBucket(eq, key, info, _cell) { function set0(h, key, value, eq, hash) { let h_buckets = h.buckets; let buckets_len = h_buckets.length; - let i = hash(key) & (buckets_len - 1 | 0); + let i = Curry._1(hash, key) & (buckets_len - 1 | 0); let l = h_buckets[i]; if (l !== undefined) { if (replaceInBucket(eq, key, value, l)) { @@ -97,13 +98,13 @@ function set(h, key, value) { function remove(h, key) { let h_buckets = h.buckets; - let i = h.hash(key) & (h_buckets.length - 1 | 0); + let i = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let bucket = h_buckets[i]; if (bucket === undefined) { return; } let eq = h.eq; - if (eq(bucket.key, key)) { + if (Curry._2(eq, bucket.key, key)) { h_buckets[i] = bucket.next; h.size = h.size - 1 | 0; return; @@ -117,7 +118,7 @@ function remove(h, key) { return; } let cell_next = bucket$1.next; - if (eq(bucket$1.key, key)) { + if (Curry._2(eq, bucket$1.key, key)) { prec.next = cell_next; h.size = h.size - 1 | 0; return; @@ -131,25 +132,25 @@ function remove(h, key) { function get(h, key) { let h_buckets = h.buckets; - let nid = h.hash(key) & (h_buckets.length - 1 | 0); + let nid = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let cell1 = h_buckets[nid]; if (cell1 === undefined) { return; } let eq = h.eq; - if (eq(key, cell1.key)) { + if (Curry._2(eq, key, cell1.key)) { return Caml_option.some(cell1.value); } let cell2 = cell1.next; if (cell2 === undefined) { return; } - if (eq(key, cell2.key)) { + if (Curry._2(eq, key, cell2.key)) { return Caml_option.some(cell2.value); } let cell3 = cell2.next; if (cell3 !== undefined) { - if (eq(key, cell3.key)) { + if (Curry._2(eq, key, cell3.key)) { return Caml_option.some(cell3.value); } else { let _buckets = cell3.next; @@ -158,7 +159,7 @@ function get(h, key) { if (buckets === undefined) { return; } - if (eq(key, buckets.key)) { + if (Curry._2(eq, key, buckets.key)) { return Caml_option.some(buckets.value); } _buckets = buckets.next; @@ -171,14 +172,14 @@ function get(h, key) { function has(h, key) { let h_buckets = h.buckets; - let nid = h.hash(key) & (h_buckets.length - 1 | 0); + let nid = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let bucket = h_buckets[nid]; if (bucket !== undefined) { let _cell = bucket; let eq = h.eq; while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { return true; } let nextCell = cell.next; diff --git a/lib/es6/belt_HashMapInt.js b/lib/es6/belt_HashMapInt.js index 905f88bcd7..2d1d6c8537 100644 --- a/lib/es6/belt_HashMapInt.js +++ b/lib/es6/belt_HashMapInt.js @@ -193,7 +193,7 @@ function size(h) { function fromArray(arr) { let len = arr.length; - let v = make(len); + let v = Belt_internalBucketsType.make(undefined, undefined, len); for(let i = 0; i < len; ++i){ let match = arr[i]; set(v, match[0], match[1]); diff --git a/lib/es6/belt_HashMapString.js b/lib/es6/belt_HashMapString.js index 041b2e8ace..c4352164cb 100644 --- a/lib/es6/belt_HashMapString.js +++ b/lib/es6/belt_HashMapString.js @@ -193,7 +193,7 @@ function size(h) { function fromArray(arr) { let len = arr.length; - let v = make(len); + let v = Belt_internalBucketsType.make(undefined, undefined, len); for(let i = 0; i < len; ++i){ let match = arr[i]; set(v, match[0], match[1]); diff --git a/lib/es6/belt_HashSet.js b/lib/es6/belt_HashSet.js index 78a9a88609..23b2a84a8e 100644 --- a/lib/es6/belt_HashSet.js +++ b/lib/es6/belt_HashSet.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_internalSetBuckets from "./belt_internalSetBuckets.js"; import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; @@ -9,7 +10,7 @@ function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { if (old_bucket === undefined) { return; } - let nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); + let nidx = Curry._1(hash, old_bucket.key) & (h_buckets.length - 1 | 0); let tail = ndata_tail[nidx]; if (tail !== undefined) { tail.next = old_bucket; @@ -25,13 +26,13 @@ function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { function remove(h, key) { let eq = h.eq; let h_buckets = h.buckets; - let i = h.hash(key) & (h_buckets.length - 1 | 0); + let i = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let l = h_buckets[i]; if (l === undefined) { return; } let next_cell = l.next; - if (eq(l.key, key)) { + if (Curry._2(eq, l.key, key)) { h.size = h.size - 1 | 0; h_buckets[i] = next_cell; return; @@ -42,7 +43,7 @@ function remove(h, key) { let cell = _cell; let prec = _prec; let cell_next = cell.next; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { prec.next = cell_next; h.size = h.size - 1 | 0; return; @@ -62,7 +63,7 @@ function remove(h, key) { function addBucket(h, key, _cell, eq) { while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { return; } let n = cell.next; @@ -82,7 +83,7 @@ function addBucket(h, key, _cell, eq) { function add0(h, key, hash, eq) { let h_buckets = h.buckets; let buckets_len = h_buckets.length; - let i = hash(key) & (buckets_len - 1 | 0); + let i = Curry._1(hash, key) & (buckets_len - 1 | 0); let l = h_buckets[i]; if (l !== undefined) { addBucket(h, key, l, eq); @@ -125,13 +126,13 @@ function add(h, key) { function has(h, key) { let eq = h.eq; let h_buckets = h.buckets; - let nid = h.hash(key) & (h_buckets.length - 1 | 0); + let nid = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let bucket = h_buckets[nid]; if (bucket !== undefined) { let _cell = bucket; while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { return true; } let nextCell = cell.next; diff --git a/lib/es6/belt_Id.js b/lib/es6/belt_Id.js index 562e578fb4..ff1ebbb299 100644 --- a/lib/es6/belt_Id.js +++ b/lib/es6/belt_Id.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; function MakeComparableU(M) { return M; @@ -7,9 +8,7 @@ function MakeComparableU(M) { function MakeComparable(M) { let cmp = M.cmp; - let cmp$1 = function (a, b) { - return cmp(a, b); - }; + let cmp$1 = Curry.__2(cmp); return { cmp: cmp$1 }; @@ -22,9 +21,7 @@ function comparableU(cmp) { } function comparable(cmp) { - let cmp$1 = function (a, b) { - return cmp(a, b); - }; + let cmp$1 = Curry.__2(cmp); return { cmp: cmp$1 }; @@ -36,13 +33,9 @@ function MakeHashableU(M) { function MakeHashable(M) { let hash = M.hash; - let hash$1 = function (a) { - return hash(a); - }; + let hash$1 = Curry.__1(hash); let eq = M.eq; - let eq$1 = function (a, b) { - return eq(a, b); - }; + let eq$1 = Curry.__2(eq); return { hash: hash$1, eq: eq$1 @@ -57,12 +50,8 @@ function hashableU(hash, eq) { } function hashable(hash, eq) { - let hash$1 = function (a) { - return hash(a); - }; - let eq$1 = function (a, b) { - return eq(a, b); - }; + let hash$1 = Curry.__1(hash); + let eq$1 = Curry.__2(eq); return { hash: hash$1, eq: eq$1 diff --git a/lib/es6/belt_List.js b/lib/es6/belt_List.js index e55399c63a..c3960a9084 100644 --- a/lib/es6/belt_List.js +++ b/lib/es6/belt_List.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_Array from "./belt_Array.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_SortArray from "./belt_SortArray.js"; @@ -112,7 +113,7 @@ function partitionAux(p, _cell, _precX, _precY) { hd: h, tl: /* [] */0 }; - if (p(h)) { + if (Curry._1(p, h)) { precX.tl = next; _precX = next; _cell = t; @@ -178,7 +179,7 @@ function copyAuxWitFilter(f, _cellX, _prec) { } let t = cellX.tl; let h = cellX.hd; - if (f(h)) { + if (Curry._1(f, h)) { let next = { hd: h, tl: /* [] */0 @@ -203,7 +204,7 @@ function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { } let t = cellX.tl; let h = cellX.hd; - if (f(h, i)) { + if (Curry._2(f, h, i)) { let next = { hd: h, tl: /* [] */0 @@ -228,7 +229,7 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { return; } let t = cellX.tl; - let h = f(cellX.hd); + let h = Curry._1(f, cellX.hd); if (h !== undefined) { let next = { hd: Caml_option.valFromOption(h), @@ -253,7 +254,7 @@ function removeAssocAuxWithMap(_cellX, x, _prec, f) { } let t = cellX.tl; let h = cellX.hd; - if (f(h[0], x)) { + if (Curry._2(f, h[0], x)) { prec.tl = t; return true; } @@ -277,7 +278,7 @@ function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { } let t = cellX.tl; let h = cellX.hd; - if (eq(h[0], x)) { + if (Curry._2(eq, h[0], x)) { prec.tl = { hd: [ x, @@ -306,7 +307,7 @@ function copyAuxWithMap(_cellX, _prec, f) { return; } let next = { - hd: f(cellX.hd), + hd: Curry._1(f, cellX.hd), tl: /* [] */0 }; prec.tl = next; @@ -354,7 +355,7 @@ function copyAuxWithMap2(f, _cellX, _cellY, _prec) { return; } let next = { - hd: f(cellX.hd, cellY.hd), + hd: Curry._2(f, cellX.hd, cellY.hd), tl: /* [] */0 }; prec.tl = next; @@ -374,7 +375,7 @@ function copyAuxWithMapI(f, _i, _cellX, _prec) { return; } let next = { - hd: f(i, cellX.hd), + hd: Curry._2(f, i, cellX.hd), tl: /* [] */0 }; prec.tl = next; @@ -518,7 +519,7 @@ function mapU(xs, f) { return /* [] */0; } let cell = { - hd: f(xs.hd), + hd: Curry._1(f, xs.hd), tl: /* [] */0 }; copyAuxWithMap(xs.tl, cell, f); @@ -526,9 +527,7 @@ function mapU(xs, f) { } function map(xs, f) { - return mapU(xs, (function (x) { - return f(x); - })); + return mapU(xs, Curry.__1(f)); } function zipByU(l1, l2, f) { @@ -539,7 +538,7 @@ function zipByU(l1, l2, f) { return /* [] */0; } let cell = { - hd: f(l1.hd, l2.hd), + hd: Curry._2(f, l1.hd, l2.hd), tl: /* [] */0 }; copyAuxWithMap2(f, l1.tl, l2.tl, cell); @@ -547,9 +546,7 @@ function zipByU(l1, l2, f) { } function zipBy(l1, l2, f) { - return zipByU(l1, l2, (function (x, y) { - return f(x, y); - })); + return zipByU(l1, l2, Curry.__2(f)); } function mapWithIndexU(xs, f) { @@ -557,7 +554,7 @@ function mapWithIndexU(xs, f) { return /* [] */0; } let cell = { - hd: f(0, xs.hd), + hd: Curry._2(f, 0, xs.hd), tl: /* [] */0 }; copyAuxWithMapI(f, 1, xs.tl, cell); @@ -565,9 +562,7 @@ function mapWithIndexU(xs, f) { } function mapWithIndex(xs, f) { - return mapWithIndexU(xs, (function (i, x) { - return f(i, x); - })); + return mapWithIndexU(xs, Curry.__2(f)); } function makeByU(n, f) { @@ -575,14 +570,14 @@ function makeByU(n, f) { return /* [] */0; } let headX = { - hd: f(0), + hd: Curry._1(f, 0), tl: /* [] */0 }; let cur = headX; let i = 1; while(i < n) { let v = { - hd: f(i), + hd: Curry._1(f, i), tl: /* [] */0 }; cur.tl = v; @@ -593,9 +588,7 @@ function makeByU(n, f) { } function makeBy(n, f) { - return makeByU(n, (function (x) { - return f(x); - })); + return makeByU(n, Curry.__1(f)); } function make(n, v) { @@ -761,7 +754,7 @@ function mapReverseU(l, f) { } _xs = xs.tl; _accu = { - hd: f(xs.hd), + hd: Curry._1(f, xs.hd), tl: accu }; continue; @@ -769,9 +762,7 @@ function mapReverseU(l, f) { } function mapReverse(l, f) { - return mapReverseU(l, (function (x) { - return f(x); - })); + return mapReverseU(l, Curry.__1(f)); } function forEachU(_xs, f) { @@ -780,16 +771,14 @@ function forEachU(_xs, f) { if (!xs) { return; } - f(xs.hd); + Curry._1(f, xs.hd); _xs = xs.tl; continue; }; } function forEach(xs, f) { - forEachU(xs, (function (x) { - return f(x); - })); + forEachU(xs, Curry.__1(f)); } function forEachWithIndexU(l, f) { @@ -801,7 +790,7 @@ function forEachWithIndexU(l, f) { if (!xs) { return; } - f(i, xs.hd); + Curry._2(f, i, xs.hd); _i = i + 1 | 0; _xs = xs.tl; continue; @@ -809,9 +798,7 @@ function forEachWithIndexU(l, f) { } function forEachWithIndex(l, f) { - forEachWithIndexU(l, (function (i, x) { - return f(i, x); - })); + forEachWithIndexU(l, Curry.__2(f)); } function reduceU(_l, _accu, f) { @@ -821,21 +808,19 @@ function reduceU(_l, _accu, f) { if (!l) { return accu; } - _accu = f(accu, l.hd); + _accu = Curry._2(f, accu, l.hd); _l = l.tl; continue; }; } function reduce(l, accu, f) { - return reduceU(l, accu, (function (acc, x) { - return f(acc, x); - })); + return reduceU(l, accu, Curry.__2(f)); } function reduceReverseUnsafeU(l, accu, f) { if (l) { - return f(reduceReverseUnsafeU(l.tl, accu, f), l.hd); + return Curry._2(f, reduceReverseUnsafeU(l.tl, accu, f), l.hd); } else { return accu; } @@ -851,9 +836,7 @@ function reduceReverseU(l, acc, f) { } function reduceReverse(l, accu, f) { - return reduceReverseU(l, accu, (function (a, b) { - return f(a, b); - })); + return reduceReverseU(l, accu, Curry.__2(f)); } function reduceWithIndexU(l, acc, f) { @@ -868,16 +851,14 @@ function reduceWithIndexU(l, acc, f) { return acc$1; } _i = i + 1 | 0; - _acc = f(acc$1, l$1.hd, i); + _acc = Curry._3(f, acc$1, l$1.hd, i); _l = l$1.tl; continue; }; } function reduceWithIndex(l, acc, f) { - return reduceWithIndexU(l, acc, (function (acc, x, i) { - return f(acc, x, i); - })); + return reduceWithIndexU(l, acc, Curry.__3(f)); } function mapReverse2U(l1, l2, f) { @@ -895,7 +876,7 @@ function mapReverse2U(l1, l2, f) { return accu; } _accu = { - hd: f(l1$1.hd, l2$1.hd), + hd: Curry._2(f, l1$1.hd, l2$1.hd), tl: accu }; _l2 = l2$1.tl; @@ -905,9 +886,7 @@ function mapReverse2U(l1, l2, f) { } function mapReverse2(l1, l2, f) { - return mapReverse2U(l1, l2, (function (a, b) { - return f(a, b); - })); + return mapReverse2U(l1, l2, Curry.__2(f)); } function forEach2U(_l1, _l2, f) { @@ -920,7 +899,7 @@ function forEach2U(_l1, _l2, f) { if (!l2) { return; } - f(l1.hd, l2.hd); + Curry._2(f, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -928,9 +907,7 @@ function forEach2U(_l1, _l2, f) { } function forEach2(l1, l2, f) { - forEach2U(l1, l2, (function (a, b) { - return f(a, b); - })); + forEach2U(l1, l2, Curry.__2(f)); } function reduce2U(_l1, _l2, _accu, f) { @@ -944,7 +921,7 @@ function reduce2U(_l1, _l2, _accu, f) { if (!l2) { return accu; } - _accu = f(accu, l1.hd, l2.hd); + _accu = Curry._3(f, accu, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -952,14 +929,12 @@ function reduce2U(_l1, _l2, _accu, f) { } function reduce2(l1, l2, acc, f) { - return reduce2U(l1, l2, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduce2U(l1, l2, acc, Curry.__3(f)); } function reduceReverse2UnsafeU(l1, l2, accu, f) { if (l1 && l2) { - return f(reduceReverse2UnsafeU(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); + return Curry._3(f, reduceReverse2UnsafeU(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); } else { return accu; } @@ -975,9 +950,7 @@ function reduceReverse2U(l1, l2, acc, f) { } function reduceReverse2(l1, l2, acc, f) { - return reduceReverse2U(l1, l2, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceReverse2U(l1, l2, acc, Curry.__3(f)); } function everyU(_xs, p) { @@ -986,7 +959,7 @@ function everyU(_xs, p) { if (!xs) { return true; } - if (!p(xs.hd)) { + if (!Curry._1(p, xs.hd)) { return false; } _xs = xs.tl; @@ -995,9 +968,7 @@ function everyU(_xs, p) { } function every(xs, p) { - return everyU(xs, (function (x) { - return p(x); - })); + return everyU(xs, Curry.__1(p)); } function someU(_xs, p) { @@ -1006,7 +977,7 @@ function someU(_xs, p) { if (!xs) { return false; } - if (p(xs.hd)) { + if (Curry._1(p, xs.hd)) { return true; } _xs = xs.tl; @@ -1015,9 +986,7 @@ function someU(_xs, p) { } function some(xs, p) { - return someU(xs, (function (x) { - return p(x); - })); + return someU(xs, Curry.__1(p)); } function every2U(_l1, _l2, p) { @@ -1030,7 +999,7 @@ function every2U(_l1, _l2, p) { if (!l2) { return true; } - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -1040,9 +1009,7 @@ function every2U(_l1, _l2, p) { } function every2(l1, l2, p) { - return every2U(l1, l2, (function (a, b) { - return p(a, b); - })); + return every2U(l1, l2, Curry.__2(p)); } function cmpByLength(_l1, _l2) { @@ -1079,7 +1046,7 @@ function cmpU(_l1, _l2, p) { if (!l2) { return 1; } - let c = p(l1.hd, l2.hd); + let c = Curry._2(p, l1.hd, l2.hd); if (c !== 0) { return c; } @@ -1090,9 +1057,7 @@ function cmpU(_l1, _l2, p) { } function cmp(l1, l2, f) { - return cmpU(l1, l2, (function (x, y) { - return f(x, y); - })); + return cmpU(l1, l2, Curry.__2(f)); } function eqU(_l1, _l2, p) { @@ -1109,7 +1074,7 @@ function eqU(_l1, _l2, p) { if (!l2) { return false; } - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -1119,9 +1084,7 @@ function eqU(_l1, _l2, p) { } function eq(l1, l2, f) { - return eqU(l1, l2, (function (x, y) { - return f(x, y); - })); + return eqU(l1, l2, Curry.__2(f)); } function some2U(_l1, _l2, p) { @@ -1134,7 +1097,7 @@ function some2U(_l1, _l2, p) { if (!l2) { return false; } - if (p(l1.hd, l2.hd)) { + if (Curry._2(p, l1.hd, l2.hd)) { return true; } _l2 = l2.tl; @@ -1144,9 +1107,7 @@ function some2U(_l1, _l2, p) { } function some2(l1, l2, p) { - return some2U(l1, l2, (function (a, b) { - return p(a, b); - })); + return some2U(l1, l2, Curry.__2(p)); } function hasU(_xs, x, eq) { @@ -1155,7 +1116,7 @@ function hasU(_xs, x, eq) { if (!xs) { return false; } - if (eq(xs.hd, x)) { + if (Curry._2(eq, xs.hd, x)) { return true; } _xs = xs.tl; @@ -1164,9 +1125,7 @@ function hasU(_xs, x, eq) { } function has(xs, x, eq) { - return hasU(xs, x, (function (a, b) { - return eq(a, b); - })); + return hasU(xs, x, Curry.__2(eq)); } function getAssocU(_xs, x, eq) { @@ -1176,7 +1135,7 @@ function getAssocU(_xs, x, eq) { return; } let match = xs.hd; - if (eq(match[0], x)) { + if (Curry._2(eq, match[0], x)) { return Caml_option.some(match[1]); } _xs = xs.tl; @@ -1185,9 +1144,7 @@ function getAssocU(_xs, x, eq) { } function getAssoc(xs, x, eq) { - return getAssocU(xs, x, (function (a, b) { - return eq(a, b); - })); + return getAssocU(xs, x, Curry.__2(eq)); } function hasAssocU(_xs, x, eq) { @@ -1196,7 +1153,7 @@ function hasAssocU(_xs, x, eq) { if (!xs) { return false; } - if (eq(xs.hd[0], x)) { + if (Curry._2(eq, xs.hd[0], x)) { return true; } _xs = xs.tl; @@ -1205,9 +1162,7 @@ function hasAssocU(_xs, x, eq) { } function hasAssoc(xs, x, eq) { - return hasAssocU(xs, x, (function (a, b) { - return eq(a, b); - })); + return hasAssocU(xs, x, Curry.__2(eq)); } function removeAssocU(xs, x, eq) { @@ -1216,7 +1171,7 @@ function removeAssocU(xs, x, eq) { } let l = xs.tl; let pair = xs.hd; - if (eq(pair[0], x)) { + if (Curry._2(eq, pair[0], x)) { return l; } let cell = { @@ -1232,9 +1187,7 @@ function removeAssocU(xs, x, eq) { } function removeAssoc(xs, x, eq) { - return removeAssocU(xs, x, (function (a, b) { - return eq(a, b); - })); + return removeAssocU(xs, x, Curry.__2(eq)); } function setAssocU(xs, x, k, eq) { @@ -1249,7 +1202,7 @@ function setAssocU(xs, x, k, eq) { } let l = xs.tl; let pair = xs.hd; - if (eq(pair[0], x)) { + if (Curry._2(eq, pair[0], x)) { return { hd: [ x, @@ -1277,9 +1230,7 @@ function setAssocU(xs, x, k, eq) { } function setAssoc(xs, x, k, eq) { - return setAssocU(xs, x, k, (function (a, b) { - return eq(a, b); - })); + return setAssocU(xs, x, k, Curry.__2(eq)); } function sortU(xs, cmp) { @@ -1289,9 +1240,7 @@ function sortU(xs, cmp) { } function sort(xs, cmp) { - return sortU(xs, (function (x, y) { - return cmp(x, y); - })); + return sortU(xs, Curry.__2(cmp)); } function getByU(_xs, p) { @@ -1301,7 +1250,7 @@ function getByU(_xs, p) { return; } let x = xs.hd; - if (p(x)) { + if (Curry._1(p, x)) { return Caml_option.some(x); } _xs = xs.tl; @@ -1310,9 +1259,7 @@ function getByU(_xs, p) { } function getBy(xs, p) { - return getByU(xs, (function (a) { - return p(a); - })); + return getByU(xs, Curry.__1(p)); } function keepU(_xs, p) { @@ -1323,7 +1270,7 @@ function keepU(_xs, p) { } let t = xs.tl; let h = xs.hd; - if (p(h)) { + if (Curry._1(p, h)) { let cell = { hd: h, tl: /* [] */0 @@ -1337,9 +1284,7 @@ function keepU(_xs, p) { } function keep(xs, p) { - return keepU(xs, (function (x) { - return p(x); - })); + return keepU(xs, Curry.__1(p)); } function keepWithIndexU(xs, p) { @@ -1353,7 +1298,7 @@ function keepWithIndexU(xs, p) { } let t = xs$1.tl; let h = xs$1.hd; - if (p(h, i)) { + if (Curry._2(p, h, i)) { let cell = { hd: h, tl: /* [] */0 @@ -1368,9 +1313,7 @@ function keepWithIndexU(xs, p) { } function keepWithIndex(xs, p) { - return keepWithIndexU(xs, (function (x, i) { - return p(x, i); - })); + return keepWithIndexU(xs, Curry.__2(p)); } function keepMapU(_xs, p) { @@ -1380,7 +1323,7 @@ function keepMapU(_xs, p) { return /* [] */0; } let t = xs.tl; - let h = p(xs.hd); + let h = Curry._1(p, xs.hd); if (h !== undefined) { let cell = { hd: Caml_option.valFromOption(h), @@ -1395,9 +1338,7 @@ function keepMapU(_xs, p) { } function keepMap(xs, p) { - return keepMapU(xs, (function (x) { - return p(x); - })); + return keepMapU(xs, Curry.__1(p)); } function partitionU(l, p) { @@ -1416,7 +1357,7 @@ function partitionU(l, p) { hd: h, tl: /* [] */0 }; - let b = p(h); + let b = Curry._1(p, h); partitionAux(p, l.tl, nextX, nextY); if (b) { return [ @@ -1432,9 +1373,7 @@ function partitionU(l, p) { } function partition(l, p) { - return partitionU(l, (function (x) { - return p(x); - })); + return partitionU(l, Curry.__1(p)); } function unzip(xs) { diff --git a/lib/es6/belt_Map.js b/lib/es6/belt_Map.js index 9c811ba7fe..8234a5b949 100644 --- a/lib/es6/belt_Map.js +++ b/lib/es6/belt_Map.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_MapDict from "./belt_MapDict.js"; function fromArray(data, id) { @@ -58,9 +59,7 @@ function updateU(m, key, f) { } function update(m, key, f) { - return updateU(m, key, (function (a) { - return f(a); - })); + return updateU(m, key, Curry.__1(f)); } function split(m, x) { @@ -91,9 +90,7 @@ function mergeU(s1, s2, f) { } function merge(s1, s2, f) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - })); + return mergeU(s1, s2, Curry.__3(f)); } function make(id) { @@ -112,9 +109,7 @@ function findFirstByU(m, f) { } function findFirstBy(m, f) { - return findFirstByU(m, (function (a, b) { - return f(a, b); - })); + return Belt_MapDict.findFirstByU(m.data, Curry.__2(f)); } function forEachU(m, f) { @@ -122,9 +117,7 @@ function forEachU(m, f) { } function forEach(m, f) { - forEachU(m, (function (a, b) { - f(a, b); - })); + Belt_MapDict.forEachU(m.data, Curry.__2(f)); } function reduceU(m, acc, f) { @@ -132,9 +125,7 @@ function reduceU(m, acc, f) { } function reduce(m, acc, f) { - return reduceU(m, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(m, acc, Curry.__3(f)); } function everyU(m, f) { @@ -142,9 +133,7 @@ function everyU(m, f) { } function every(m, f) { - return everyU(m, (function (a, b) { - return f(a, b); - })); + return Belt_MapDict.everyU(m.data, Curry.__2(f)); } function someU(m, f) { @@ -152,9 +141,7 @@ function someU(m, f) { } function some(m, f) { - return someU(m, (function (a, b) { - return f(a, b); - })); + return Belt_MapDict.someU(m.data, Curry.__2(f)); } function keepU(m, f) { @@ -165,9 +152,7 @@ function keepU(m, f) { } function keep(m, f) { - return keepU(m, (function (a, b) { - return f(a, b); - })); + return keepU(m, Curry.__2(f)); } function partitionU(m, p) { @@ -186,9 +171,7 @@ function partitionU(m, p) { } function partition(m, p) { - return partitionU(m, (function (a, b) { - return p(a, b); - })); + return partitionU(m, Curry.__2(p)); } function mapU(m, f) { @@ -199,9 +182,7 @@ function mapU(m, f) { } function map(m, f) { - return mapU(m, (function (a) { - return f(a); - })); + return mapU(m, Curry.__1(f)); } function mapWithKeyU(m, f) { @@ -212,9 +193,7 @@ function mapWithKeyU(m, f) { } function mapWithKey(m, f) { - return mapWithKeyU(m, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(m, Curry.__2(f)); } function size(map) { @@ -298,9 +277,7 @@ function eqU(m1, m2, veq) { } function eq(m1, m2, veq) { - return eqU(m1, m2, (function (a, b) { - return veq(a, b); - })); + return eqU(m1, m2, Curry.__2(veq)); } function cmpU(m1, m2, vcmp) { @@ -308,9 +285,7 @@ function cmpU(m1, m2, vcmp) { } function cmp(m1, m2, vcmp) { - return cmpU(m1, m2, (function (a, b) { - return vcmp(a, b); - })); + return cmpU(m1, m2, Curry.__2(vcmp)); } function getData(m) { diff --git a/lib/es6/belt_MapDict.js b/lib/es6/belt_MapDict.js index ad544897de..29f3f5cdc5 100644 --- a/lib/es6/belt_MapDict.js +++ b/lib/es6/belt_MapDict.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; @@ -8,7 +9,7 @@ function set(t, newK, newD, cmp) { return Belt_internalAVLtree.singleton(newK, newD); } let k = t.k; - let c = cmp(newK, k); + let c = Curry._2(cmp, newK, k); if (c === 0) { return Belt_internalAVLtree.updateValue(t, newD); } @@ -25,9 +26,9 @@ function set(t, newK, newD, cmp) { function updateU(t, newK, f, cmp) { if (t !== undefined) { let k = t.k; - let c = cmp(newK, k); + let c = Curry._2(cmp, newK, k); if (c === 0) { - let newD = f(Caml_option.some(t.v)); + let newD = Curry._1(f, Caml_option.some(t.v)); if (newD !== undefined) { return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(newD)); } @@ -66,7 +67,7 @@ function updateU(t, newK, f, cmp) { return Belt_internalAVLtree.bal(l$1, k, v, rr); } } - let newD$1 = f(undefined); + let newD$1 = Curry._1(f, undefined); if (newD$1 !== undefined) { return Belt_internalAVLtree.singleton(newK, Caml_option.valFromOption(newD$1)); } else { @@ -75,16 +76,14 @@ function updateU(t, newK, f, cmp) { } function update(t, newK, f, cmp) { - return updateU(t, newK, (function (a) { - return f(a); - }), cmp); + return updateU(t, newK, Curry.__1(f), cmp); } function removeAux0(n, x, cmp) { let v = n.k; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { if (l === undefined) { return r; @@ -145,7 +144,7 @@ function splitAuxPivot(n, x, pres, cmp) { let d = n.v; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { pres.contents = Caml_option.some(d); return [ @@ -203,7 +202,7 @@ function mergeU(s1, s2, f, cmp) { if (s1 === undefined) { if (s2 !== undefined) { return Belt_internalAVLtree.keepMapU(s2, (function (k, v) { - return f(k, undefined, Caml_option.some(v)); + return Curry._3(f, k, undefined, Caml_option.some(v)); })); } else { return; @@ -211,7 +210,7 @@ function mergeU(s1, s2, f, cmp) { } if (s2 === undefined) { return Belt_internalAVLtree.keepMapU(s1, (function (k, v) { - return f(k, Caml_option.some(v), undefined); + return Curry._3(f, k, Caml_option.some(v), undefined); })); } if (s1.h >= s2.h) { @@ -225,7 +224,7 @@ function mergeU(s1, s2, f, cmp) { let match = splitAuxPivot(s2, v1, d2, cmp); let d2$1 = d2.contents; let newLeft = mergeU(l1, match[0], f, cmp); - let newD = f(v1, Caml_option.some(d1), d2$1); + let newD = Curry._3(f, v1, Caml_option.some(d1), d2$1); let newRight = mergeU(r1, match[1], f, cmp); return Belt_internalAVLtree.concatOrJoin(newLeft, v1, newD, newRight); } @@ -239,15 +238,13 @@ function mergeU(s1, s2, f, cmp) { let match$1 = splitAuxPivot(s1, v2, d1$1, cmp); let d1$2 = d1$1.contents; let newLeft$1 = mergeU(match$1[0], l2, f, cmp); - let newD$1 = f(v2, d1$2, Caml_option.some(d2$2)); + let newD$1 = Curry._3(f, v2, d1$2, Caml_option.some(d2$2)); let newRight$1 = mergeU(match$1[1], r2, f, cmp); return Belt_internalAVLtree.concatOrJoin(newLeft$1, v2, newD$1, newRight$1); } function merge(s1, s2, f, cmp) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - }), cmp); + return mergeU(s1, s2, Curry.__3(f), cmp); } function removeMany(t, keys, cmp) { diff --git a/lib/es6/belt_MapInt.js b/lib/es6/belt_MapInt.js index ced1b1814e..074c9c4a08 100644 --- a/lib/es6/belt_MapInt.js +++ b/lib/es6/belt_MapInt.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_internalMapInt from "./belt_internalMapInt.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; @@ -24,7 +25,7 @@ function updateU(t, x, f) { if (t !== undefined) { let k = t.k; if (x === k) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); } @@ -63,7 +64,7 @@ function updateU(t, x, f) { return Belt_internalAVLtree.bal(l$1, k, v, rr); } } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -72,9 +73,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - return updateU(t, x, (function (a) { - return f(a); - })); + return updateU(t, x, Curry.__1(f)); } function removeAux(n, x) { diff --git a/lib/es6/belt_MapString.js b/lib/es6/belt_MapString.js index 0880dca3cd..f531c8c023 100644 --- a/lib/es6/belt_MapString.js +++ b/lib/es6/belt_MapString.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; import * as Belt_internalMapString from "./belt_internalMapString.js"; @@ -24,7 +25,7 @@ function updateU(t, x, f) { if (t !== undefined) { let k = t.k; if (x === k) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); } @@ -63,7 +64,7 @@ function updateU(t, x, f) { return Belt_internalAVLtree.bal(l$1, k, v, rr); } } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -72,9 +73,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - return updateU(t, x, (function (a) { - return f(a); - })); + return updateU(t, x, Curry.__1(f)); } function removeAux(n, x) { diff --git a/lib/es6/belt_MutableMap.js b/lib/es6/belt_MutableMap.js index df575d99d5..88108b9d1b 100644 --- a/lib/es6/belt_MutableMap.js +++ b/lib/es6/belt_MutableMap.js @@ -1,11 +1,12 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; function removeMutateAux(nt, x, cmp) { let k = nt.k; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { let l = nt.l; let r = nt.r; @@ -88,9 +89,9 @@ function removeMany(d, xs) { function updateDone(t, x, f, cmp) { if (t !== undefined) { let k = t.k; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { t.v = Caml_option.valFromOption(data); return t; @@ -117,7 +118,7 @@ function updateDone(t, x, f, cmp) { } return Belt_internalAVLtree.balMutate(t); } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -136,9 +137,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - updateU(t, x, (function (a) { - return f(a); - })); + updateU(t, x, Curry.__1(f)); } function make(id) { @@ -153,7 +152,8 @@ function clear(m) { } function isEmpty(d) { - return d.data === undefined; + let x = d.data; + return x === undefined; } function minKey(m) { @@ -193,9 +193,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a, b) { - f(a, b); - })); + Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); } function reduceU(d, acc, cb) { @@ -203,9 +201,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b, c) { - return cb(a, b, c); - })); + return reduceU(d, acc, Curry.__3(cb)); } function everyU(d, p) { @@ -213,9 +209,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a, b) { - return p(a, b); - })); + return Belt_internalAVLtree.everyU(d.data, Curry.__2(p)); } function someU(d, p) { @@ -223,9 +217,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a, b) { - return p(a, b); - })); + return Belt_internalAVLtree.someU(d.data, Curry.__2(p)); } function size(d) { @@ -257,9 +249,7 @@ function cmpU(m1, m2, cmp) { } function cmp(m1, m2, cmp$1) { - return cmpU(m1, m2, (function (a, b) { - return cmp$1(a, b); - })); + return cmpU(m1, m2, Curry.__2(cmp$1)); } function eqU(m1, m2, cmp) { @@ -267,9 +257,7 @@ function eqU(m1, m2, cmp) { } function eq(m1, m2, cmp) { - return eqU(m1, m2, (function (a, b) { - return cmp(a, b); - })); + return eqU(m1, m2, Curry.__2(cmp)); } function mapU(m, f) { @@ -280,9 +268,7 @@ function mapU(m, f) { } function map(m, f) { - return mapU(m, (function (a) { - return f(a); - })); + return mapU(m, Curry.__1(f)); } function mapWithKeyU(m, f) { @@ -293,9 +279,7 @@ function mapWithKeyU(m, f) { } function mapWithKey(m, f) { - return mapWithKeyU(m, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(m, Curry.__2(f)); } function get(m, x) { diff --git a/lib/es6/belt_MutableMapInt.js b/lib/es6/belt_MutableMapInt.js index dc792430ed..e89c0f59e9 100644 --- a/lib/es6/belt_MutableMapInt.js +++ b/lib/es6/belt_MutableMapInt.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_internalMapInt from "./belt_internalMapInt.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; @@ -11,7 +12,8 @@ function make() { } function isEmpty(m) { - return m.data === undefined; + let x = m.data; + return x === undefined; } function clear(m) { @@ -65,9 +67,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a, b) { - f(a, b); - })); + Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); } function mapU(d, f) { @@ -77,9 +77,7 @@ function mapU(d, f) { } function map(d, f) { - return mapU(d, (function (a) { - return f(a); - })); + return mapU(d, Curry.__1(f)); } function mapWithKeyU(d, f) { @@ -89,9 +87,7 @@ function mapWithKeyU(d, f) { } function mapWithKey(d, f) { - return mapWithKeyU(d, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(d, Curry.__2(f)); } function reduceU(d, acc, f) { @@ -99,9 +95,7 @@ function reduceU(d, acc, f) { } function reduce(d, acc, f) { - return reduceU(d, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(d, acc, Curry.__3(f)); } function everyU(d, f) { @@ -109,9 +103,7 @@ function everyU(d, f) { } function every(d, f) { - return everyU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); } function someU(d, f) { @@ -119,9 +111,7 @@ function someU(d, f) { } function some(d, f) { - return someU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); } function size(d) { @@ -203,7 +193,7 @@ function updateDone(t, x, f) { if (t !== undefined) { let k = t.k; if (k === x) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { t.v = Caml_option.valFromOption(data); return t; @@ -231,7 +221,7 @@ function updateDone(t, x, f) { } return Belt_internalAVLtree.balMutate(t); } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -250,9 +240,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - updateU(t, x, (function (a) { - return f(a); - })); + updateU(t, x, Curry.__1(f)); } function removeArrayMutateAux(_t, xs, _i, len) { @@ -298,9 +286,7 @@ function cmpU(d0, d1, f) { } function cmp(d0, d1, f) { - return cmpU(d0, d1, (function (a, b) { - return f(a, b); - })); + return cmpU(d0, d1, Curry.__2(f)); } function eqU(d0, d1, f) { @@ -308,9 +294,7 @@ function eqU(d0, d1, f) { } function eq(d0, d1, f) { - return eqU(d0, d1, (function (a, b) { - return f(a, b); - })); + return eqU(d0, d1, Curry.__2(f)); } function get(d, x) { diff --git a/lib/es6/belt_MutableMapString.js b/lib/es6/belt_MutableMapString.js index b0d77bb7e7..2bb72dbeb7 100644 --- a/lib/es6/belt_MutableMapString.js +++ b/lib/es6/belt_MutableMapString.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; import * as Belt_internalMapString from "./belt_internalMapString.js"; @@ -11,7 +12,8 @@ function make() { } function isEmpty(m) { - return m.data === undefined; + let x = m.data; + return x === undefined; } function clear(m) { @@ -65,9 +67,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a, b) { - f(a, b); - })); + Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); } function mapU(d, f) { @@ -77,9 +77,7 @@ function mapU(d, f) { } function map(d, f) { - return mapU(d, (function (a) { - return f(a); - })); + return mapU(d, Curry.__1(f)); } function mapWithKeyU(d, f) { @@ -89,9 +87,7 @@ function mapWithKeyU(d, f) { } function mapWithKey(d, f) { - return mapWithKeyU(d, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(d, Curry.__2(f)); } function reduceU(d, acc, f) { @@ -99,9 +95,7 @@ function reduceU(d, acc, f) { } function reduce(d, acc, f) { - return reduceU(d, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(d, acc, Curry.__3(f)); } function everyU(d, f) { @@ -109,9 +103,7 @@ function everyU(d, f) { } function every(d, f) { - return everyU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); } function someU(d, f) { @@ -119,9 +111,7 @@ function someU(d, f) { } function some(d, f) { - return someU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); } function size(d) { @@ -203,7 +193,7 @@ function updateDone(t, x, f) { if (t !== undefined) { let k = t.k; if (k === x) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { t.v = Caml_option.valFromOption(data); return t; @@ -231,7 +221,7 @@ function updateDone(t, x, f) { } return Belt_internalAVLtree.balMutate(t); } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -250,9 +240,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - updateU(t, x, (function (a) { - return f(a); - })); + updateU(t, x, Curry.__1(f)); } function removeArrayMutateAux(_t, xs, _i, len) { @@ -298,9 +286,7 @@ function cmpU(d0, d1, f) { } function cmp(d0, d1, f) { - return cmpU(d0, d1, (function (a, b) { - return f(a, b); - })); + return cmpU(d0, d1, Curry.__2(f)); } function eqU(d0, d1, f) { @@ -308,9 +294,7 @@ function eqU(d0, d1, f) { } function eq(d0, d1, f) { - return eqU(d0, d1, (function (a, b) { - return f(a, b); - })); + return eqU(d0, d1, Curry.__2(f)); } function get(d, x) { diff --git a/lib/es6/belt_MutableQueue.js b/lib/es6/belt_MutableQueue.js index 792e610d4b..6298b62fe0 100644 --- a/lib/es6/belt_MutableQueue.js +++ b/lib/es6/belt_MutableQueue.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function make() { @@ -156,7 +157,7 @@ function mapU(q, f) { let cell = _cell; let prev = _prev; if (cell !== undefined) { - let content = f(cell.content); + let content = Curry._1(f, cell.content); let res = { content: content, next: undefined @@ -176,9 +177,7 @@ function mapU(q, f) { } function map(q, f) { - return mapU(q, (function (a) { - return f(a); - })); + return mapU(q, Curry.__1(f)); } function isEmpty(q) { @@ -196,16 +195,14 @@ function forEachU(q, f) { if (cell === undefined) { return; } - f(cell.content); + Curry._1(f, cell.content); _cell = cell.next; continue; }; } function forEach(q, f) { - forEachU(q, (function (a) { - f(a); - })); + forEachU(q, Curry.__1(f)); } function reduceU(q, accu, f) { @@ -217,7 +214,7 @@ function reduceU(q, accu, f) { if (cell === undefined) { return accu$1; } - let accu$2 = f(accu$1, cell.content); + let accu$2 = Curry._2(f, accu$1, cell.content); _cell = cell.next; _accu = accu$2; continue; @@ -225,9 +222,7 @@ function reduceU(q, accu, f) { } function reduce(q, accu, f) { - return reduceU(q, accu, (function (a, b) { - return f(a, b); - })); + return reduceU(q, accu, Curry.__2(f)); } function transfer(q1, q2) { diff --git a/lib/es6/belt_MutableSet.js b/lib/es6/belt_MutableSet.js index 05ed011852..893bcfca79 100644 --- a/lib/es6/belt_MutableSet.js +++ b/lib/es6/belt_MutableSet.js @@ -1,11 +1,12 @@ +import * as Curry from "./curry.js"; import * as Belt_SortArray from "./belt_SortArray.js"; import * as Belt_internalAVLset from "./belt_internalAVLset.js"; function remove0(nt, x, cmp) { let k = nt.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { let l = nt.l; let r = nt.r; @@ -80,7 +81,7 @@ function removeMany(d, xs) { function removeCheck0(nt, x, removed, cmp) { let k = nt.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { removed.contents = true; let l = nt.l; @@ -132,7 +133,7 @@ function removeCheck(d, v) { function addCheck0(t, x, added, cmp) { if (t !== undefined) { let k = t.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { return t; } @@ -192,7 +193,8 @@ function make(id) { } function isEmpty(d) { - return d.data === undefined; + let n = d.data; + return n === undefined; } function minimum(d) { @@ -216,9 +218,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a) { - f(a); - })); + Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); } function reduceU(d, acc, cb) { @@ -226,9 +226,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b) { - return cb(a, b); - })); + return reduceU(d, acc, Curry.__2(cb)); } function everyU(d, p) { @@ -236,9 +234,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); } function someU(d, p) { @@ -246,9 +242,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.someU(d.data, Curry.__1(p)); } function size(d) { @@ -346,9 +340,7 @@ function keepU(d, p) { } function keep(d, p) { - return keepU(d, (function (a) { - return p(a); - })); + return keepU(d, Curry.__1(p)); } function partitionU(d, p) { @@ -367,9 +359,7 @@ function partitionU(d, p) { } function partition(d, p) { - return partitionU(d, (function (a) { - return p(a); - })); + return partitionU(d, Curry.__1(p)); } function subset(a, b) { @@ -398,7 +388,7 @@ function intersect(a, b) { let tmp = new Array(totalSize); Belt_internalAVLset.fillArray(match, 0, tmp); Belt_internalAVLset.fillArray(match$1, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { + if (Curry._2(cmp, tmp[sizea - 1 | 0], tmp[sizea]) < 0 || Curry._2(cmp, tmp[totalSize - 1 | 0], tmp[0]) < 0) { return { cmp: cmp, data: undefined @@ -434,7 +424,7 @@ function diff(a, b) { let tmp = new Array(totalSize); Belt_internalAVLset.fillArray(dataa, 0, tmp); Belt_internalAVLset.fillArray(match, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { + if (Curry._2(cmp, tmp[sizea - 1 | 0], tmp[sizea]) < 0 || Curry._2(cmp, tmp[totalSize - 1 | 0], tmp[0]) < 0) { return { cmp: cmp, data: Belt_internalAVLset.copy(dataa) @@ -470,7 +460,7 @@ function union(a, b) { let tmp = new Array(totalSize); Belt_internalAVLset.fillArray(dataa, 0, tmp); Belt_internalAVLset.fillArray(datab, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0) { + if (Curry._2(cmp, tmp[sizea - 1 | 0], tmp[sizea]) < 0) { return { cmp: cmp, data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) diff --git a/lib/es6/belt_MutableSetInt.js b/lib/es6/belt_MutableSetInt.js index 47ff473614..db281ee9a8 100644 --- a/lib/es6/belt_MutableSetInt.js +++ b/lib/es6/belt_MutableSetInt.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_SortArrayInt from "./belt_SortArrayInt.js"; import * as Belt_internalAVLset from "./belt_internalAVLset.js"; import * as Belt_internalSetInt from "./belt_internalSetInt.js"; @@ -189,7 +190,8 @@ function make() { } function isEmpty(d) { - return d.data === undefined; + let n = d.data; + return n === undefined; } function minimum(d) { @@ -213,9 +215,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a) { - f(a); - })); + Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); } function reduceU(d, acc, cb) { @@ -223,9 +223,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b) { - return cb(a, b); - })); + return reduceU(d, acc, Curry.__2(cb)); } function everyU(d, p) { @@ -233,9 +231,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); } function someU(d, p) { @@ -243,9 +239,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.someU(d.data, Curry.__1(p)); } function size(d) { @@ -334,9 +328,7 @@ function keepU(d, p) { } function keep(d, p) { - return keepU(d, (function (a) { - return p(a); - })); + return keepU(d, Curry.__1(p)); } function partitionU(d, p) { @@ -352,9 +344,7 @@ function partitionU(d, p) { } function partition(d, p) { - return partitionU(d, (function (a) { - return p(a); - })); + return partitionU(d, Curry.__1(p)); } function subset(a, b) { diff --git a/lib/es6/belt_MutableSetString.js b/lib/es6/belt_MutableSetString.js index d8a217d1ef..7dc13b6c0b 100644 --- a/lib/es6/belt_MutableSetString.js +++ b/lib/es6/belt_MutableSetString.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_internalAVLset from "./belt_internalAVLset.js"; import * as Belt_SortArrayString from "./belt_SortArrayString.js"; import * as Belt_internalSetString from "./belt_internalSetString.js"; @@ -189,7 +190,8 @@ function make() { } function isEmpty(d) { - return d.data === undefined; + let n = d.data; + return n === undefined; } function minimum(d) { @@ -213,9 +215,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a) { - f(a); - })); + Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); } function reduceU(d, acc, cb) { @@ -223,9 +223,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b) { - return cb(a, b); - })); + return reduceU(d, acc, Curry.__2(cb)); } function everyU(d, p) { @@ -233,9 +231,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); } function someU(d, p) { @@ -243,9 +239,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.someU(d.data, Curry.__1(p)); } function size(d) { @@ -334,9 +328,7 @@ function keepU(d, p) { } function keep(d, p) { - return keepU(d, (function (a) { - return p(a); - })); + return keepU(d, Curry.__1(p)); } function partitionU(d, p) { @@ -352,9 +344,7 @@ function partitionU(d, p) { } function partition(d, p) { - return partitionU(d, (function (a) { - return p(a); - })); + return partitionU(d, Curry.__1(p)); } function subset(a, b) { diff --git a/lib/es6/belt_MutableStack.js b/lib/es6/belt_MutableStack.js index 1197f56c81..26e944b37d 100644 --- a/lib/es6/belt_MutableStack.js +++ b/lib/es6/belt_MutableStack.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function make() { @@ -91,16 +92,14 @@ function forEachU(s, f) { if (s$1 === undefined) { return; } - f(s$1.head); + Curry._1(f, s$1.head); _s = s$1.tail; continue; }; } function forEach(s, f) { - forEachU(s, (function (x) { - f(x); - })); + forEachU(s, Curry.__1(f)); } function dynamicPopIterU(s, f) { @@ -110,15 +109,13 @@ function dynamicPopIterU(s, f) { return; } s.root = match.tail; - f(match.head); + Curry._1(f, match.head); continue; }; } function dynamicPopIter(s, f) { - dynamicPopIterU(s, (function (x) { - f(x); - })); + dynamicPopIterU(s, Curry.__1(f)); } export { diff --git a/lib/es6/belt_Option.js b/lib/es6/belt_Option.js index 840279441c..52331baede 100644 --- a/lib/es6/belt_Option.js +++ b/lib/es6/belt_Option.js @@ -1,31 +1,28 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function keepU(opt, p) { - if (opt !== undefined && p(Caml_option.valFromOption(opt))) { + if (opt !== undefined && Curry._1(p, Caml_option.valFromOption(opt))) { return opt; } } function keep(opt, p) { - return keepU(opt, (function (x) { - return p(x); - })); + return keepU(opt, Curry.__1(p)); } function forEachU(opt, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return Curry._1(f, Caml_option.valFromOption(opt)); } } function forEach(opt, f) { - forEachU(opt, (function (x) { - f(x); - })); + forEachU(opt, Curry.__1(f)); } function getExn(x) { @@ -41,42 +38,36 @@ function getExn(x) { function mapWithDefaultU(opt, $$default, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return Curry._1(f, Caml_option.valFromOption(opt)); } else { return $$default; } } function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, (function (x) { - return f(x); - })); + return mapWithDefaultU(opt, $$default, Curry.__1(f)); } function mapU(opt, f) { if (opt !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(opt))); + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(opt))); } } function map(opt, f) { - return mapU(opt, (function (x) { - return f(x); - })); + return mapU(opt, Curry.__1(f)); } function flatMapU(opt, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return Curry._1(f, Caml_option.valFromOption(opt)); } } function flatMap(opt, f) { - return flatMapU(opt, (function (x) { - return f(x); - })); + return flatMapU(opt, Curry.__1(f)); } function getWithDefault(opt, $$default) { @@ -106,7 +97,7 @@ function isNone(x) { function eqU(a, b, f) { if (a !== undefined) { if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return Curry._2(f, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return false; } @@ -116,15 +107,13 @@ function eqU(a, b, f) { } function eq(a, b, f) { - return eqU(a, b, (function (x, y) { - return f(x, y); - })); + return eqU(a, b, Curry.__2(f)); } function cmpU(a, b, f) { if (a !== undefined) { if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return Curry._2(f, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return 1; } @@ -136,9 +125,7 @@ function cmpU(a, b, f) { } function cmp(a, b, f) { - return cmpU(a, b, (function (x, y) { - return f(x, y); - })); + return cmpU(a, b, Curry.__2(f)); } export { diff --git a/lib/es6/belt_Range.js b/lib/es6/belt_Range.js index 6dc8c014d2..da82accec9 100644 --- a/lib/es6/belt_Range.js +++ b/lib/es6/belt_Range.js @@ -1,16 +1,15 @@ +import * as Curry from "./curry.js"; function forEachU(s, f, action) { for(let i = s; i <= f; ++i){ - action(i); + Curry._1(action, i); } } function forEach(s, f, action) { - forEachU(s, f, (function (a) { - action(a); - })); + forEachU(s, f, Curry.__1(action)); } function everyU(_s, f, p) { @@ -19,7 +18,7 @@ function everyU(_s, f, p) { if (s > f) { return true; } - if (!p(s)) { + if (!Curry._1(p, s)) { return false; } _s = s + 1 | 0; @@ -28,9 +27,7 @@ function everyU(_s, f, p) { } function every(s, f, p) { - return everyU(s, f, (function (a) { - return p(a); - })); + return everyU(s, f, Curry.__1(p)); } function everyByU(s, f, step, p) { @@ -41,7 +38,7 @@ function everyByU(s, f, step, p) { if (s$1 > f) { return true; } - if (!p(s$1)) { + if (!Curry._1(p, s$1)) { return false; } _s = s$1 + step | 0; @@ -53,9 +50,7 @@ function everyByU(s, f, step, p) { } function everyBy(s, f, step, p) { - return everyByU(s, f, step, (function (a) { - return p(a); - })); + return everyByU(s, f, step, Curry.__1(p)); } function someU(_s, f, p) { @@ -64,7 +59,7 @@ function someU(_s, f, p) { if (s > f) { return false; } - if (p(s)) { + if (Curry._1(p, s)) { return true; } _s = s + 1 | 0; @@ -73,9 +68,7 @@ function someU(_s, f, p) { } function some(s, f, p) { - return someU(s, f, (function (a) { - return p(a); - })); + return someU(s, f, Curry.__1(p)); } function someByU(s, f, step, p) { @@ -86,7 +79,7 @@ function someByU(s, f, step, p) { if (s$1 > f) { return false; } - if (p(s$1)) { + if (Curry._1(p, s$1)) { return true; } _s = s$1 + step | 0; @@ -98,9 +91,7 @@ function someByU(s, f, step, p) { } function someBy(s, f, step, p) { - return someByU(s, f, step, (function (a) { - return p(a); - })); + return someByU(s, f, step, Curry.__1(p)); } export { diff --git a/lib/es6/belt_Result.js b/lib/es6/belt_Result.js index e3594b9633..c4020cb2ea 100644 --- a/lib/es6/belt_Result.js +++ b/lib/es6/belt_Result.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; function getExn(x) { if (x.TAG === "Ok") { @@ -14,23 +15,21 @@ function getExn(x) { function mapWithDefaultU(opt, $$default, f) { if (opt.TAG === "Ok") { - return f(opt._0); + return Curry._1(f, opt._0); } else { return $$default; } } function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, (function (x) { - return f(x); - })); + return mapWithDefaultU(opt, $$default, Curry.__1(f)); } function mapU(opt, f) { if (opt.TAG === "Ok") { return { TAG: "Ok", - _0: f(opt._0) + _0: Curry._1(f, opt._0) }; } else { return { @@ -41,14 +40,12 @@ function mapU(opt, f) { } function map(opt, f) { - return mapU(opt, (function (x) { - return f(x); - })); + return mapU(opt, Curry.__1(f)); } function flatMapU(opt, f) { if (opt.TAG === "Ok") { - return f(opt._0); + return Curry._1(f, opt._0); } else { return { TAG: "Error", @@ -58,9 +55,7 @@ function flatMapU(opt, f) { } function flatMap(opt, f) { - return flatMapU(opt, (function (x) { - return f(x); - })); + return flatMapU(opt, Curry.__1(f)); } function getWithDefault(opt, $$default) { @@ -90,7 +85,7 @@ function isError(x) { function eqU(a, b, f) { if (a.TAG === "Ok") { if (b.TAG === "Ok") { - return f(a._0, b._0); + return Curry._2(f, a._0, b._0); } else { return false; } @@ -102,15 +97,13 @@ function eqU(a, b, f) { } function eq(a, b, f) { - return eqU(a, b, (function (x, y) { - return f(x, y); - })); + return eqU(a, b, Curry.__2(f)); } function cmpU(a, b, f) { if (a.TAG === "Ok") { if (b.TAG === "Ok") { - return f(a._0, b._0); + return Curry._2(f, a._0, b._0); } else { return 1; } @@ -122,9 +115,7 @@ function cmpU(a, b, f) { } function cmp(a, b, f) { - return cmpU(a, b, (function (x, y) { - return f(x, y); - })); + return cmpU(a, b, Curry.__2(f)); } export { diff --git a/lib/es6/belt_Set.js b/lib/es6/belt_Set.js index c68c9f5b85..816c874348 100644 --- a/lib/es6/belt_Set.js +++ b/lib/es6/belt_Set.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_SetDict from "./belt_SetDict.js"; function fromArray(data, id) { @@ -127,9 +128,7 @@ function forEachU(m, f) { } function forEach(m, f) { - forEachU(m, (function (a) { - f(a); - })); + Belt_SetDict.forEachU(m.data, Curry.__1(f)); } function reduceU(m, acc, f) { @@ -137,9 +136,7 @@ function reduceU(m, acc, f) { } function reduce(m, acc, f) { - return reduceU(m, acc, (function (a, b) { - return f(a, b); - })); + return reduceU(m, acc, Curry.__2(f)); } function everyU(m, f) { @@ -147,9 +144,7 @@ function everyU(m, f) { } function every(m, f) { - return everyU(m, (function (a) { - return f(a); - })); + return Belt_SetDict.everyU(m.data, Curry.__1(f)); } function someU(m, f) { @@ -157,9 +152,7 @@ function someU(m, f) { } function some(m, f) { - return someU(m, (function (a) { - return f(a); - })); + return Belt_SetDict.someU(m.data, Curry.__1(f)); } function keepU(m, f) { @@ -170,9 +163,7 @@ function keepU(m, f) { } function keep(m, f) { - return keepU(m, (function (a) { - return f(a); - })); + return keepU(m, Curry.__1(f)); } function partitionU(m, f) { @@ -191,9 +182,7 @@ function partitionU(m, f) { } function partition(m, f) { - return partitionU(m, (function (a) { - return f(a); - })); + return partitionU(m, Curry.__1(f)); } function size(m) { diff --git a/lib/es6/belt_SetDict.js b/lib/es6/belt_SetDict.js index 4231c26328..424be90fed 100644 --- a/lib/es6/belt_SetDict.js +++ b/lib/es6/belt_SetDict.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_internalAVLset from "./belt_internalAVLset.js"; function add(t, x, cmp) { @@ -7,7 +8,7 @@ function add(t, x, cmp) { return Belt_internalAVLset.singleton(x); } let k = t.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { return t; } @@ -36,7 +37,7 @@ function remove(t, x, cmp) { let v = t.v; let l = t.l; let r = t.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { if (l === undefined) { return r; @@ -90,7 +91,7 @@ function splitAuxNoPivot(cmp, n, x) { let v = n.v; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return [ l, @@ -127,7 +128,7 @@ function splitAuxPivot(cmp, n, x, pres) { let v = n.v; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { pres.contents = true; return [ diff --git a/lib/es6/belt_SortArray.js b/lib/es6/belt_SortArray.js index 11810837e4..8c0b788b83 100644 --- a/lib/es6/belt_SortArray.js +++ b/lib/es6/belt_SortArray.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_Array from "./belt_Array.js"; function sortedLengthAuxMore(xs, _prec, _acc, len, lt) { @@ -10,7 +11,7 @@ function sortedLengthAuxMore(xs, _prec, _acc, len, lt) { return acc; } let v = xs[acc]; - if (!lt(v, prec)) { + if (!Curry._2(lt, v, prec)) { return acc; } _acc = acc + 1 | 0; @@ -26,7 +27,7 @@ function strictlySortedLengthU(xs, lt) { } let x0 = xs[0]; let x1 = xs[1]; - if (lt(x0, x1)) { + if (Curry._2(lt, x0, x1)) { let _prec = x1; let _acc = 2; while(true) { @@ -36,14 +37,14 @@ function strictlySortedLengthU(xs, lt) { return acc; } let v = xs[acc]; - if (!lt(prec, v)) { + if (!Curry._2(lt, prec, v)) { return acc; } _acc = acc + 1 | 0; _prec = v; continue; }; - } else if (lt(x1, x0)) { + } else if (Curry._2(lt, x1, x0)) { return -sortedLengthAuxMore(xs, x1, 2, len, lt) | 0; } else { return 1; @@ -51,9 +52,7 @@ function strictlySortedLengthU(xs, lt) { } function strictlySortedLength(xs, lt) { - return strictlySortedLengthU(xs, (function (x, y) { - return lt(x, y); - })); + return strictlySortedLengthU(xs, Curry.__2(lt)); } function isSortedU(a, cmp) { @@ -68,7 +67,7 @@ function isSortedU(a, cmp) { if (i === last_bound) { return true; } - if (cmp(a[i], a[i + 1 | 0]) > 0) { + if (Curry._2(cmp, a[i], a[i + 1 | 0]) > 0) { return false; } _i = i + 1 | 0; @@ -78,9 +77,7 @@ function isSortedU(a, cmp) { } function isSorted(a, cmp) { - return isSortedU(a, (function (x, y) { - return cmp(x, y); - })); + return isSortedU(a, Curry.__2(cmp)); } function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { @@ -97,7 +94,7 @@ function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) let i2 = _i2; let s1 = _s1; let i1 = _i1; - if (cmp(s1, s2) <= 0) { + if (Curry._2(cmp, s1, s2) <= 0) { dst[d] = s1; let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -134,7 +131,7 @@ function unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) let i2 = _i2; let s1 = _s1; let i1 = _i1; - let c = cmp(s1, s2); + let c = Curry._2(cmp, s1, s2); if (c < 0) { dst[d] = s1; let i1$1 = i1 + 1 | 0; @@ -184,9 +181,7 @@ function unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) } function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (function (x, y) { - return cmp(x, y); - })); + return unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); } function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { @@ -203,7 +198,7 @@ function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, let i2 = _i2; let s1 = _s1; let i1 = _i1; - let c = cmp(s1, s2); + let c = Curry._2(cmp, s1, s2); if (c < 0) { let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -239,9 +234,7 @@ function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, } function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (function (x, y) { - return cmp(x, y); - })); + return intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); } function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { @@ -258,7 +251,7 @@ function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) let i2 = _i2; let s1 = _s1; let i1 = _i1; - let c = cmp(s1, s2); + let c = Curry._2(cmp, s1, s2); if (c < 0) { dst[d] = s1; let d$1 = d + 1 | 0; @@ -300,16 +293,14 @@ function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) } function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (function (x, y) { - return cmp(x, y); - })); + return diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); } function insertionSort(src, srcofs, dst, dstofs, len, cmp) { for(let i = 0; i < len; ++i){ let e = src[srcofs + i | 0]; let j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(dst[j], e) > 0) { + while(j >= dstofs && Curry._2(cmp, dst[j], e) > 0) { dst[j + 1 | 0] = dst[j]; j = j - 1 | 0; }; @@ -342,9 +333,7 @@ function stableSortInPlaceByU(a, cmp) { } function stableSortInPlaceBy(a, cmp) { - stableSortInPlaceByU(a, (function (x, y) { - return cmp(x, y); - })); + stableSortInPlaceByU(a, Curry.__2(cmp)); } function stableSortByU(a, cmp) { @@ -354,9 +343,7 @@ function stableSortByU(a, cmp) { } function stableSortBy(a, cmp) { - return stableSortByU(a, (function (x, y) { - return cmp(x, y); - })); + return stableSortByU(a, Curry.__2(cmp)); } function binarySearchByU(sorted, key, cmp) { @@ -365,12 +352,12 @@ function binarySearchByU(sorted, key, cmp) { return -1; } let lo = sorted[0]; - let c = cmp(key, lo); + let c = Curry._2(cmp, key, lo); if (c < 0) { return -1; } let hi = sorted[len - 1 | 0]; - let c2 = cmp(key, hi); + let c2 = Curry._2(cmp, key, hi); if (c2 > 0) { return -(len + 1 | 0) | 0; } else { @@ -381,13 +368,13 @@ function binarySearchByU(sorted, key, cmp) { let lo$1 = _lo; let mid = (lo$1 + hi$1 | 0) / 2 | 0; let midVal = sorted[mid]; - let c$1 = cmp(key, midVal); + let c$1 = Curry._2(cmp, key, midVal); if (c$1 === 0) { return mid; } if (c$1 < 0) { if (hi$1 === mid) { - if (cmp(sorted[lo$1], key) === 0) { + if (Curry._2(cmp, sorted[lo$1], key) === 0) { return lo$1; } else { return -(hi$1 + 1 | 0) | 0; @@ -397,7 +384,7 @@ function binarySearchByU(sorted, key, cmp) { continue; } if (lo$1 === mid) { - if (cmp(sorted[hi$1], key) === 0) { + if (Curry._2(cmp, sorted[hi$1], key) === 0) { return hi$1; } else { return -(hi$1 + 1 | 0) | 0; @@ -410,9 +397,7 @@ function binarySearchByU(sorted, key, cmp) { } function binarySearchBy(sorted, key, cmp) { - return binarySearchByU(sorted, key, (function (x, y) { - return cmp(x, y); - })); + return binarySearchByU(sorted, key, Curry.__2(cmp)); } let Int; diff --git a/lib/es6/belt_internalAVLset.js b/lib/es6/belt_internalAVLset.js index 6f6efe8a31..3fe519d075 100644 --- a/lib/es6/belt_internalAVLset.js +++ b/lib/es6/belt_internalAVLset.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_SortArray from "./belt_SortArray.js"; @@ -170,16 +171,14 @@ function forEachU(_n, f) { return; } forEachU(n.l, f); - f(n.v); + Curry._1(f, n.v); _n = n.r; continue; }; } function forEach(n, f) { - forEachU(n, (function (a) { - f(a); - })); + forEachU(n, Curry.__1(f)); } function reduceU(_s, _accu, f) { @@ -189,16 +188,14 @@ function reduceU(_s, _accu, f) { if (s === undefined) { return accu; } - _accu = f(reduceU(s.l, accu, f), s.v); + _accu = Curry._2(f, reduceU(s.l, accu, f), s.v); _s = s.r; continue; }; } function reduce(s, accu, f) { - return reduceU(s, accu, (function (a, b) { - return f(a, b); - })); + return reduceU(s, accu, Curry.__2(f)); } function everyU(_n, p) { @@ -207,7 +204,7 @@ function everyU(_n, p) { if (n === undefined) { return true; } - if (!p(n.v)) { + if (!Curry._1(p, n.v)) { return false; } if (!everyU(n.l, p)) { @@ -219,9 +216,7 @@ function everyU(_n, p) { } function every(n, p) { - return everyU(n, (function (a) { - return p(a); - })); + return everyU(n, Curry.__1(p)); } function someU(_n, p) { @@ -230,7 +225,7 @@ function someU(_n, p) { if (n === undefined) { return false; } - if (p(n.v)) { + if (Curry._1(p, n.v)) { return true; } if (someU(n.l, p)) { @@ -242,9 +237,7 @@ function someU(_n, p) { } function some(n, p) { - return someU(n, (function (a) { - return p(a); - })); + return someU(n, Curry.__1(p)); } function addMinElement(n, v) { @@ -306,7 +299,7 @@ function partitionSharedU(n, p) { let match = partitionSharedU(n.l, p); let lf = match[1]; let lt = match[0]; - let pv = p(value); + let pv = Curry._1(p, value); let match$1 = partitionSharedU(n.r, p); let rf = match$1[1]; let rt = match$1[0]; @@ -324,9 +317,7 @@ function partitionSharedU(n, p) { } function partitionShared(n, p) { - return partitionSharedU(n, (function (a) { - return p(a); - })); + return partitionSharedU(n, Curry.__1(p)); } function lengthNode(n) { @@ -424,7 +415,7 @@ function fillArrayWithPartition(_n, cursor, arr, p) { if (l !== undefined) { fillArrayWithPartition(l, cursor, arr, p); } - if (p(v)) { + if (Curry._1(p, v)) { let c = cursor.forward; arr[c] = v; cursor.forward = c + 1 | 0; @@ -449,7 +440,7 @@ function fillArrayWithFilter(_n, _i, arr, p) { let l = n.l; let r = n.r; let next = l !== undefined ? fillArrayWithFilter(l, i, arr, p) : i; - let rnext = p(v) ? (arr[next] = v, next + 1 | 0) : next; + let rnext = Curry._1(p, v) ? (arr[next] = v, next + 1 | 0) : next; if (r === undefined) { return rnext; } @@ -549,7 +540,7 @@ function keepSharedU(n, p) { let l = n.l; let r = n.r; let newL = keepSharedU(l, p); - let pv = p(v); + let pv = Curry._1(p, v); let newR = keepSharedU(r, p); if (pv) { if (l === newL && r === newR) { @@ -563,9 +554,7 @@ function keepSharedU(n, p) { } function keepShared(n, p) { - return keepSharedU(n, (function (a) { - return p(a); - })); + return keepSharedU(n, Curry.__1(p)); } function keepCopyU(n, p) { @@ -579,9 +568,7 @@ function keepCopyU(n, p) { } function keepCopy(n, p) { - return keepCopyU(n, (function (x) { - return p(x); - })); + return keepCopyU(n, Curry.__1(p)); } function partitionCopyU(n, p) { @@ -607,9 +594,7 @@ function partitionCopyU(n, p) { } function partitionCopy(n, p) { - return partitionCopyU(n, (function (a) { - return p(a); - })); + return partitionCopyU(n, Curry.__1(p)); } function has(_t, x, cmp) { @@ -619,7 +604,7 @@ function has(_t, x, cmp) { return false; } let v = t.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return true; } @@ -645,7 +630,7 @@ function cmp(s1, s2, cmp$1) { } let h2 = e2.hd; let h1 = e1.hd; - let c = cmp$1(h1.v, h2.v); + let c = Curry._2(cmp$1, h1.v, h2.v); if (c !== 0) { return c; } @@ -680,7 +665,7 @@ function subset(_s1, _s2, cmp) { let v2 = s2.v; let l2 = s2.l; let r2 = s2.r; - let c = cmp(v1, v2); + let c = Curry._2(cmp, v1, v2); if (c === 0) { if (!subset(l1, l2, cmp)) { return false; @@ -711,7 +696,7 @@ function get(_n, x, cmp) { return; } let v = n.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return Caml_option.some(v); } @@ -727,7 +712,7 @@ function getUndefined(_n, x, cmp) { return; } let v = n.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return v; } @@ -741,7 +726,7 @@ function getExn(_n, x, cmp) { let n = _n; if (n !== undefined) { let v = n.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return v; } @@ -855,7 +840,7 @@ function addMutate(cmp, t, x) { return singleton(x); } let k = t.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { return t; } @@ -876,7 +861,7 @@ function fromArray(xs, cmp) { return; } let next = Belt_SortArray.strictlySortedLengthU(xs, (function (x, y) { - return cmp(x, y) < 0; + return Curry._2(cmp, x, y) < 0; })); let result; if (next >= 0) { diff --git a/lib/es6/belt_internalAVLtree.js b/lib/es6/belt_internalAVLtree.js index b2406181e3..ac02e1ae3a 100644 --- a/lib/es6/belt_internalAVLtree.js +++ b/lib/es6/belt_internalAVLtree.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_SortArray from "./belt_SortArray.js"; @@ -254,7 +255,7 @@ function findFirstByU(n, p) { } let v = n.k; let d = n.v; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); if (pvd) { return [ v, @@ -269,9 +270,7 @@ function findFirstByU(n, p) { } function findFirstBy(n, p) { - return findFirstByU(n, (function (a, b) { - return p(a, b); - })); + return findFirstByU(n, Curry.__2(p)); } function forEachU(_n, f) { @@ -281,16 +280,14 @@ function forEachU(_n, f) { return; } forEachU(n.l, f); - f(n.k, n.v); + Curry._2(f, n.k, n.v); _n = n.r; continue; }; } function forEach(n, f) { - forEachU(n, (function (a, b) { - f(a, b); - })); + forEachU(n, Curry.__2(f)); } function mapU(n, f) { @@ -298,7 +295,7 @@ function mapU(n, f) { return; } let newLeft = mapU(n.l, f); - let newD = f(n.v); + let newD = Curry._1(f, n.v); let newRight = mapU(n.r, f); return { k: n.k, @@ -310,9 +307,7 @@ function mapU(n, f) { } function map(n, f) { - return mapU(n, (function (a) { - return f(a); - })); + return mapU(n, Curry.__1(f)); } function mapWithKeyU(n, f) { @@ -321,7 +316,7 @@ function mapWithKeyU(n, f) { } let key = n.k; let newLeft = mapWithKeyU(n.l, f); - let newD = f(key, n.v); + let newD = Curry._2(f, key, n.v); let newRight = mapWithKeyU(n.r, f); return { k: key, @@ -333,9 +328,7 @@ function mapWithKeyU(n, f) { } function mapWithKey(n, f) { - return mapWithKeyU(n, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(n, Curry.__2(f)); } function reduceU(_m, _accu, f) { @@ -349,16 +342,14 @@ function reduceU(_m, _accu, f) { let d = m.v; let l = m.l; let r = m.r; - _accu = f(reduceU(l, accu, f), v, d); + _accu = Curry._3(f, reduceU(l, accu, f), v, d); _m = r; continue; }; } function reduce(m, accu, f) { - return reduceU(m, accu, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(m, accu, Curry.__3(f)); } function everyU(_n, p) { @@ -367,7 +358,7 @@ function everyU(_n, p) { if (n === undefined) { return true; } - if (!p(n.k, n.v)) { + if (!Curry._2(p, n.k, n.v)) { return false; } if (!everyU(n.l, p)) { @@ -379,9 +370,7 @@ function everyU(_n, p) { } function every(n, p) { - return everyU(n, (function (a, b) { - return p(a, b); - })); + return everyU(n, Curry.__2(p)); } function someU(_n, p) { @@ -390,7 +379,7 @@ function someU(_n, p) { if (n === undefined) { return false; } - if (p(n.k, n.v)) { + if (Curry._2(p, n.k, n.v)) { return true; } if (someU(n.l, p)) { @@ -402,9 +391,7 @@ function someU(_n, p) { } function some(n, p) { - return someU(n, (function (a, b) { - return p(a, b); - })); + return someU(n, Curry.__2(p)); } function addMinElement(n, k, v) { @@ -481,7 +468,7 @@ function keepSharedU(n, p) { let v = n.k; let d = n.v; let newLeft = keepSharedU(n.l, p); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let newRight = keepSharedU(n.r, p); if (pvd) { return join(newLeft, v, d, newRight); @@ -491,9 +478,7 @@ function keepSharedU(n, p) { } function keepShared(n, p) { - return keepSharedU(n, (function (a, b) { - return p(a, b); - })); + return keepSharedU(n, Curry.__2(p)); } function keepMapU(n, p) { @@ -503,7 +488,7 @@ function keepMapU(n, p) { let v = n.k; let d = n.v; let newLeft = keepMapU(n.l, p); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let newRight = keepMapU(n.r, p); if (pvd !== undefined) { return join(newLeft, v, Caml_option.valFromOption(pvd), newRight); @@ -513,9 +498,7 @@ function keepMapU(n, p) { } function keepMap(n, p) { - return keepMapU(n, (function (a, b) { - return p(a, b); - })); + return keepMapU(n, Curry.__2(p)); } function partitionSharedU(n, p) { @@ -530,7 +513,7 @@ function partitionSharedU(n, p) { let match = partitionSharedU(n.l, p); let lf = match[1]; let lt = match[0]; - let pvd = p(key, value); + let pvd = Curry._2(p, key, value); let match$1 = partitionSharedU(n.r, p); let rf = match$1[1]; let rt = match$1[0]; @@ -548,9 +531,7 @@ function partitionSharedU(n, p) { } function partitionShared(n, p) { - return partitionSharedU(n, (function (a, b) { - return p(a, b); - })); + return partitionSharedU(n, Curry.__2(p)); } function lengthNode(n) { @@ -817,11 +798,11 @@ function cmpU(s1, s2, kcmp, vcmp) { } let h2 = e2.hd; let h1 = e1.hd; - let c = kcmp(h1.k, h2.k); + let c = Curry._2(kcmp, h1.k, h2.k); if (c !== 0) { return c; } - let cx = vcmp(h1.v, h2.v); + let cx = Curry._2(vcmp, h1.v, h2.v); if (cx !== 0) { return cx; } @@ -837,9 +818,7 @@ function cmpU(s1, s2, kcmp, vcmp) { } function cmp(s1, s2, kcmp, vcmp) { - return cmpU(s1, s2, kcmp, (function (a, b) { - return vcmp(a, b); - })); + return cmpU(s1, s2, kcmp, Curry.__2(vcmp)); } function eqU(s1, s2, kcmp, veq) { @@ -859,7 +838,7 @@ function eqU(s1, s2, kcmp, veq) { } let h2 = e2.hd; let h1 = e1.hd; - if (!(kcmp(h1.k, h2.k) === 0 && veq(h1.v, h2.v))) { + if (!(Curry._2(kcmp, h1.k, h2.k) === 0 && Curry._2(veq, h1.v, h2.v))) { return false; } _e2 = stackAllLeft(h2.r, e2.tl); @@ -872,9 +851,7 @@ function eqU(s1, s2, kcmp, veq) { } function eq(s1, s2, kcmp, veq) { - return eqU(s1, s2, kcmp, (function (a, b) { - return veq(a, b); - })); + return eqU(s1, s2, kcmp, Curry.__2(veq)); } function get(_n, x, cmp) { @@ -884,7 +861,7 @@ function get(_n, x, cmp) { return; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return Caml_option.some(n.v); } @@ -900,7 +877,7 @@ function getUndefined(_n, x, cmp) { return; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return n.v; } @@ -914,7 +891,7 @@ function getExn(_n, x, cmp) { let n = _n; if (n !== undefined) { let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return n.v; } @@ -936,7 +913,7 @@ function getWithDefault(_n, x, def, cmp) { return def; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return n.v; } @@ -952,7 +929,7 @@ function has(_n, x, cmp) { return false; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return true; } @@ -1052,7 +1029,7 @@ function updateMutate(t, x, data, cmp) { return singleton(x, data); } let k = t.k; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { t.v = data; return t; @@ -1074,7 +1051,7 @@ function fromArray(xs, cmp) { return; } let next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return cmp(param[0], param$1[0]) < 0; + return Curry._2(cmp, param[0], param$1[0]) < 0; })); let result; if (next >= 0) { diff --git a/lib/es6/belt_internalBuckets.js b/lib/es6/belt_internalBuckets.js index 43299a9adc..69c74a4806 100644 --- a/lib/es6/belt_internalBuckets.js +++ b/lib/es6/belt_internalBuckets.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_Array from "./belt_Array.js"; import * as Caml_option from "./caml_option.js"; @@ -72,7 +73,7 @@ function do_bucket_iter(f, _buckets) { if (buckets === undefined) { return; } - f(buckets.key, buckets.value); + Curry._2(f, buckets.key, buckets.value); _buckets = buckets.next; continue; }; @@ -86,9 +87,7 @@ function forEachU(h, f) { } function forEach(h, f) { - forEachU(h, (function (a, b) { - return f(a, b); - })); + forEachU(h, Curry.__2(f)); } function do_bucket_fold(f, _b, _accu) { @@ -98,7 +97,7 @@ function do_bucket_fold(f, _b, _accu) { if (b === undefined) { return accu; } - _accu = f(accu, b.key, b.value); + _accu = Curry._3(f, accu, b.key, b.value); _b = b.next; continue; }; @@ -114,9 +113,7 @@ function reduceU(h, init, f) { } function reduce(h, init, f) { - return reduceU(h, init, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(h, init, Curry.__3(f)); } function getMaxBucketLength(h) { @@ -156,7 +153,7 @@ function filterMapInplaceBucket(f, h, i, _prec, _cell) { let cell = _cell; let prec = _prec; let n = cell.next; - let data = f(cell.key, cell.value); + let data = Curry._2(f, cell.key, cell.value); if (data !== undefined) { if (prec !== undefined) { cell.next = cell; @@ -198,9 +195,7 @@ function keepMapInPlaceU(h, f) { } function keepMapInPlace(h, f) { - keepMapInPlaceU(h, (function (a, b) { - return f(a, b); - })); + keepMapInPlaceU(h, Curry.__2(f)); } function fillArray(_i, arr, _cell) { @@ -225,7 +220,7 @@ function fillArrayMap(_i, arr, _cell, f) { while(true) { let cell = _cell; let i = _i; - arr[i] = f(cell); + arr[i] = Curry._1(f, cell); let v = cell.next; if (v === undefined) { return i + 1 | 0; diff --git a/lib/es6/belt_internalMapInt.js b/lib/es6/belt_internalMapInt.js index 845b33e8f4..122784a58c 100644 --- a/lib/es6/belt_internalMapInt.js +++ b/lib/es6/belt_internalMapInt.js @@ -1,6 +1,7 @@ import * as Caml from "./caml.js"; +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_SortArray from "./belt_SortArray.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; @@ -194,7 +195,7 @@ function mergeU(s1, s2, f) { let l1 = s1.l; let r1 = s1.r; let match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, Curry._3(f, v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); } } else if (s2 === undefined) { @@ -205,13 +206,11 @@ function mergeU(s1, s2, f) { let l2 = s2.l; let r2 = s2.r; let match$1 = split(v2, s1); - return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, Curry._3(f, v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); } function merge(s1, s2, f) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - })); + return mergeU(s1, s2, Curry.__3(f)); } function compareAux(_e1, _e2, vcmp) { @@ -230,7 +229,7 @@ function compareAux(_e1, _e2, vcmp) { if (c !== 0) { return c; } - let cx = vcmp(h1.v, h2.v); + let cx = Curry._2(vcmp, h1.v, h2.v); if (cx !== 0) { return cx; } @@ -253,9 +252,7 @@ function cmpU(s1, s2, cmp) { } function cmp(s1, s2, f) { - return cmpU(s1, s2, (function (a, b) { - return f(a, b); - })); + return cmpU(s1, s2, Curry.__2(f)); } function eqAux(_e1, _e2, eq) { @@ -270,7 +267,7 @@ function eqAux(_e1, _e2, eq) { } let h2 = e2.hd; let h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { + if (!(h1.k === h2.k && Curry._2(eq, h1.v, h2.v))) { return false; } _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); @@ -290,9 +287,7 @@ function eqU(s1, s2, eq) { } function eq(s1, s2, f) { - return eqU(s1, s2, (function (a, b) { - return f(a, b); - })); + return eqU(s1, s2, Curry.__2(f)); } function addMutate(t, x, data) { diff --git a/lib/es6/belt_internalMapString.js b/lib/es6/belt_internalMapString.js index d264f68795..303a845146 100644 --- a/lib/es6/belt_internalMapString.js +++ b/lib/es6/belt_internalMapString.js @@ -1,6 +1,7 @@ import * as Caml from "./caml.js"; +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as Belt_SortArray from "./belt_SortArray.js"; import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; @@ -194,7 +195,7 @@ function mergeU(s1, s2, f) { let l1 = s1.l; let r1 = s1.r; let match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, Curry._3(f, v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); } } else if (s2 === undefined) { @@ -205,13 +206,11 @@ function mergeU(s1, s2, f) { let l2 = s2.l; let r2 = s2.r; let match$1 = split(v2, s1); - return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, Curry._3(f, v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); } function merge(s1, s2, f) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - })); + return mergeU(s1, s2, Curry.__3(f)); } function compareAux(_e1, _e2, vcmp) { @@ -230,7 +229,7 @@ function compareAux(_e1, _e2, vcmp) { if (c !== 0) { return c; } - let cx = vcmp(h1.v, h2.v); + let cx = Curry._2(vcmp, h1.v, h2.v); if (cx !== 0) { return cx; } @@ -253,9 +252,7 @@ function cmpU(s1, s2, cmp) { } function cmp(s1, s2, f) { - return cmpU(s1, s2, (function (a, b) { - return f(a, b); - })); + return cmpU(s1, s2, Curry.__2(f)); } function eqAux(_e1, _e2, eq) { @@ -270,7 +267,7 @@ function eqAux(_e1, _e2, eq) { } let h2 = e2.hd; let h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { + if (!(h1.k === h2.k && Curry._2(eq, h1.v, h2.v))) { return false; } _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); @@ -290,9 +287,7 @@ function eqU(s1, s2, eq) { } function eq(s1, s2, f) { - return eqU(s1, s2, (function (a, b) { - return f(a, b); - })); + return eqU(s1, s2, Curry.__2(f)); } function addMutate(t, x, data) { diff --git a/lib/es6/belt_internalSetBuckets.js b/lib/es6/belt_internalSetBuckets.js index e4b289dd09..b045a4bfa0 100644 --- a/lib/es6/belt_internalSetBuckets.js +++ b/lib/es6/belt_internalSetBuckets.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Belt_Array from "./belt_Array.js"; function copyAuxCont(_c, _prec) { @@ -69,7 +70,7 @@ function doBucketIter(f, _buckets) { if (buckets === undefined) { return; } - f(buckets.key); + Curry._1(f, buckets.key); _buckets = buckets.next; continue; }; @@ -83,9 +84,7 @@ function forEachU(h, f) { } function forEach(h, f) { - forEachU(h, (function (a) { - f(a); - })); + forEachU(h, Curry.__1(f)); } function fillArray(_i, arr, _cell) { @@ -124,7 +123,7 @@ function doBucketFold(f, _b, _accu) { if (b === undefined) { return accu; } - _accu = f(accu, b.key); + _accu = Curry._2(f, accu, b.key); _b = b.next; continue; }; @@ -140,9 +139,7 @@ function reduceU(h, init, f) { } function reduce(h, init, f) { - return reduceU(h, init, (function (a, b) { - return f(a, b); - })); + return reduceU(h, init, Curry.__2(f)); } function getMaxBucketLength(h) { diff --git a/lib/es6/buffer.js b/lib/es6/buffer.js index 5a3d7c2b44..034ec0ea08 100644 --- a/lib/es6/buffer.js +++ b/lib/es6/buffer.js @@ -1,6 +1,7 @@ import * as Bytes from "./bytes.js"; +import * as Curry from "./curry.js"; import * as $$String from "./string.js"; import * as Caml_bytes from "./caml_bytes.js"; import * as Caml_string from "./caml_string.js"; @@ -25,39 +26,39 @@ function to_bytes(b) { } function sub(b, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (b.position - len | 0))) { - return Bytes.sub_string(b.buffer, ofs, len); + if (ofs < 0 || len < 0 || ofs > (b.position - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.sub" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.sub" - } - }); + return Bytes.sub_string(b.buffer, ofs, len); } function blit(src, srcoff, dst, dstoff, len) { - if (!(len < 0 || srcoff < 0 || srcoff > (src.position - len | 0) || dstoff < 0 || dstoff > (dst.length - len | 0))) { - return Bytes.blit(src.buffer, srcoff, dst, dstoff, len); + if (len < 0 || srcoff < 0 || srcoff > (src.position - len | 0) || dstoff < 0 || dstoff > (dst.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.blit" - } - }); + Bytes.blit(src.buffer, srcoff, dst, dstoff, len); } function nth(b, ofs) { - if (!(ofs < 0 || ofs >= b.position)) { - return b.buffer[ofs]; + if (ofs < 0 || ofs >= b.position) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.nth" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.nth" - } - }); + return b.buffer[ofs]; } function length(b) { @@ -446,7 +447,7 @@ function add_substitute(b, f, s) { } let j = i + 1 | 0; let match = find_ident(s, j, lim); - add_string(b, f(match[0])); + add_string(b, Curry._1(f, match[0])); _i = match[1]; _previous = /* ' ' */32; continue; @@ -454,16 +455,15 @@ function add_substitute(b, f, s) { } function truncate(b, len) { - if (!(len < 0 || len > b.position)) { - b.position = len; - return; + if (len < 0 || len > b.position) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.truncate" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.truncate" - } - }); + b.position = len; } export { diff --git a/lib/es6/bytes.js b/lib/es6/bytes.js index c0ae45e111..c47cca3ffb 100644 --- a/lib/es6/bytes.js +++ b/lib/es6/bytes.js @@ -2,6 +2,7 @@ import * as Caml from "./caml.js"; import * as Char from "./char.js"; +import * as Curry from "./curry.js"; import * as Caml_bytes from "./caml_bytes.js"; import * as Caml_js_exceptions from "./caml_js_exceptions.js"; @@ -63,7 +64,7 @@ function make(n, c) { function init(n, f) { let s = Caml_bytes.create(n); for(let i = 0; i < n; ++i){ - s[i] = f(i); + s[i] = Curry._1(f, i); } return s; } @@ -148,15 +149,15 @@ function $plus$plus(a, b) { if (match$1) { return c; } - if (!match$2) { - return c; + if (match$2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.extend" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.extend" - } - }); + return c; } function extend(s, left, right) { @@ -179,66 +180,65 @@ function extend(s, left, right) { } function fill(s, ofs, len, c) { - if (!(ofs < 0 || len < 0 || ofs > (s.length - len | 0))) { - return unsafe_fill(s, ofs, len, c); + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.fill / Bytes.fill" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.fill / Bytes.fill" - } - }); + unsafe_fill(s, ofs, len, c); } function blit(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - return unsafe_blit(s1, ofs1, s2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.blit" - } - }); + unsafe_blit(s1, ofs1, s2, ofs2, len); } function blit_string(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - if (len <= 0) { - return; - } - let off1 = s1.length - ofs1 | 0; - if (len <= off1) { - for(let i = 0; i < len; ++i){ - s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); - } - return; - } - for(let i$1 = 0; i$1 < off1; ++i$1){ - s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); - } - for(let i$2 = off1; i$2 < len; ++i$2){ - s2[ofs2 + i$2 | 0] = /* '\000' */0; + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.blit / Bytes.blit_string" + } + }); + } + if (len <= 0) { + return; + } + let off1 = s1.length - ofs1 | 0; + if (len <= off1) { + for(let i = 0; i < len; ++i){ + s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); } return; } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.blit / Bytes.blit_string" - } - }); + for(let i$1 = 0; i$1 < off1; ++i$1){ + s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); + } + for(let i$2 = off1; i$2 < len; ++i$2){ + s2[ofs2 + i$2 | 0] = /* '\000' */0; + } } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -446,7 +446,7 @@ function map(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(s[i]); + r[i] = Curry._1(f, s[i]); } return r; } @@ -458,7 +458,7 @@ function mapi(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(i, s[i]); + r[i] = Curry._2(f, i, s[i]); } return r; } @@ -476,7 +476,7 @@ function apply1(f, s) { return s; } let r = copy(s); - r[0] = f(s[0]); + r[0] = Curry._1(f, s[0]); return r; } @@ -530,28 +530,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -577,15 +577,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -607,15 +607,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/es6/bytesLabels.js b/lib/es6/bytesLabels.js index c0ae45e111..c47cca3ffb 100644 --- a/lib/es6/bytesLabels.js +++ b/lib/es6/bytesLabels.js @@ -2,6 +2,7 @@ import * as Caml from "./caml.js"; import * as Char from "./char.js"; +import * as Curry from "./curry.js"; import * as Caml_bytes from "./caml_bytes.js"; import * as Caml_js_exceptions from "./caml_js_exceptions.js"; @@ -63,7 +64,7 @@ function make(n, c) { function init(n, f) { let s = Caml_bytes.create(n); for(let i = 0; i < n; ++i){ - s[i] = f(i); + s[i] = Curry._1(f, i); } return s; } @@ -148,15 +149,15 @@ function $plus$plus(a, b) { if (match$1) { return c; } - if (!match$2) { - return c; + if (match$2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.extend" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.extend" - } - }); + return c; } function extend(s, left, right) { @@ -179,66 +180,65 @@ function extend(s, left, right) { } function fill(s, ofs, len, c) { - if (!(ofs < 0 || len < 0 || ofs > (s.length - len | 0))) { - return unsafe_fill(s, ofs, len, c); + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.fill / Bytes.fill" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.fill / Bytes.fill" - } - }); + unsafe_fill(s, ofs, len, c); } function blit(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - return unsafe_blit(s1, ofs1, s2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.blit" - } - }); + unsafe_blit(s1, ofs1, s2, ofs2, len); } function blit_string(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - if (len <= 0) { - return; - } - let off1 = s1.length - ofs1 | 0; - if (len <= off1) { - for(let i = 0; i < len; ++i){ - s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); - } - return; - } - for(let i$1 = 0; i$1 < off1; ++i$1){ - s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); - } - for(let i$2 = off1; i$2 < len; ++i$2){ - s2[ofs2 + i$2 | 0] = /* '\000' */0; + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.blit / Bytes.blit_string" + } + }); + } + if (len <= 0) { + return; + } + let off1 = s1.length - ofs1 | 0; + if (len <= off1) { + for(let i = 0; i < len; ++i){ + s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); } return; } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.blit / Bytes.blit_string" - } - }); + for(let i$1 = 0; i$1 < off1; ++i$1){ + s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); + } + for(let i$2 = off1; i$2 < len; ++i$2){ + s2[ofs2 + i$2 | 0] = /* '\000' */0; + } } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -446,7 +446,7 @@ function map(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(s[i]); + r[i] = Curry._1(f, s[i]); } return r; } @@ -458,7 +458,7 @@ function mapi(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(i, s[i]); + r[i] = Curry._2(f, i, s[i]); } return r; } @@ -476,7 +476,7 @@ function apply1(f, s) { return s; } let r = copy(s); - r[0] = f(s[0]); + r[0] = Curry._1(f, s[0]); return r; } @@ -530,28 +530,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -577,15 +577,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -607,15 +607,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/es6/caml.js b/lib/es6/caml.js index 65242212b2..a85e2555f3 100644 --- a/lib/es6/caml.js +++ b/lib/es6/caml.js @@ -166,10 +166,10 @@ function i64_le(x, y) { } function i64_min(x, y) { - if (i64_lt(x, y)) { - return x; - } else { + if (i64_ge(x, y)) { return y; + } else { + return x; } } diff --git a/lib/es6/camlinternalLazy.js b/lib/es6/camlinternalLazy.js index cf6061cc29..6315f50de6 100644 --- a/lib/es6/camlinternalLazy.js +++ b/lib/es6/camlinternalLazy.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_exceptions from "./caml_exceptions.js"; function is_val(l) { @@ -9,7 +10,7 @@ function is_val(l) { let Undefined = /* @__PURE__ */Caml_exceptions.create("CamlinternalLazy.Undefined"); function forward_with_closure(blk, closure) { - let result = closure(); + let result = Curry._1(closure, undefined); blk.VAL = result; blk.LAZY_DONE = true; return result; diff --git a/lib/es6/char.js b/lib/es6/char.js index 3c49e01262..3e41fcddf6 100644 --- a/lib/es6/char.js +++ b/lib/es6/char.js @@ -3,15 +3,15 @@ import * as Bytes from "./bytes.js"; function chr(n) { - if (!(n < 0 || n > 255)) { - return n; + if (n < 0 || n > 255) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Char.chr" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Char.chr" - } - }); + return n; } function escaped(param) { diff --git a/lib/es6/digest.js b/lib/es6/digest.js index 8025c68591..d321133827 100644 --- a/lib/es6/digest.js +++ b/lib/es6/digest.js @@ -16,15 +16,15 @@ function bytes(b) { } function substring(str, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (str.length - len | 0))) { - return Caml_md5.md5_string(str, ofs, len); + if (ofs < 0 || len < 0 || ofs > (str.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Digest.substring" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Digest.substring" - } - }); + return Caml_md5.md5_string(str, ofs, len); } function subbytes(b, ofs, len) { diff --git a/lib/es6/filename.js b/lib/es6/filename.js index f894484288..0c8667c1ee 100644 --- a/lib/es6/filename.js +++ b/lib/es6/filename.js @@ -1,6 +1,8 @@ import * as Sys from "./sys.js"; +import * as Bytes from "./bytes.js"; +import * as Curry from "./curry.js"; import * as Buffer from "./buffer.js"; import * as $$String from "./string.js"; import * as Caml_sys from "./caml_sys.js"; @@ -17,7 +19,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - if (!is_dir_sep(name, n)) { + if (!Curry._2(is_dir_sep, name, n)) { let _n$1 = n; let p = n + 1 | 0; while(true) { @@ -25,7 +27,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n$1 < 0) { return $$String.sub(name, 0, p); } - if (is_dir_sep(name, n$1)) { + if (Curry._2(is_dir_sep, name, n$1)) { return $$String.sub(name, n$1 + 1 | 0, (p - n$1 | 0) - 1 | 0); } _n$1 = n$1 - 1 | 0; @@ -48,21 +50,21 @@ function generic_dirname(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - if (!is_dir_sep(name, n)) { + if (!Curry._2(is_dir_sep, name, n)) { let _n$1 = n; while(true) { let n$1 = _n$1; if (n$1 < 0) { return current_dir_name; } - if (is_dir_sep(name, n$1)) { + if (Curry._2(is_dir_sep, name, n$1)) { let _n$2 = n$1; while(true) { let n$2 = _n$2; if (n$2 < 0) { return $$String.sub(name, 0, 1); } - if (!is_dir_sep(name, n$2)) { + if (!Curry._2(is_dir_sep, name, n$2)) { return $$String.sub(name, 0, n$2 + 1 | 0); } _n$2 = n$2 - 1 | 0; @@ -193,7 +195,7 @@ function check_suffix$1(name, suff) { return false; } let s = $$String.sub(name, name.length - suff.length | 0, suff.length); - return $$String.lowercase_ascii(s) === $$String.lowercase_ascii(suff); + return Bytes.unsafe_to_string(Bytes.lowercase_ascii(Bytes.unsafe_of_string(s))) === Bytes.unsafe_to_string(Bytes.lowercase_ascii(Bytes.unsafe_of_string(suff))); } let temp_dir_name$1; @@ -373,7 +375,7 @@ let dir_sep = match[2]; function concat(dirname, filename) { let l = dirname.length; - if (l === 0 || is_dir_sep$2(dirname, l - 1 | 0)) { + if (l === 0 || Curry._2(is_dir_sep$2, dirname, l - 1 | 0)) { return dirname + filename; } else { return dirname + (dir_sep + filename); @@ -382,29 +384,29 @@ function concat(dirname, filename) { function chop_suffix(name, suff) { let n = name.length - suff.length | 0; - if (n >= 0) { - return $$String.sub(name, 0, n); + if (n < 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Filename.chop_suffix" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Filename.chop_suffix" - } - }); + return $$String.sub(name, 0, n); } function extension_len(name) { let _i = name.length - 1 | 0; while(true) { let i = _i; - if (i < 0 || is_dir_sep$2(name, i)) { + if (i < 0 || Curry._2(is_dir_sep$2, name, i)) { return 0; } if (Caml_string.get(name, i) === /* '.' */46) { let _i$1 = i - 1 | 0; while(true) { let i$1 = _i$1; - if (i$1 < 0 || is_dir_sep$2(name, i$1)) { + if (i$1 < 0 || Curry._2(is_dir_sep$2, name, i$1)) { return 0; } if (Caml_string.get(name, i$1) !== /* '.' */46) { @@ -430,15 +432,15 @@ function extension(name) { function chop_extension(name) { let l = extension_len(name); - if (l !== 0) { - return $$String.sub(name, 0, name.length - l | 0); + if (l === 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Filename.chop_extension" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Filename.chop_extension" - } - }); + return $$String.sub(name, 0, name.length - l | 0); } function remove_extension(name) { diff --git a/lib/es6/genlex.js b/lib/es6/genlex.js index 5a0b8ed711..db2acdd716 100644 --- a/lib/es6/genlex.js +++ b/lib/es6/genlex.js @@ -105,8 +105,8 @@ function make_lexer(keywords) { case 13 : case 26 : case 32 : - exit = 2; - break; + Stream.junk(strm__); + continue; case 34 : Stream.junk(strm__); reset_buffer(); @@ -175,10 +175,11 @@ function make_lexer(keywords) { store(/* '-' */45); store(c$2); return number(strm__); + } else { + reset_buffer(); + store(/* '-' */45); + return ident2(strm__); } - reset_buffer(); - store(/* '-' */45); - return ident2(strm__); case 48 : case 49 : case 50 : @@ -189,7 +190,7 @@ function make_lexer(keywords) { case 55 : case 56 : case 57 : - exit = 5; + exit = 4; break; case 0 : case 1 : @@ -238,7 +239,7 @@ function make_lexer(keywords) { case 62 : case 63 : case 64 : - exit = 4; + exit = 3; break; } @@ -247,7 +248,7 @@ function make_lexer(keywords) { switch (c) { case 92 : case 94 : - exit = 4; + exit = 3; break; case 91 : case 93 : @@ -255,14 +256,14 @@ function make_lexer(keywords) { exit = 1; break; default: - exit = 3; + exit = 2; } } } else { exit = c >= 127 ? ( - c > 255 || c < 192 ? 1 : 3 + c > 255 || c < 192 ? 1 : 2 ) : ( - c !== 125 ? 4 : 1 + c !== 125 ? 3 : 1 ); } switch (exit) { @@ -270,49 +271,42 @@ function make_lexer(keywords) { Stream.junk(strm__); return keyword_or_error(c); case 2 : - Stream.junk(strm__); - continue; - case 3 : Stream.junk(strm__); reset_buffer(); store(c); while(true) { let c$3 = Stream.peek(strm__); - if (c$3 !== undefined) { - let exit$1 = 0; - if (c$3 >= 91) { - if (c$3 > 122 || c$3 < 95) { - if (!(c$3 > 255 || c$3 < 192)) { - exit$1 = 2; - } - - } else if (c$3 !== 96) { - exit$1 = 2; - } - - } else if (c$3 >= 48) { - if (c$3 > 64 || c$3 < 58) { - exit$1 = 2; + if (c$3 === undefined) { + return ident_or_keyword(get_string()); + } + if (c$3 >= 91) { + if (c$3 > 122 || c$3 < 95) { + if (c$3 > 255 || c$3 < 192) { + return ident_or_keyword(get_string()); } - } else if (c$3 === 39) { - exit$1 = 2; + } else if (c$3 === 96) { + return ident_or_keyword(get_string()); } - if (exit$1 === 2) { - Stream.junk(strm__); - store(c$3); - continue; + + } else if (c$3 >= 48) { + if (!(c$3 > 64 || c$3 < 58)) { + return ident_or_keyword(get_string()); } + } else if (c$3 !== 39) { + return ident_or_keyword(get_string()); } - return ident_or_keyword(get_string()); + Stream.junk(strm__); + store(c$3); + continue; }; - case 4 : + case 3 : Stream.junk(strm__); reset_buffer(); store(c); return ident2(strm__); - case 5 : + case 4 : Stream.junk(strm__); reset_buffer(); store(c); @@ -324,81 +318,80 @@ function make_lexer(keywords) { let ident2 = function (strm__) { while(true) { let c = Stream.peek(strm__); - if (c !== undefined) { - let exit = 0; - if (c >= 94) { - if (c > 125 || c < 95) { - if (c < 127) { - exit = 2; - } - - } else if (c === 124) { - exit = 2; - } - - } else if (c >= 65) { - if (c === 92) { - exit = 2; + if (c === undefined) { + return ident_or_keyword(get_string()); + } + if (c >= 94) { + if (c > 125 || c < 95) { + if (c >= 127) { + return ident_or_keyword(get_string()); } - } else if (c >= 33) { - switch (c) { - case 34 : - case 39 : - case 40 : - case 41 : - case 44 : - case 46 : - case 48 : - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - case 55 : - case 56 : - case 57 : - case 59 : - break; - case 33 : - case 35 : - case 36 : - case 37 : - case 38 : - case 42 : - case 43 : - case 45 : - case 47 : - case 58 : - case 60 : - case 61 : - case 62 : - case 63 : - case 64 : - exit = 2; - break; - - } + } else if (c !== 124) { + return ident_or_keyword(get_string()); } - if (exit === 2) { - Stream.junk(strm__); - store(c); - continue; + + } else if (c >= 65) { + if (c !== 92) { + return ident_or_keyword(get_string()); } + } else { + if (c < 33) { + return ident_or_keyword(get_string()); + } + switch (c) { + case 34 : + case 39 : + case 40 : + case 41 : + case 44 : + case 46 : + case 48 : + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + case 59 : + return ident_or_keyword(get_string()); + case 33 : + case 35 : + case 36 : + case 37 : + case 38 : + case 42 : + case 43 : + case 45 : + case 47 : + case 58 : + case 60 : + case 61 : + case 62 : + case 63 : + case 64 : + break; + + } } - return ident_or_keyword(get_string()); + Stream.junk(strm__); + store(c); + continue; }; }; let number = function (strm__) { while(true) { let c = Stream.peek(strm__); if (c !== undefined) { - let exit = 0; if (c >= 58) { if (!(c !== 69 && c !== 101)) { - exit = 2; + Stream.junk(strm__); + store(/* 'E' */69); + return exponent_part(strm__); } } else if (c !== 46) { @@ -434,12 +427,6 @@ function make_lexer(keywords) { }; }; } - if (exit === 2) { - Stream.junk(strm__); - store(/* 'E' */69); - return exponent_part(strm__); - } - } return { TAG: "Int", @@ -449,15 +436,13 @@ function make_lexer(keywords) { }; let exponent_part = function (strm__) { let c = Stream.peek(strm__); - if (c === undefined) { + if (c !== undefined && !(c !== 43 && c !== 45)) { + Stream.junk(strm__); + store(c); return end_exponent_part(strm__); - } - if (c !== 43 && c !== 45) { + } else { return end_exponent_part(strm__); } - Stream.junk(strm__); - store(c); - return end_exponent_part(strm__); }; let end_exponent_part = function (strm__) { while(true) { @@ -692,4 +677,4 @@ function make_lexer(keywords) { export { make_lexer, } -/* Hashtbl Not a pure module */ +/* No side effect */ diff --git a/lib/es6/hashtbl.js b/lib/es6/hashtbl.js index ca21010481..3148f3046b 100644 --- a/lib/es6/hashtbl.js +++ b/lib/es6/hashtbl.js @@ -1,8 +1,8 @@ import * as Caml from "./caml.js"; -import * as Lazy from "./lazy.js"; import * as $$Array from "./array.js"; +import * as Curry from "./curry.js"; import * as Random from "./random.js"; import * as Caml_obj from "./caml_obj.js"; import * as Caml_hash from "./caml_hash.js"; @@ -39,7 +39,7 @@ function is_randomized() { return randomized.contents; } -let prng = Lazy.from_fun(function () { +let prng = CamlinternalLazy.from_fun(function () { return Random.State.make_self_init(); }); @@ -178,7 +178,7 @@ function resize(indexfun, h) { data: data, next: "Empty" }); - let nidx = indexfun(h, key); + let nidx = Curry._2(indexfun, h, key); let tail = Caml_array.get(ndata_tail, nidx); if (typeof tail !== "object") { Caml_array.set(ndata, nidx, cell); @@ -450,7 +450,7 @@ function iter(f, h) { let key = param.key; let data = param.data; let next = param.next; - f(key, data); + Curry._2(f, key, data); _param = next; continue; }; @@ -498,7 +498,7 @@ function filter_map_inplace_bucket(f, h, i, _prec, _param) { let key = param.key; let data = param.data; let next = param.next; - let data$1 = f(key, data); + let data$1 = Curry._2(f, key, data); if (data$1 !== undefined) { if (typeof prec !== "object") { Caml_array.set(h.data, i, param); @@ -552,7 +552,7 @@ function fold(f, h, init) { let key = b.key; let data = b.data; let next = b.next; - _accu = f(key, data, accu); + _accu = Curry._3(f, key, data, accu); _b = next; continue; }; @@ -618,7 +618,7 @@ function stats(h) { function MakeSeeded(H) { let key_index = function (h, key) { - return H.hash(h.seed, key) & (h.data.length - 1 | 0); + return Curry._2(H.hash, h.seed, key) & (h.data.length - 1 | 0); }; let add = function (h, key, data) { let i = key_index(h, key); @@ -647,7 +647,7 @@ function MakeSeeded(H) { } let k = param.key; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { h.size = h.size - 1 | 0; if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); @@ -673,7 +673,7 @@ function MakeSeeded(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (H.equal(key, k1)) { + if (Curry._2(H.equal, key, k1)) { return d1; } if (typeof next1 !== "object") { @@ -686,7 +686,7 @@ function MakeSeeded(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (H.equal(key, k2)) { + if (Curry._2(H.equal, key, k2)) { return d2; } if (typeof next2 !== "object") { @@ -699,7 +699,7 @@ function MakeSeeded(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (H.equal(key, k3)) { + if (Curry._2(H.equal, key, k3)) { return d3; } else { let _param = next3; @@ -715,7 +715,7 @@ function MakeSeeded(H) { let k = param.key; let data = param.data; let next = param.next; - if (H.equal(key, k)) { + if (Curry._2(H.equal, key, k)) { return data; } _param = next; @@ -731,7 +731,7 @@ function MakeSeeded(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (H.equal(key, k1)) { + if (Curry._2(H.equal, key, k1)) { return Caml_option.some(d1); } if (typeof next1 !== "object") { @@ -740,7 +740,7 @@ function MakeSeeded(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (H.equal(key, k2)) { + if (Curry._2(H.equal, key, k2)) { return Caml_option.some(d2); } if (typeof next2 !== "object") { @@ -749,7 +749,7 @@ function MakeSeeded(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (H.equal(key, k3)) { + if (Curry._2(H.equal, key, k3)) { return Caml_option.some(d3); } else { let _param = next3; @@ -761,7 +761,7 @@ function MakeSeeded(H) { let k = param.key; let data = param.data; let next = param.next; - if (H.equal(key, k)) { + if (Curry._2(H.equal, key, k)) { return Caml_option.some(data); } _param = next; @@ -779,7 +779,7 @@ function MakeSeeded(H) { let k = param.key; let d = param.data; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { return { hd: d, tl: find_in_bucket(next) @@ -799,7 +799,7 @@ function MakeSeeded(H) { } let k = param.key; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { param.key = key; param.data = data; return false; @@ -836,7 +836,7 @@ function MakeSeeded(H) { } let k = param.key; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { return true; } _param = next; @@ -866,7 +866,7 @@ function MakeSeeded(H) { function Make(H) { let equal = H.equal; let key_index = function (h, key) { - return H.hash(key) & (h.data.length - 1 | 0); + return Curry._1(H.hash, key) & (h.data.length - 1 | 0); }; let add = function (h, key, data) { let i = key_index(h, key); @@ -895,7 +895,7 @@ function Make(H) { } let k = param.key; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { h.size = h.size - 1 | 0; if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); @@ -921,7 +921,7 @@ function Make(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (equal(key, k1)) { + if (Curry._2(equal, key, k1)) { return d1; } if (typeof next1 !== "object") { @@ -934,7 +934,7 @@ function Make(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (equal(key, k2)) { + if (Curry._2(equal, key, k2)) { return d2; } if (typeof next2 !== "object") { @@ -947,7 +947,7 @@ function Make(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (equal(key, k3)) { + if (Curry._2(equal, key, k3)) { return d3; } else { let _param = next3; @@ -963,7 +963,7 @@ function Make(H) { let k = param.key; let data = param.data; let next = param.next; - if (equal(key, k)) { + if (Curry._2(equal, key, k)) { return data; } _param = next; @@ -979,7 +979,7 @@ function Make(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (equal(key, k1)) { + if (Curry._2(equal, key, k1)) { return Caml_option.some(d1); } if (typeof next1 !== "object") { @@ -988,7 +988,7 @@ function Make(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (equal(key, k2)) { + if (Curry._2(equal, key, k2)) { return Caml_option.some(d2); } if (typeof next2 !== "object") { @@ -997,7 +997,7 @@ function Make(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (equal(key, k3)) { + if (Curry._2(equal, key, k3)) { return Caml_option.some(d3); } else { let _param = next3; @@ -1009,7 +1009,7 @@ function Make(H) { let k = param.key; let data = param.data; let next = param.next; - if (equal(key, k)) { + if (Curry._2(equal, key, k)) { return Caml_option.some(data); } _param = next; @@ -1027,7 +1027,7 @@ function Make(H) { let k = param.key; let d = param.data; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { return { hd: d, tl: find_in_bucket(next) @@ -1047,7 +1047,7 @@ function Make(H) { } let k = param.key; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { param.key = key; param.data = data; return false; @@ -1084,7 +1084,7 @@ function Make(H) { } let k = param.key; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { return true; } _param = next; @@ -1142,4 +1142,4 @@ export { hash_param, seeded_hash_param, } -/* prng Not a pure module */ +/* No side effect */ diff --git a/lib/es6/hashtblLabels.js b/lib/es6/hashtblLabels.js index 9b3a3844a1..168edfb9c1 100644 --- a/lib/es6/hashtblLabels.js +++ b/lib/es6/hashtblLabels.js @@ -1,31 +1,22 @@ +import * as Curry from "./curry.js"; import * as Hashtbl from "./hashtbl.js"; -function add(tbl, key, data) { - Hashtbl.add(tbl, key, data); -} +let add = Hashtbl.add; -function replace(tbl, key, data) { - Hashtbl.replace(tbl, key, data); -} +let replace = Hashtbl.replace; function iter(f, tbl) { - Hashtbl.iter((function (key, data) { - f(key, data); - }), tbl); + Hashtbl.iter(Curry.__2(f), tbl); } function filter_map_inplace(f, tbl) { - Hashtbl.filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Hashtbl.filter_map_inplace(Curry.__2(f), tbl); } function fold(f, tbl, init) { - return Hashtbl.fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Hashtbl.fold(Curry.__3(f), tbl, init); } function MakeSeeded(H) { @@ -35,26 +26,16 @@ function MakeSeeded(H) { let iter = include.iter; let filter_map_inplace = include.filter_map_inplace; let fold = include.fold; - let add$1 = function (tbl, key, data) { - add(tbl, key, data); - }; - let replace$1 = function (tbl, key, data) { - replace(tbl, key, data); - }; + let add$1 = Curry.__3(add); + let replace$1 = Curry.__3(replace); let iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); + Curry._2(iter, Curry.__2(f), tbl); }; let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Curry._2(filter_map_inplace, Curry.__2(f), tbl); }; let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Curry._3(fold, Curry.__3(f), tbl, init); }; return { create: include.create, @@ -78,7 +59,7 @@ function MakeSeeded(H) { function Make(H) { let hash = function (_seed, x) { - return H.hash(x); + return Curry._1(H.hash, x); }; let H_equal = H.equal; let H$1 = { @@ -92,29 +73,19 @@ function Make(H) { let iter = include.iter; let filter_map_inplace = include.filter_map_inplace; let fold = include.fold; - let add$1 = function (tbl, key, data) { - add(tbl, key, data); - }; - let replace$1 = function (tbl, key, data) { - replace(tbl, key, data); - }; + let add$1 = Curry.__3(add); + let replace$1 = Curry.__3(replace); let iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); + Curry._2(iter, Curry.__2(f), tbl); }; let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Curry._2(filter_map_inplace, Curry.__2(f), tbl); }; let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Curry._3(fold, Curry.__3(f), tbl, init); }; let create$1 = function (sz) { - return create(false, sz); + return Curry._2(create, false, sz); }; return { create: create$1, @@ -196,4 +167,4 @@ export { MakeSeeded, Make, } -/* Hashtbl Not a pure module */ +/* No side effect */ diff --git a/lib/es6/js_dict.js b/lib/es6/js_dict.js index aada879bc8..fe3266980f 100644 --- a/lib/es6/js_dict.js +++ b/lib/es6/js_dict.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function get(dict, k) { @@ -68,7 +69,7 @@ function map(f, source) { let l = keys.length; for(let i = 0; i < l; ++i){ let key = keys[i]; - target[key] = f(source[key]); + target[key] = Curry._1(f, source[key]); } return target; } diff --git a/lib/es6/js_null.js b/lib/es6/js_null.js index c6706e56a8..1c8221b3d3 100644 --- a/lib/es6/js_null.js +++ b/lib/es6/js_null.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function test(x) { @@ -17,7 +18,7 @@ function getExn(f) { function bind(x, f) { if (x !== null) { - return f(x); + return Curry._1(f, x); } else { return null; } @@ -25,7 +26,7 @@ function bind(x, f) { function iter(x, f) { if (x !== null) { - return f(x); + return Curry._1(f, x); } } diff --git a/lib/es6/js_null_undefined.js b/lib/es6/js_null_undefined.js index 58e5799d43..4eaa8bb6c1 100644 --- a/lib/es6/js_null_undefined.js +++ b/lib/es6/js_null_undefined.js @@ -1,18 +1,19 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function bind(x, f) { if (x == null) { return x; } else { - return f(x); + return Curry._1(f, x); } } function iter(x, f) { if (!(x == null)) { - return f(x); + return Curry._1(f, x); } } diff --git a/lib/es6/js_option.js b/lib/es6/js_option.js index 73e0a2f8ad..348111e698 100644 --- a/lib/es6/js_option.js +++ b/lib/es6/js_option.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function some(x) { @@ -12,7 +13,7 @@ function isSome(x) { function isSomeValue(eq, v, x) { if (x !== undefined) { - return eq(v, Caml_option.valFromOption(x)); + return Curry._2(eq, v, Caml_option.valFromOption(x)); } else { return false; } @@ -34,7 +35,7 @@ function getExn(x) { function equal(eq, a, b) { if (a !== undefined) { if (b !== undefined) { - return eq(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return Curry._2(eq, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return false; } @@ -45,14 +46,14 @@ function equal(eq, a, b) { function andThen(f, x) { if (x !== undefined) { - return f(Caml_option.valFromOption(x)); + return Curry._1(f, Caml_option.valFromOption(x)); } } function map(f, x) { if (x !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(x))); + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(x))); } } @@ -70,7 +71,7 @@ function filter(f, x) { return; } let x$1 = Caml_option.valFromOption(x); - if (f(x$1)) { + if (Curry._1(f, x$1)) { return Caml_option.some(x$1); } diff --git a/lib/es6/js_undefined.js b/lib/es6/js_undefined.js index 68411f013f..3a22b46f6b 100644 --- a/lib/es6/js_undefined.js +++ b/lib/es6/js_undefined.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function test(x) { @@ -21,14 +22,14 @@ function getExn(f) { function bind(x, f) { if (x !== undefined) { - return f(x); + return Curry._1(f, x); } } function iter(x, f) { if (x !== undefined) { - return f(x); + return Curry._1(f, x); } } diff --git a/lib/es6/lazy.js b/lib/es6/lazy.js index 9153ac974b..1adb9d296b 100644 --- a/lib/es6/lazy.js +++ b/lib/es6/lazy.js @@ -1,16 +1,15 @@ +import * as Curry from "./curry.js"; import * as CamlinternalLazy from "./camlinternalLazy.js"; function from_fun(f) { return CamlinternalLazy.from_fun(function () { - return f(); + return Curry._1(f, undefined); }); } -function from_val(v) { - return CamlinternalLazy.from_val(v); -} +let from_val = CamlinternalLazy.from_val; let Undefined = CamlinternalLazy.Undefined; diff --git a/lib/es6/lexing.js b/lib/es6/lexing.js index e2f6ccdb75..68c6aedf48 100644 --- a/lib/es6/lexing.js +++ b/lib/es6/lexing.js @@ -1,6 +1,7 @@ import * as Bytes from "./bytes.js"; +import * as Curry from "./curry.js"; import * as Caml_array from "./caml_array.js"; import * as Caml_bytes from "./caml_bytes.js"; import * as Caml_lexer from "./caml_lexer.js"; @@ -46,7 +47,7 @@ function from_function(f) { return { refill_buff: (function (x) { let aux_buffer = Caml_bytes.create(512); - let read = f(aux_buffer, aux_buffer.length); + let read = Curry._2(f, aux_buffer, aux_buffer.length); let n = read > 0 ? read : (x.lex_eof_reached = true, 0); if ((x.lex_buffer_len + n | 0) > x.lex_buffer.length) { if (((x.lex_buffer_len - x.lex_start_pos | 0) + n | 0) <= x.lex_buffer.length) { diff --git a/lib/es6/list.js b/lib/es6/list.js index 75645dc081..679fc2fd40 100644 --- a/lib/es6/list.js +++ b/lib/es6/list.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_obj from "./caml_obj.js"; import * as Pervasives from "./pervasives.js"; import * as Caml_option from "./caml_option.js"; @@ -136,7 +137,7 @@ function init_tailrec_aux(_acc, _i, n, f) { } _i = i + 1 | 0; _acc = { - hd: f(i), + hd: Curry._1(f, i), tl: acc }; continue; @@ -147,7 +148,7 @@ function init_aux(i, n, f) { if (i >= n) { return /* [] */0; } - let r = f(i); + let r = Curry._1(f, i); return { hd: r, tl: init_aux(i + 1 | 0, n, f) @@ -155,19 +156,19 @@ function init_aux(i, n, f) { } function init(len, f) { - if (len >= 0) { - if (len > 10000) { - return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); - } else { - return init_aux(0, len, f); - } + if (len < 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.init" + } + }); + } + if (len > 10000) { + return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); + } else { + return init_aux(0, len, f); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.init" - } - }); } function flatten(param) { @@ -182,7 +183,7 @@ function map(f, param) { if (!param) { return /* [] */0; } - let r = f(param.hd); + let r = Curry._1(f, param.hd); return { hd: r, tl: map(f, param.tl) @@ -193,7 +194,7 @@ function mapi(i, f, param) { if (!param) { return /* [] */0; } - let r = f(i, param.hd); + let r = Curry._2(f, i, param.hd); return { hd: r, tl: mapi(i + 1 | 0, f, param.tl) @@ -215,7 +216,7 @@ function rev_map(f, l) { } _param = param.tl; _accu = { - hd: f(param.hd), + hd: Curry._1(f, param.hd), tl: accu }; continue; @@ -228,7 +229,7 @@ function iter(f, _param) { if (!param) { return; } - f(param.hd); + Curry._1(f, param.hd); _param = param.tl; continue; }; @@ -243,7 +244,7 @@ function iteri(f, l) { if (!param) { return; } - f(i, param.hd); + Curry._2(f, i, param.hd); _param = param.tl; _i = i + 1 | 0; continue; @@ -258,14 +259,14 @@ function fold_left(f, _accu, _l) { return accu; } _l = l.tl; - _accu = f(accu, l.hd); + _accu = Curry._2(f, accu, l.hd); continue; }; } function fold_right(f, l, accu) { if (l) { - return f(l.hd, fold_right(f, l.tl, accu)); + return Curry._2(f, l.hd, fold_right(f, l.tl, accu)); } else { return accu; } @@ -274,7 +275,7 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - let r = f(l1.hd, l2.hd); + let r = Curry._2(f, l1.hd, l2.hd); return { hd: r, tl: map2(f, l1.tl, l2.tl) @@ -311,7 +312,7 @@ function rev_map2(f, l1, l2) { _l2 = l2$1.tl; _l1 = l1$1.tl; _accu = { - hd: f(l1$1.hd, l2$1.hd), + hd: Curry._2(f, l1$1.hd, l2$1.hd), tl: accu }; continue; @@ -323,15 +324,15 @@ function rev_map2(f, l1, l2) { } }); } - if (!l2$1) { - return accu; + if (l2$1) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.rev_map2" - } - }); + return accu; }; } @@ -341,7 +342,7 @@ function iter2(f, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - f(l1.hd, l2.hd); + Curry._2(f, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -374,7 +375,7 @@ function fold_left2(f, _accu, _l1, _l2) { if (l2) { _l2 = l2.tl; _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); + _accu = Curry._3(f, accu, l1.hd, l2.hd); continue; } throw new Error("Invalid_argument", { @@ -384,22 +385,22 @@ function fold_left2(f, _accu, _l1, _l2) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_left2" - } - }); + return accu; }; } function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + return Curry._3(f, l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } throw new Error("Invalid_argument", { cause: { @@ -408,15 +409,15 @@ function fold_right2(f, l1, l2, accu) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2" - } - }); + return accu; } function for_all(p, _param) { @@ -425,7 +426,7 @@ function for_all(p, _param) { if (!param) { return true; } - if (!p(param.hd)) { + if (!Curry._1(p, param.hd)) { return false; } _param = param.tl; @@ -439,7 +440,7 @@ function exists(p, _param) { if (!param) { return false; } - if (p(param.hd)) { + if (Curry._1(p, param.hd)) { return true; } _param = param.tl; @@ -453,7 +454,7 @@ function for_all2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -485,7 +486,7 @@ function exists2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (p(l1.hd, l2.hd)) { + if (Curry._2(p, l1.hd, l2.hd)) { return true; } _l2 = l2.tl; @@ -672,7 +673,7 @@ function find(p, _param) { let param = _param; if (param) { let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return x; } _param = param.tl; @@ -693,7 +694,7 @@ function find_opt(p, _param) { return; } let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return Caml_option.some(x); } _param = param.tl; @@ -712,7 +713,7 @@ function find_all(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _accu = { hd: x, @@ -741,7 +742,7 @@ function partition(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _yes = { hd: x, @@ -817,7 +818,7 @@ function merge(cmp, l1, l2) { } let h2 = l2.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { return { hd: h1, tl: merge(cmp, l1.tl, l2) @@ -866,8 +867,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { + if (Curry._2(cmp, x1, x2) <= 0) { + if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x1, tl: { @@ -878,7 +879,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x1, tl: { @@ -901,7 +902,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x2, tl: { @@ -912,7 +913,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) <= 0) { + } else if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x2, tl: { @@ -946,7 +947,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) <= 0) { + if (Curry._2(cmp, x1$1, x2$1) <= 0) { return { hd: x1$1, tl: { @@ -986,7 +987,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) > 0) { + if (Curry._2(cmp, h1, h2) > 0) { _accu = { hd: h1, tl: accu @@ -1012,8 +1013,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { + if (Curry._2(cmp, x1, x2) > 0) { + if (Curry._2(cmp, x2, x3) > 0) { return { hd: x1, tl: { @@ -1024,7 +1025,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x1, tl: { @@ -1047,7 +1048,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x2, tl: { @@ -1058,7 +1059,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) > 0) { + } else if (Curry._2(cmp, x2, x3) > 0) { return { hd: x2, tl: { @@ -1092,7 +1093,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) > 0) { + if (Curry._2(cmp, x1$1, x2$1) > 0) { return { hd: x1$1, tl: { @@ -1132,7 +1133,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { _accu = { hd: h1, tl: accu @@ -1167,9 +1168,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1194,7 +1195,7 @@ function sort_uniq(cmp, l) { } } if (c < 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1216,7 +1217,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1249,7 +1250,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1271,7 +1272,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1314,7 +1315,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1362,7 +1363,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, @@ -1398,9 +1399,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1425,7 +1426,7 @@ function sort_uniq(cmp, l) { } } if (c > 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1447,7 +1448,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1480,7 +1481,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1502,7 +1503,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1545,7 +1546,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1593,7 +1594,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, diff --git a/lib/es6/listLabels.js b/lib/es6/listLabels.js index 85bb33989a..78e516c64d 100644 --- a/lib/es6/listLabels.js +++ b/lib/es6/listLabels.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_obj from "./caml_obj.js"; import * as Pervasives from "./pervasives.js"; import * as Caml_option from "./caml_option.js"; @@ -136,7 +137,7 @@ function init_tailrec_aux(_acc, _i, n, f) { } _i = i + 1 | 0; _acc = { - hd: f(i), + hd: Curry._1(f, i), tl: acc }; continue; @@ -147,7 +148,7 @@ function init_aux(i, n, f) { if (i >= n) { return /* [] */0; } - let r = f(i); + let r = Curry._1(f, i); return { hd: r, tl: init_aux(i + 1 | 0, n, f) @@ -155,19 +156,19 @@ function init_aux(i, n, f) { } function init(len, f) { - if (len >= 0) { - if (len > 10000) { - return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); - } else { - return init_aux(0, len, f); - } + if (len < 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.init" + } + }); + } + if (len > 10000) { + return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); + } else { + return init_aux(0, len, f); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.init" - } - }); } function flatten(param) { @@ -182,7 +183,7 @@ function map(f, param) { if (!param) { return /* [] */0; } - let r = f(param.hd); + let r = Curry._1(f, param.hd); return { hd: r, tl: map(f, param.tl) @@ -193,7 +194,7 @@ function mapi(i, f, param) { if (!param) { return /* [] */0; } - let r = f(i, param.hd); + let r = Curry._2(f, i, param.hd); return { hd: r, tl: mapi(i + 1 | 0, f, param.tl) @@ -215,7 +216,7 @@ function rev_map(f, l) { } _param = param.tl; _accu = { - hd: f(param.hd), + hd: Curry._1(f, param.hd), tl: accu }; continue; @@ -228,7 +229,7 @@ function iter(f, _param) { if (!param) { return; } - f(param.hd); + Curry._1(f, param.hd); _param = param.tl; continue; }; @@ -243,7 +244,7 @@ function iteri(f, l) { if (!param) { return; } - f(i, param.hd); + Curry._2(f, i, param.hd); _param = param.tl; _i = i + 1 | 0; continue; @@ -258,14 +259,14 @@ function fold_left(f, _accu, _l) { return accu; } _l = l.tl; - _accu = f(accu, l.hd); + _accu = Curry._2(f, accu, l.hd); continue; }; } function fold_right(f, l, accu) { if (l) { - return f(l.hd, fold_right(f, l.tl, accu)); + return Curry._2(f, l.hd, fold_right(f, l.tl, accu)); } else { return accu; } @@ -274,7 +275,7 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - let r = f(l1.hd, l2.hd); + let r = Curry._2(f, l1.hd, l2.hd); return { hd: r, tl: map2(f, l1.tl, l2.tl) @@ -311,7 +312,7 @@ function rev_map2(f, l1, l2) { _l2 = l2$1.tl; _l1 = l1$1.tl; _accu = { - hd: f(l1$1.hd, l2$1.hd), + hd: Curry._2(f, l1$1.hd, l2$1.hd), tl: accu }; continue; @@ -323,15 +324,15 @@ function rev_map2(f, l1, l2) { } }); } - if (!l2$1) { - return accu; + if (l2$1) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.rev_map2" - } - }); + return accu; }; } @@ -341,7 +342,7 @@ function iter2(f, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - f(l1.hd, l2.hd); + Curry._2(f, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -374,7 +375,7 @@ function fold_left2(f, _accu, _l1, _l2) { if (l2) { _l2 = l2.tl; _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); + _accu = Curry._3(f, accu, l1.hd, l2.hd); continue; } throw new Error("Invalid_argument", { @@ -384,22 +385,22 @@ function fold_left2(f, _accu, _l1, _l2) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_left2" - } - }); + return accu; }; } function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + return Curry._3(f, l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } throw new Error("Invalid_argument", { cause: { @@ -408,15 +409,15 @@ function fold_right2(f, l1, l2, accu) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2" - } - }); + return accu; } function for_all(p, _param) { @@ -425,7 +426,7 @@ function for_all(p, _param) { if (!param) { return true; } - if (!p(param.hd)) { + if (!Curry._1(p, param.hd)) { return false; } _param = param.tl; @@ -439,7 +440,7 @@ function exists(p, _param) { if (!param) { return false; } - if (p(param.hd)) { + if (Curry._1(p, param.hd)) { return true; } _param = param.tl; @@ -453,7 +454,7 @@ function for_all2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -485,7 +486,7 @@ function exists2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (p(l1.hd, l2.hd)) { + if (Curry._2(p, l1.hd, l2.hd)) { return true; } _l2 = l2.tl; @@ -672,7 +673,7 @@ function find(p, _param) { let param = _param; if (param) { let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return x; } _param = param.tl; @@ -693,7 +694,7 @@ function find_opt(p, _param) { return; } let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return Caml_option.some(x); } _param = param.tl; @@ -712,7 +713,7 @@ function find_all(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _accu = { hd: x, @@ -741,7 +742,7 @@ function partition(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _yes = { hd: x, @@ -817,7 +818,7 @@ function merge(cmp, l1, l2) { } let h2 = l2.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { return { hd: h1, tl: merge(cmp, l1.tl, l2) @@ -866,8 +867,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { + if (Curry._2(cmp, x1, x2) <= 0) { + if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x1, tl: { @@ -878,7 +879,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x1, tl: { @@ -901,7 +902,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x2, tl: { @@ -912,7 +913,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) <= 0) { + } else if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x2, tl: { @@ -946,7 +947,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) <= 0) { + if (Curry._2(cmp, x1$1, x2$1) <= 0) { return { hd: x1$1, tl: { @@ -986,7 +987,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) > 0) { + if (Curry._2(cmp, h1, h2) > 0) { _accu = { hd: h1, tl: accu @@ -1012,8 +1013,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { + if (Curry._2(cmp, x1, x2) > 0) { + if (Curry._2(cmp, x2, x3) > 0) { return { hd: x1, tl: { @@ -1024,7 +1025,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x1, tl: { @@ -1047,7 +1048,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x2, tl: { @@ -1058,7 +1059,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) > 0) { + } else if (Curry._2(cmp, x2, x3) > 0) { return { hd: x2, tl: { @@ -1092,7 +1093,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) > 0) { + if (Curry._2(cmp, x1$1, x2$1) > 0) { return { hd: x1$1, tl: { @@ -1132,7 +1133,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { _accu = { hd: h1, tl: accu @@ -1167,9 +1168,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1194,7 +1195,7 @@ function sort_uniq(cmp, l) { } } if (c < 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1216,7 +1217,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1249,7 +1250,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1271,7 +1272,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1314,7 +1315,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1362,7 +1363,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, @@ -1398,9 +1399,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1425,7 +1426,7 @@ function sort_uniq(cmp, l) { } } if (c > 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1447,7 +1448,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1480,7 +1481,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1502,7 +1503,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1545,7 +1546,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1593,7 +1594,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, diff --git a/lib/es6/map.js b/lib/es6/map.js index 9add13e742..0f78c18808 100644 --- a/lib/es6/map.js +++ b/lib/es6/map.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function Make(funarg) { @@ -120,7 +121,7 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { if (d === data) { return param; @@ -160,7 +161,7 @@ function Make(funarg) { } }); } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return param.d; } @@ -179,7 +180,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -194,7 +195,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -215,7 +216,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -230,7 +231,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -255,7 +256,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -270,7 +271,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -291,7 +292,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -306,7 +307,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -326,7 +327,7 @@ function Make(funarg) { if (typeof param !== "object") { return; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return Caml_option.some(param.d); } @@ -340,7 +341,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -458,7 +459,7 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return merge(l, r); } @@ -479,7 +480,7 @@ function Make(funarg) { }; let update = function (x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -497,9 +498,9 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -539,7 +540,7 @@ function Make(funarg) { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -549,7 +550,7 @@ function Make(funarg) { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -566,7 +567,7 @@ function Make(funarg) { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -584,7 +585,7 @@ function Make(funarg) { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -595,7 +596,7 @@ function Make(funarg) { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -611,7 +612,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -681,7 +682,7 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -714,7 +715,7 @@ function Make(funarg) { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -732,7 +733,7 @@ function Make(funarg) { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; let union = function (f, s1, s2) { if (typeof s1 !== "object") { @@ -751,7 +752,7 @@ function Make(funarg) { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -761,7 +762,7 @@ function Make(funarg) { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -775,7 +776,7 @@ function Make(funarg) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -799,7 +800,7 @@ function Make(funarg) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -849,11 +850,11 @@ function Make(funarg) { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -878,10 +879,10 @@ function Make(funarg) { if (typeof e2 !== "object") { return false; } - if (funarg.compare(e1._0, e2._0) !== 0) { + if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); diff --git a/lib/es6/mapLabels.js b/lib/es6/mapLabels.js index d6fe21fdf5..0706caa57b 100644 --- a/lib/es6/mapLabels.js +++ b/lib/es6/mapLabels.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function Make(Ord) { @@ -120,7 +121,7 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { if (d === data) { return param; @@ -160,7 +161,7 @@ function Make(Ord) { } }); } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return param.d; } @@ -180,7 +181,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -201,7 +202,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, param.d, f, param.l); } _param = param.r; @@ -220,7 +221,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -237,7 +238,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, param.d, f, param.l); } _param = param.r; @@ -256,7 +257,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -277,7 +278,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, param.d, f, param.r); } _param = param.l; @@ -296,7 +297,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -313,7 +314,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, param.d, f, param.r); } _param = param.l; @@ -326,7 +327,7 @@ function Make(Ord) { if (typeof param !== "object") { return; } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return Caml_option.some(param.d); } @@ -340,7 +341,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return true; } @@ -458,7 +459,7 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return merge(l, r); } @@ -479,7 +480,7 @@ function Make(Ord) { }; let update = function (x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -497,9 +498,9 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -539,7 +540,7 @@ function Make(Ord) { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -549,7 +550,7 @@ function Make(Ord) { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -566,7 +567,7 @@ function Make(Ord) { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -584,7 +585,7 @@ function Make(Ord) { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -595,7 +596,7 @@ function Make(Ord) { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -611,7 +612,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -681,7 +682,7 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return [ l, @@ -714,7 +715,7 @@ function Make(Ord) { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -732,7 +733,7 @@ function Make(Ord) { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; let union = function (f, s1, s2) { if (typeof s1 !== "object") { @@ -751,7 +752,7 @@ function Make(Ord) { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -761,7 +762,7 @@ function Make(Ord) { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -775,7 +776,7 @@ function Make(Ord) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -799,7 +800,7 @@ function Make(Ord) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -849,11 +850,11 @@ function Make(Ord) { if (typeof e2 !== "object") { return 1; } - let c = Ord.compare(e1._0, e2._0); + let c = Curry._2(Ord.compare, e1._0, e2._0); if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -878,10 +879,10 @@ function Make(Ord) { if (typeof e2 !== "object") { return false; } - if (Ord.compare(e1._0, e2._0) !== 0) { + if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); diff --git a/lib/es6/moreLabels.js b/lib/es6/moreLabels.js index bb08f475a0..2e3a589459 100644 --- a/lib/es6/moreLabels.js +++ b/lib/es6/moreLabels.js @@ -1,6 +1,7 @@ import * as List from "./list.js"; +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; import * as HashtblLabels from "./hashtblLabels.js"; @@ -150,7 +151,7 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { if (d === data) { return param; @@ -190,7 +191,7 @@ let $$Map = { } }); } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return param.d; } @@ -210,7 +211,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -231,7 +232,7 @@ let $$Map = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, param.d, f, param.l); } _param = param.r; @@ -250,7 +251,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -267,7 +268,7 @@ let $$Map = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, param.d, f, param.l); } _param = param.r; @@ -286,7 +287,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -307,7 +308,7 @@ let $$Map = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, param.d, f, param.r); } _param = param.l; @@ -326,7 +327,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -343,7 +344,7 @@ let $$Map = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, param.d, f, param.r); } _param = param.l; @@ -356,7 +357,7 @@ let $$Map = { if (typeof param !== "object") { return; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return Caml_option.some(param.d); } @@ -370,7 +371,7 @@ let $$Map = { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -488,7 +489,7 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return merge(l, r); } @@ -509,7 +510,7 @@ let $$Map = { }; let update = function (x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -527,9 +528,9 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -569,7 +570,7 @@ let $$Map = { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -579,7 +580,7 @@ let $$Map = { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -596,7 +597,7 @@ let $$Map = { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -614,7 +615,7 @@ let $$Map = { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -625,7 +626,7 @@ let $$Map = { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -641,7 +642,7 @@ let $$Map = { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -711,7 +712,7 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -744,7 +745,7 @@ let $$Map = { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -762,7 +763,7 @@ let $$Map = { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; let union = function (f, s1, s2) { if (typeof s1 !== "object") { @@ -781,7 +782,7 @@ let $$Map = { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -791,7 +792,7 @@ let $$Map = { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -805,7 +806,7 @@ let $$Map = { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -829,7 +830,7 @@ let $$Map = { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -879,11 +880,11 @@ let $$Map = { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -908,10 +909,10 @@ let $$Map = { if (typeof e2 !== "object") { return false; } - if (funarg.compare(e1._0, e2._0) !== 0) { + if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); @@ -1084,7 +1085,7 @@ let $$Set = { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return param; } @@ -1252,7 +1253,7 @@ let $$Set = { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -1288,7 +1289,7 @@ let $$Set = { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -1303,7 +1304,7 @@ let $$Set = { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return merge(l, r); } @@ -1413,7 +1414,7 @@ let $$Set = { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -1443,7 +1444,7 @@ let $$Set = { } let r2 = s2.r; let l2 = s2.l; - let c = funarg.compare(v1, s2.v); + let c = Curry._2(funarg.compare, v1, s2.v); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -1485,7 +1486,7 @@ let $$Set = { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -1497,7 +1498,7 @@ let $$Set = { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -1508,7 +1509,7 @@ let $$Set = { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -1524,7 +1525,7 @@ let $$Set = { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -1542,7 +1543,7 @@ let $$Set = { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -1565,7 +1566,7 @@ let $$Set = { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -1617,7 +1618,7 @@ let $$Set = { }); } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return v; } @@ -1633,7 +1634,7 @@ let $$Set = { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -1653,7 +1654,7 @@ let $$Set = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, f, param.l); } _param = param.r; @@ -1668,7 +1669,7 @@ let $$Set = { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -1684,7 +1685,7 @@ let $$Set = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, f, param.l); } _param = param.r; @@ -1699,7 +1700,7 @@ let $$Set = { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -1719,7 +1720,7 @@ let $$Set = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, f, param.r); } _param = param.l; @@ -1734,7 +1735,7 @@ let $$Set = { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -1750,7 +1751,7 @@ let $$Set = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, f, param.r); } _param = param.l; @@ -1764,7 +1765,7 @@ let $$Set = { return; } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return Caml_option.some(v); } @@ -1773,7 +1774,7 @@ let $$Set = { }; }; let try_join = function (l, v, r) { - if ((l === "Empty" || funarg.compare(max_elt(l), v) < 0) && (r === "Empty" || funarg.compare(v, min_elt(r)) < 0)) { + if ((l === "Empty" || Curry._2(funarg.compare, max_elt(l), v) < 0) && (r === "Empty" || Curry._2(funarg.compare, v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); @@ -1787,7 +1788,7 @@ let $$Set = { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; @@ -1977,4 +1978,4 @@ export { $$Map, $$Set, } -/* HashtblLabels Not a pure module */ +/* No side effect */ diff --git a/lib/es6/parsing.js b/lib/es6/parsing.js index a17af3f6e4..5b44689bfc 100644 --- a/lib/es6/parsing.js +++ b/lib/es6/parsing.js @@ -1,6 +1,7 @@ import * as $$Array from "./array.js"; +import * as Curry from "./curry.js"; import * as Lexing from "./lexing.js"; import * as Caml_obj from "./caml_obj.js"; import * as Caml_array from "./caml_array.js"; @@ -80,7 +81,7 @@ function yyparse(tables, start, lexer, lexbuf) { let match = Caml_parser.parse_engine(tables, env, cmd, arg); switch (match) { case "Read_token" : - let t = lexer(lexbuf); + let t = Curry._1(lexer, lexbuf); env.symb_start = lexbuf.lex_start_p; env.symb_end = lexbuf.lex_curr_p; _arg = t; @@ -107,7 +108,7 @@ function yyparse(tables, start, lexer, lexbuf) { try { match$1 = [ "Semantic_action_computed", - Caml_array.get(tables.actions, env.rule_number)(env) + Curry._1(Caml_array.get(tables.actions, env.rule_number), env) ]; } catch (raw_exn){ @@ -127,7 +128,7 @@ function yyparse(tables, start, lexer, lexbuf) { _cmd = match$1[0]; continue; case "Call_error_function" : - tables.error_function("syntax error"); + Curry._1(tables.error_function, "syntax error"); _arg = undefined; _cmd = "Error_detected"; continue; @@ -211,7 +212,7 @@ function rhs_end(n) { } function is_current_lookahead(tok) { - return current_lookahead_fun.contents(tok); + return Curry._1(current_lookahead_fun.contents, tok); } function parse_error(param) { diff --git a/lib/es6/pervasives.js b/lib/es6/pervasives.js index e211c20bee..40f92cebe8 100644 --- a/lib/es6/pervasives.js +++ b/lib/es6/pervasives.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_sys from "./caml_sys.js"; import * as Caml_format from "./caml_format.js"; import * as Caml_string from "./caml_string.js"; @@ -41,7 +42,7 @@ function lnot(x) { let min_int = -2147483648; function classify_float(x) { - if (isFinite(x)) { + if (Curry._1(isFinite, x)) { if (Math.abs(x) >= 2.22507385850720138e-308) { return "FP_normal"; } else if (x !== 0) { @@ -49,7 +50,7 @@ function classify_float(x) { } else { return "FP_zero"; } - } else if (isNaN(x)) { + } else if (Curry._1(isNaN, x)) { return "FP_nan"; } else { return "FP_infinite"; @@ -185,7 +186,7 @@ function print_int(i) { } function print_float(i) { - console.log(string_of_float(i)); + console.log(valid_float_lexem(Caml_format.format_float("%.12g", i))); } function print_string(prim) { @@ -201,13 +202,13 @@ let exit_function = { function at_exit(f) { let g = exit_function.contents; exit_function.contents = (function () { - f(); - g(); + Curry._1(f, undefined); + Curry._1(g, undefined); }); } function exit(retcode) { - exit_function.contents(); + Curry._1(exit_function.contents, undefined); return Caml_sys.sys_exit(retcode); } diff --git a/lib/es6/queue.js b/lib/es6/queue.js index 36d67dbb71..5f54f6c08f 100644 --- a/lib/es6/queue.js +++ b/lib/es6/queue.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; import * as Caml_exceptions from "./caml_exceptions.js"; let Empty = /* @__PURE__ */Caml_exceptions.create("Queue.Empty"); @@ -116,7 +117,7 @@ function iter(f, q) { return; } let next = cell.next; - f(cell.content); + Curry._1(f, cell.content); _cell = next; continue; }; @@ -132,7 +133,7 @@ function fold(f, accu, q) { return accu$1; } let next = cell.next; - let accu$2 = f(accu$1, cell.content); + let accu$2 = Curry._2(f, accu$1, cell.content); _cell = next; _accu = accu$2; continue; diff --git a/lib/es6/random.js b/lib/es6/random.js index c0e7284cf1..e2e703067e 100644 --- a/lib/es6/random.js +++ b/lib/es6/random.js @@ -74,65 +74,65 @@ function bits(s) { } function int(s, bound) { - if (!(bound > 1073741823 || bound <= 0)) { - while(true) { - let r = bits(s); - let v = r % bound; - if ((r - v | 0) <= ((1073741823 - bound | 0) + 1 | 0)) { - return v; - } - continue; - }; + if (bound > 1073741823 || bound <= 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Random.int" - } - }); + while(true) { + let r = bits(s); + let v = r % bound; + if ((r - v | 0) <= ((1073741823 - bound | 0) + 1 | 0)) { + return v; + } + continue; + }; } function int32(s, bound) { - if (bound > 0) { - while(true) { - let b1 = bits(s); - let b2 = ((bits(s) & 1) << 30); - let r = b1 | b2; - let v = r % bound; - if ((r - v | 0) <= ((Int32.max_int - bound | 0) + 1 | 0)) { - return v; - } - continue; - }; + if (bound <= 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int32" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Random.int32" - } - }); + while(true) { + let b1 = bits(s); + let b2 = ((bits(s) & 1) << 30); + let r = b1 | b2; + let v = r % bound; + if ((r - v | 0) <= ((Int32.max_int - bound | 0) + 1 | 0)) { + return v; + } + continue; + }; } function int64(s, bound) { - if (!Caml.i64_le(bound, Caml_int64.zero)) { - while(true) { - let b1 = Caml_int64.of_int32(bits(s)); - let b2 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s)), 30); - let b3 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s) & 7), 60); - let r = Caml_int64.or_(b1, Caml_int64.or_(b2, b3)); - let v = Caml_int64.mod_(r, bound); - if (!Caml.i64_gt(Caml_int64.sub(r, v), Caml_int64.add(Caml_int64.sub(Int64.max_int, bound), Caml_int64.one))) { - return v; - } - continue; - }; + if (Caml.i64_le(bound, Caml_int64.zero)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int64" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Random.int64" - } - }); + while(true) { + let b1 = Caml_int64.of_int32(bits(s)); + let b2 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s)), 30); + let b3 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s) & 7), 60); + let r = Caml_int64.or_(b1, Caml_int64.or_(b2, b3)); + let v = Caml_int64.mod_(r, bound); + if (!Caml.i64_gt(Caml_int64.sub(r, v), Caml_int64.add(Caml_int64.sub(Int64.max_int, bound), Caml_int64.one))) { + return v; + } + continue; + }; } function rawfloat(s) { @@ -227,7 +227,7 @@ function int64$1(bound) { } function float$1(scale) { - return float($$default, scale); + return rawfloat($$default) * scale; } function bool$1() { diff --git a/lib/es6/set.js b/lib/es6/set.js index 2808ee5d78..de5d2c054c 100644 --- a/lib/es6/set.js +++ b/lib/es6/set.js @@ -1,6 +1,7 @@ import * as List from "./list.js"; +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function Make(funarg) { @@ -100,7 +101,7 @@ function Make(funarg) { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return param; } @@ -259,7 +260,7 @@ function Make(funarg) { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -295,7 +296,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -310,7 +311,7 @@ function Make(funarg) { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { if (typeof l !== "object") { return r; @@ -428,7 +429,7 @@ function Make(funarg) { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -455,7 +456,7 @@ function Make(funarg) { } let r2 = s2.r; let l2 = s2.l; - let c = funarg.compare(v1, s2.v); + let c = Curry._2(funarg.compare, v1, s2.v); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -497,7 +498,7 @@ function Make(funarg) { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -509,7 +510,7 @@ function Make(funarg) { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -520,7 +521,7 @@ function Make(funarg) { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -536,7 +537,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -554,7 +555,7 @@ function Make(funarg) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -577,7 +578,7 @@ function Make(funarg) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -629,7 +630,7 @@ function Make(funarg) { }); } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return v; } @@ -648,7 +649,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -658,7 +659,7 @@ function Make(funarg) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -678,7 +679,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -688,7 +689,7 @@ function Make(funarg) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -712,7 +713,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -722,7 +723,7 @@ function Make(funarg) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -742,7 +743,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -752,7 +753,7 @@ function Make(funarg) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -772,7 +773,7 @@ function Make(funarg) { return; } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return Caml_option.some(v); } @@ -788,11 +789,11 @@ function Make(funarg) { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; - } else if ((l$p === "Empty" || funarg.compare(max_elt(l$p), v$p) < 0) && (r$p === "Empty" || funarg.compare(v$p, min_elt(r$p)) < 0)) { + } else if ((l$p === "Empty" || Curry._2(funarg.compare, max_elt(l$p), v$p) < 0) && (r$p === "Empty" || Curry._2(funarg.compare, v$p, min_elt(r$p)) < 0)) { return join(l$p, v$p, r$p); } else { return union(l$p, add(v$p, r$p)); diff --git a/lib/es6/setLabels.js b/lib/es6/setLabels.js index 3097a1f8f3..8900080d49 100644 --- a/lib/es6/setLabels.js +++ b/lib/es6/setLabels.js @@ -1,6 +1,7 @@ import * as List from "./list.js"; +import * as Curry from "./curry.js"; import * as Caml_option from "./caml_option.js"; function Make(Ord) { @@ -100,7 +101,7 @@ function Make(Ord) { let r = param.r; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return param; } @@ -268,7 +269,7 @@ function Make(Ord) { let r = param.r; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return [ l, @@ -304,7 +305,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return true; } @@ -319,7 +320,7 @@ function Make(Ord) { let r = param.r; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return merge(l, r); } @@ -429,7 +430,7 @@ function Make(Ord) { if (typeof e2 !== "object") { return 1; } - let c = Ord.compare(e1._0, e2._0); + let c = Curry._2(Ord.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -459,7 +460,7 @@ function Make(Ord) { } let r2 = s2.r; let l2 = s2.l; - let c = Ord.compare(v1, s2.v); + let c = Curry._2(Ord.compare, v1, s2.v); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -501,7 +502,7 @@ function Make(Ord) { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -513,7 +514,7 @@ function Make(Ord) { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -524,7 +525,7 @@ function Make(Ord) { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -540,7 +541,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -558,7 +559,7 @@ function Make(Ord) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -581,7 +582,7 @@ function Make(Ord) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -633,7 +634,7 @@ function Make(Ord) { }); } let v = param.v; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return v; } @@ -649,7 +650,7 @@ function Make(Ord) { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -669,7 +670,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, f, param.l); } _param = param.r; @@ -684,7 +685,7 @@ function Make(Ord) { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -700,7 +701,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, f, param.l); } _param = param.r; @@ -715,7 +716,7 @@ function Make(Ord) { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -735,7 +736,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, f, param.r); } _param = param.l; @@ -750,7 +751,7 @@ function Make(Ord) { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -766,7 +767,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, f, param.r); } _param = param.l; @@ -780,7 +781,7 @@ function Make(Ord) { return; } let v = param.v; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return Caml_option.some(v); } @@ -789,7 +790,7 @@ function Make(Ord) { }; }; let try_join = function (l, v, r) { - if ((l === "Empty" || Ord.compare(max_elt(l), v) < 0) && (r === "Empty" || Ord.compare(v, min_elt(r)) < 0)) { + if ((l === "Empty" || Curry._2(Ord.compare, max_elt(l), v) < 0) && (r === "Empty" || Curry._2(Ord.compare, v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); @@ -803,7 +804,7 @@ function Make(Ord) { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; diff --git a/lib/es6/sort.js b/lib/es6/sort.js index 64395cfd55..00b5fec14a 100644 --- a/lib/es6/sort.js +++ b/lib/es6/sort.js @@ -1,5 +1,6 @@ +import * as Curry from "./curry.js"; function merge(order, l1, l2) { if (!l1) { @@ -10,7 +11,7 @@ function merge(order, l1, l2) { } let h2 = l2.hd; let h1 = l1.hd; - if (order(h1, h2)) { + if (Curry._2(order, h1, h2)) { return { hd: h1, tl: merge(order, l1.tl, l2) @@ -41,7 +42,7 @@ function list(order, l) { } let e2 = match.hd; return { - hd: order(e, e2) ? ({ + hd: Curry._2(order, e, e2) ? ({ hd: e, tl: { hd: e2, @@ -100,12 +101,12 @@ function array(cmp, arr) { return; } let mid = ((lo + hi | 0) >>> 1); - if (cmp(arr[mid], arr[lo])) { + if (Curry._2(cmp, arr[mid], arr[lo])) { swap(arr, mid, lo); } - if (cmp(arr[hi], arr[mid])) { + if (Curry._2(cmp, arr[hi], arr[mid])) { swap(arr, mid, hi); - if (cmp(arr[mid], arr[lo])) { + if (Curry._2(cmp, arr[mid], arr[lo])) { swap(arr, mid, lo); } @@ -113,7 +114,7 @@ function array(cmp, arr) { let pivot = arr[mid]; let i = lo + 1 | 0; let j = hi - 1 | 0; - if (!cmp(pivot, arr[hi]) || !cmp(arr[lo], pivot)) { + if (!Curry._2(cmp, pivot, arr[hi]) || !Curry._2(cmp, arr[lo], pivot)) { throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", @@ -122,10 +123,10 @@ function array(cmp, arr) { }); } while(i < j) { - while(!cmp(pivot, arr[i])) { + while(!Curry._2(cmp, pivot, arr[i])) { i = i + 1 | 0; }; - while(!cmp(arr[j], pivot)) { + while(!Curry._2(cmp, arr[j], pivot)) { j = j - 1 | 0; }; if (i < j) { @@ -147,10 +148,10 @@ function array(cmp, arr) { qsort(0, arr.length - 1 | 0); for(let i = 1 ,i_finish = arr.length; i < i_finish; ++i){ let val_i = arr[i]; - if (!cmp(arr[i - 1 | 0], val_i)) { + if (!Curry._2(cmp, arr[i - 1 | 0], val_i)) { arr[i] = arr[i - 1 | 0]; let j = i - 1 | 0; - while(j >= 1 && !cmp(arr[j - 1 | 0], val_i)) { + while(j >= 1 && !Curry._2(cmp, arr[j - 1 | 0], val_i)) { arr[j] = arr[j - 1 | 0]; j = j - 1 | 0; }; diff --git a/lib/es6/stream.js b/lib/es6/stream.js index c1fffd51dc..057a31d5b6 100644 --- a/lib/es6/stream.js +++ b/lib/es6/stream.js @@ -1,7 +1,7 @@ -import * as Lazy from "./lazy.js"; import * as List from "./list.js"; +import * as Curry from "./curry.js"; import * as Caml_bytes from "./caml_bytes.js"; import * as Caml_option from "./caml_option.js"; import * as Caml_string from "./caml_string.js"; @@ -84,7 +84,7 @@ function get_data(count, _d) { return "Sempty"; } } - let a$1 = g.func(count); + let a$1 = Curry._1(g.func, count); if (a$1 !== undefined) { return { TAG: "Scons", @@ -137,7 +137,7 @@ function peek_data(s) { if (a !== undefined) { return Caml_option.valFromOption(a); } - let x = g.func(s.count); + let x = Curry._1(g.func, s.count); g.curr = Caml_option.some(x); return x; @@ -266,7 +266,7 @@ function iter(f, strm) { return; } junk(strm); - f(Caml_option.valFromOption(a)); + Curry._1(f, Caml_option.valFromOption(a)); _param = undefined; continue; }; @@ -362,32 +362,38 @@ function ising(i) { } function lapp(f, s) { + let f$1 = function () { + return { + TAG: "Sapp", + _0: data(Curry._1(f, undefined)), + _1: data(s) + }; + }; return { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { - return { - TAG: "Sapp", - _0: data(f()), - _1: data(s) - }; + _0: CamlinternalLazy.from_fun(function () { + return f$1(); }) } }; } function lcons(f, s) { + let f$1 = function () { + return { + TAG: "Scons", + _0: Curry._1(f, undefined), + _1: data(s) + }; + }; return { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { - return { - TAG: "Scons", - _0: f(), - _1: data(s) - }; + _0: CamlinternalLazy.from_fun(function () { + return f$1(); }) } }; @@ -398,10 +404,10 @@ function lsing(f) { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { + _0: CamlinternalLazy.from_fun(function () { return { TAG: "Scons", - _0: f(), + _0: Curry._1(f, undefined), _1: "Sempty" }; }) @@ -414,8 +420,8 @@ function slazy(f) { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { - return data(f()); + _0: CamlinternalLazy.from_fun(function () { + return data(Curry._1(f, undefined)); }) } }; @@ -429,7 +435,7 @@ function dump_data(f, param) { switch (param.TAG) { case "Scons" : console.log("Scons ("); - f(param._0); + Curry._1(f, param._0); console.log(", "); dump_data(f, param._1); console.log(")"); diff --git a/lib/es6/string.js b/lib/es6/string.js index 8fd3ca5035..9ac0eb8bab 100644 --- a/lib/es6/string.js +++ b/lib/es6/string.js @@ -3,6 +3,7 @@ import * as Caml from "./caml.js"; import * as $$Array from "./array.js"; import * as Bytes from "./bytes.js"; +import * as Curry from "./curry.js"; import * as Caml_string from "./caml_string.js"; import * as Caml_js_exceptions from "./caml_js_exceptions.js"; @@ -20,13 +21,13 @@ function concat(sep, xs) { function iter(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(s.codePointAt(i)); + Curry._1(f, s.codePointAt(i)); } } function iteri(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(i, s.codePointAt(i)); + Curry._2(f, i, s.codePointAt(i)); } } @@ -128,28 +129,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -175,15 +176,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -205,15 +206,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/es6/stringLabels.js b/lib/es6/stringLabels.js index 3db2216ab3..9df2847bb4 100644 --- a/lib/es6/stringLabels.js +++ b/lib/es6/stringLabels.js @@ -3,6 +3,7 @@ import * as Caml from "./caml.js"; import * as $$Array from "./array.js"; import * as Bytes from "./bytes.js"; +import * as Curry from "./curry.js"; import * as Caml_string from "./caml_string.js"; import * as Caml_js_exceptions from "./caml_js_exceptions.js"; @@ -14,9 +15,7 @@ function sub(s, ofs, len) { return Bytes.unsafe_to_string(Bytes.sub(Bytes.unsafe_of_string(s), ofs, len)); } -function blit(src, src_pos, dst, dst_pos, len) { - Bytes.blit_string(src, src_pos, dst, dst_pos, len); -} +let blit = Bytes.blit_string; function concat(sep, xs) { return $$Array.of_list(xs).join(sep); @@ -24,13 +23,13 @@ function concat(sep, xs) { function iter(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(s.codePointAt(i)); + Curry._1(f, s.codePointAt(i)); } } function iteri(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(i, s.codePointAt(i)); + Curry._2(f, i, s.codePointAt(i)); } } @@ -132,28 +131,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -179,15 +178,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -209,15 +208,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/es6/sys.js b/lib/es6/sys.js index 7ddb3c3ddd..1ded50c6ab 100644 --- a/lib/es6/sys.js +++ b/lib/es6/sys.js @@ -45,20 +45,7 @@ function set_signal(sig_num, sig_beh) { let Break = /* @__PURE__ */Caml_exceptions.create("Sys.Break"); function catch_break(on) { - if (on) { - return set_signal(-6, { - TAG: "Signal_handle", - _0: (function (param) { - throw new Error(Break, { - cause: { - RE_EXN_ID: Break - } - }); - }) - }); - } else { - return set_signal(-6, "Signal_default"); - } + } function enable_runtime_warnings(param) { diff --git a/lib/es6/uchar.js b/lib/es6/uchar.js index cfb8c42324..f98c218a31 100644 --- a/lib/es6/uchar.js +++ b/lib/es6/uchar.js @@ -15,30 +15,30 @@ function succ(u) { if (u === 55295) { return 57344; } - if (u !== 1114111) { - return u + 1 | 0; + if (u === 1114111) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "U+10FFFF has no successor" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "U+10FFFF has no successor" - } - }); + return u + 1 | 0; } function pred(u) { if (u === 57344) { return 55295; } - if (u !== 0) { - return u - 1 | 0; + if (u === 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "U+0000 has no predecessor" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "U+0000 has no predecessor" - } - }); + return u - 1 | 0; } function is_valid(i) { diff --git a/lib/js/arg.js b/lib/js/arg.js index 192e936c98..abc11a991a 100644 --- a/lib/js/arg.js +++ b/lib/js/arg.js @@ -4,6 +4,7 @@ let Sys = require("./sys.js"); let Caml = require("./caml.js"); let List = require("./list.js"); let $$Array = require("./array.js"); +let Curry = require("./curry.js"); let Buffer = require("./buffer.js"); let $$String = require("./string.js"); let Caml_obj = require("./caml_obj.js"); @@ -336,12 +337,12 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let treat_action = function (f) { switch (f.TAG) { case "Unit" : - return f._0(); + return Curry._1(f._0, undefined); case "Bool" : let arg = get_arg(); let s$1 = bool_of_string_opt(arg); if (s$1 !== undefined) { - f._0(s$1); + Curry._1(f._0, s$1); } else { throw new Error(Stop, { cause: { @@ -366,7 +367,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist return; case "String" : let arg$1 = get_arg(); - f._0(arg$1); + Curry._1(f._0, arg$1); return consume_arg(); case "Set_string" : f._0.contents = get_arg(); @@ -375,7 +376,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let arg$2 = get_arg(); let x = int_of_string_opt(arg$2); if (x !== undefined) { - f._0(x); + Curry._1(f._0, x); } else { throw new Error(Stop, { cause: { @@ -413,7 +414,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let arg$4 = get_arg(); let x$2 = float_of_string_opt(arg$4); if (x$2 !== undefined) { - f._0(x$2); + Curry._1(f._0, x$2); } else { throw new Error(Stop, { cause: { @@ -453,7 +454,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist let symb = f._0; let arg$6 = get_arg(); if (List.mem(arg$6, symb)) { - f._1(arg$6); + Curry._1(f._1, arg$6); return consume_arg(); } throw new Error(Stop, { @@ -470,7 +471,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist case "Rest" : let f$1 = f._0; while(current.contents < (argv.contents.length - 1 | 0)) { - f$1(Caml_array.get(argv.contents, current.contents + 1 | 0)); + Curry._1(f$1, Caml_array.get(argv.contents, current.contents + 1 | 0)); consume_arg(); }; return; @@ -484,7 +485,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist }); } let arg$7 = get_arg(); - let newarg = f._0(arg$7); + let newarg = Curry._1(f._0, arg$7); consume_arg(); let before = $$Array.sub(argv.contents, 0, current.contents + 1 | 0); let after = $$Array.sub(argv.contents, current.contents + 1 | 0, (argv.contents.length - current.contents | 0) - 1 | 0); @@ -504,7 +505,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist }; treat_action(match[0]); } else { - anonfun(s); + Curry._1(anonfun, s); } } catch (raw_m){ diff --git a/lib/js/array.js b/lib/js/array.js index 5580be4143..7fc81c11d0 100644 --- a/lib/js/array.js +++ b/lib/js/array.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_obj = require("./caml_obj.js"); let Caml_array = require("./caml_array.js"); let Caml_exceptions = require("./caml_exceptions.js"); @@ -21,9 +22,9 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f(0)); + let res = Caml_array.make(l, Curry._1(f, 0)); for(let i = 1; i < l; ++i){ - res[i] = f(i); + res[i] = Curry._1(f, i); } return res; } @@ -57,15 +58,15 @@ function append(a1, a2) { } function sub(a, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (a.length - len | 0))) { - return Caml_array.sub(a, ofs, len); + if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.sub" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); + return Caml_array.sub(a, ofs, len); } function fill(a, ofs, len, v) { @@ -83,20 +84,20 @@ function fill(a, ofs, len, v) { } function blit(a1, ofs1, a2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0))) { - return Caml_array.blit(a1, ofs1, a2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); + Caml_array.blit(a1, ofs1, a2, ofs2, len); } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } @@ -110,7 +111,7 @@ function iter2(f, a, b) { }); } for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i], b[i]); + Curry._2(f, a[i], b[i]); } } @@ -119,9 +120,9 @@ function map(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(a[0])); + let r = Caml_array.make(l, Curry._1(f, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(a[i]); + r[i] = Curry._1(f, a[i]); } return r; } @@ -140,16 +141,16 @@ function map2(f, a, b) { if (la === 0) { return []; } - let r = Caml_array.make(la, f(a[0], b[0])); + let r = Caml_array.make(la, Curry._2(f, a[0], b[0])); for(let i = 1; i < la; ++i){ - r[i] = f(a[i], b[i]); + r[i] = Curry._2(f, a[i], b[i]); } return r; } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -158,9 +159,9 @@ function mapi(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(0, a[0])); + let r = Caml_array.make(l, Curry._2(f, 0, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(i, a[i]); + r[i] = Curry._2(f, i, a[i]); } return r; } @@ -219,7 +220,7 @@ function of_list(param) { function fold_left(f, x, a) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } @@ -227,7 +228,7 @@ function fold_left(f, x, a) { function fold_right(f, a, x) { let r = x; for(let i = a.length - 1 | 0; i >= 0; --i){ - r = f(a[i], r); + r = Curry._2(f, a[i], r); } return r; } @@ -240,7 +241,7 @@ function exists(p, a) { if (i === n) { return false; } - if (p(a[i])) { + if (Curry._1(p, a[i])) { return true; } _i = i + 1 | 0; @@ -256,7 +257,7 @@ function for_all(p, a) { if (i === n) { return true; } - if (!p(a[i])) { + if (!Curry._1(p, a[i])) { return false; } _i = i + 1 | 0; @@ -303,15 +304,15 @@ function sort(cmp, a) { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { x = i31 + 1 | 0; } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { x = i31 + 2 | 0; } return x; } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if ((i31 + 1 | 0) < l && Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { return i31 + 1 | 0; } if (i31 < l) { @@ -330,7 +331,7 @@ function sort(cmp, a) { while(true) { let i$1 = _i; let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { + if (Curry._2(cmp, Caml_array.get(a, j), e) <= 0) { return Caml_array.set(a, i$1, e); } Caml_array.set(a, i$1, Caml_array.get(a, j)); @@ -385,7 +386,7 @@ function sort(cmp, a) { } }); } - if (cmp(Caml_array.get(a, father), e) >= 0) { + if (Curry._2(cmp, Caml_array.get(a, father), e) >= 0) { return Caml_array.set(a, i, e); } Caml_array.set(a, i, Caml_array.get(a, father)); @@ -428,7 +429,7 @@ function stable_sort(cmp, a) { let i2 = _i2; let s1 = _s1; let i1 = _i1; - if (cmp(s1, s2) <= 0) { + if (Curry._2(cmp, s1, s2) <= 0) { Caml_array.set(dst, d, s1); let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -454,7 +455,7 @@ function stable_sort(cmp, a) { for(let i = 0; i < len; ++i){ let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { + while(j >= dstofs && Curry._2(cmp, Caml_array.get(dst, j), e) > 0) { Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); j = j - 1 | 0; }; diff --git a/lib/js/arrayLabels.js b/lib/js/arrayLabels.js index 961b8f8729..b1dd65cc0f 100644 --- a/lib/js/arrayLabels.js +++ b/lib/js/arrayLabels.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_obj = require("./caml_obj.js"); let Caml_array = require("./caml_array.js"); let Caml_exceptions = require("./caml_exceptions.js"); @@ -21,9 +22,9 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f(0)); + let res = Caml_array.make(l, Curry._1(f, 0)); for(let i = 1; i < l; ++i){ - res[i] = f(i); + res[i] = Curry._1(f, i); } return res; } @@ -57,15 +58,15 @@ function append(a1, a2) { } function sub(a, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (a.length - len | 0))) { - return Caml_array.sub(a, ofs, len); + if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.sub" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); + return Caml_array.sub(a, ofs, len); } function fill(a, ofs, len, v) { @@ -83,20 +84,20 @@ function fill(a, ofs, len, v) { } function blit(a1, ofs1, a2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0))) { - return Caml_array.blit(a1, ofs1, a2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Array.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); + Caml_array.blit(a1, ofs1, a2, ofs2, len); } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } @@ -110,7 +111,7 @@ function iter2(f, a, b) { }); } for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i], b[i]); + Curry._2(f, a[i], b[i]); } } @@ -119,9 +120,9 @@ function map(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(a[0])); + let r = Caml_array.make(l, Curry._1(f, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(a[i]); + r[i] = Curry._1(f, a[i]); } return r; } @@ -140,16 +141,16 @@ function map2(f, a, b) { if (la === 0) { return []; } - let r = Caml_array.make(la, f(a[0], b[0])); + let r = Caml_array.make(la, Curry._2(f, a[0], b[0])); for(let i = 1; i < la; ++i){ - r[i] = f(a[i], b[i]); + r[i] = Curry._2(f, a[i], b[i]); } return r; } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -158,9 +159,9 @@ function mapi(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f(0, a[0])); + let r = Caml_array.make(l, Curry._2(f, 0, a[0])); for(let i = 1; i < l; ++i){ - r[i] = f(i, a[i]); + r[i] = Curry._2(f, i, a[i]); } return r; } @@ -219,7 +220,7 @@ function of_list(param) { function fold_left(f, x, a) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } @@ -227,7 +228,7 @@ function fold_left(f, x, a) { function fold_right(f, a, x) { let r = x; for(let i = a.length - 1 | 0; i >= 0; --i){ - r = f(a[i], r); + r = Curry._2(f, a[i], r); } return r; } @@ -240,7 +241,7 @@ function exists(p, a) { if (i === n) { return false; } - if (p(a[i])) { + if (Curry._1(p, a[i])) { return true; } _i = i + 1 | 0; @@ -256,7 +257,7 @@ function for_all(p, a) { if (i === n) { return true; } - if (!p(a[i])) { + if (!Curry._1(p, a[i])) { return false; } _i = i + 1 | 0; @@ -303,15 +304,15 @@ function sort(cmp, a) { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { x = i31 + 1 | 0; } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { + if (Curry._2(cmp, Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { x = i31 + 2 | 0; } return x; } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + if ((i31 + 1 | 0) < l && Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { return i31 + 1 | 0; } if (i31 < l) { @@ -330,7 +331,7 @@ function sort(cmp, a) { while(true) { let i$1 = _i; let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { + if (Curry._2(cmp, Caml_array.get(a, j), e) <= 0) { return Caml_array.set(a, i$1, e); } Caml_array.set(a, i$1, Caml_array.get(a, j)); @@ -385,7 +386,7 @@ function sort(cmp, a) { } }); } - if (cmp(Caml_array.get(a, father), e) >= 0) { + if (Curry._2(cmp, Caml_array.get(a, father), e) >= 0) { return Caml_array.set(a, i, e); } Caml_array.set(a, i, Caml_array.get(a, father)); @@ -428,7 +429,7 @@ function stable_sort(cmp, a) { let i2 = _i2; let s1 = _s1; let i1 = _i1; - if (cmp(s1, s2) <= 0) { + if (Curry._2(cmp, s1, s2) <= 0) { Caml_array.set(dst, d, s1); let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -454,7 +455,7 @@ function stable_sort(cmp, a) { for(let i = 0; i < len; ++i){ let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { + while(j >= dstofs && Curry._2(cmp, Caml_array.get(dst, j), e) > 0) { Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); j = j - 1 | 0; }; diff --git a/lib/js/belt_Array.js b/lib/js/belt_Array.js index 905ed7fa04..9a82c7a3c8 100644 --- a/lib/js/belt_Array.js +++ b/lib/js/belt_Array.js @@ -1,6 +1,7 @@ 'use strict'; let Caml = require("./caml.js"); +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function get(arr, i) { @@ -107,15 +108,13 @@ function makeByU(l, f) { } let res = new Array(l); for(let i = 0; i < l; ++i){ - res[i] = f(i); + res[i] = Curry._1(f, i); } return res; } function makeBy(l, f) { - return makeByU(l, (function (a) { - return f(a); - })); + return makeByU(l, Curry.__1(f)); } function makeByAndShuffleU(l, f) { @@ -125,9 +124,7 @@ function makeByAndShuffleU(l, f) { } function makeByAndShuffle(l, f) { - return makeByAndShuffleU(l, (function (a) { - return f(a); - })); + return makeByAndShuffleU(l, Curry.__1(f)); } function range(start, finish) { @@ -177,15 +174,13 @@ function zipByU(xs, ys, f) { let len = lenx < leny ? lenx : leny; let s = new Array(len); for(let i = 0; i < len; ++i){ - s[i] = f(xs[i], ys[i]); + s[i] = Curry._2(f, xs[i], ys[i]); } return s; } function zipBy(xs, ys, f) { - return zipByU(xs, ys, (function (a, b) { - return f(a, b); - })); + return zipByU(xs, ys, Curry.__2(f)); } function concat(a1, a2) { @@ -295,29 +290,25 @@ function blit(a1, ofs1, a2, ofs2, len) { function forEachU(a, f) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } function forEach(a, f) { - forEachU(a, (function (a) { - f(a); - })); + forEachU(a, Curry.__1(f)); } function mapU(a, f) { let l = a.length; let r = new Array(l); for(let i = 0; i < l; ++i){ - r[i] = f(a[i]); + r[i] = Curry._1(f, a[i]); } return r; } function map(a, f) { - return mapU(a, (function (a) { - return f(a); - })); + return mapU(a, Curry.__1(f)); } function flatMapU(a, f) { @@ -325,9 +316,7 @@ function flatMapU(a, f) { } function flatMap(a, f) { - return flatMapU(a, (function (a) { - return f(a); - })); + return concatMany(mapU(a, Curry.__1(f))); } function getByU(a, p) { @@ -336,7 +325,7 @@ function getByU(a, p) { let r; while(r === undefined && i < l) { let v = a[i]; - if (p(v)) { + if (Curry._1(p, v)) { r = Caml_option.some(v); } i = i + 1 | 0; @@ -345,9 +334,7 @@ function getByU(a, p) { } function getBy(a, p) { - return getByU(a, (function (a) { - return p(a); - })); + return getByU(a, Curry.__1(p)); } function getIndexByU(a, p) { @@ -356,7 +343,7 @@ function getIndexByU(a, p) { let r; while(r === undefined && i < l) { let v = a[i]; - if (p(v)) { + if (Curry._1(p, v)) { r = i; } i = i + 1 | 0; @@ -365,9 +352,7 @@ function getIndexByU(a, p) { } function getIndexBy(a, p) { - return getIndexByU(a, (function (a) { - return p(a); - })); + return getIndexByU(a, Curry.__1(p)); } function keepU(a, f) { @@ -376,7 +361,7 @@ function keepU(a, f) { let j = 0; for(let i = 0; i < l; ++i){ let v = a[i]; - if (f(v)) { + if (Curry._1(f, v)) { r[j] = v; j = j + 1 | 0; } @@ -387,9 +372,7 @@ function keepU(a, f) { } function keep(a, f) { - return keepU(a, (function (a) { - return f(a); - })); + return keepU(a, Curry.__1(f)); } function keepWithIndexU(a, f) { @@ -398,7 +381,7 @@ function keepWithIndexU(a, f) { let j = 0; for(let i = 0; i < l; ++i){ let v = a[i]; - if (f(v, i)) { + if (Curry._2(f, v, i)) { r[j] = v; j = j + 1 | 0; } @@ -409,9 +392,7 @@ function keepWithIndexU(a, f) { } function keepWithIndex(a, f) { - return keepWithIndexU(a, (function (a, i) { - return f(a, i); - })); + return keepWithIndexU(a, Curry.__2(f)); } function keepMapU(a, f) { @@ -420,7 +401,7 @@ function keepMapU(a, f) { let j = 0; for(let i = 0; i < l; ++i){ let v = a[i]; - let v$1 = f(v); + let v$1 = Curry._1(f, v); if (v$1 !== undefined) { r[j] = Caml_option.valFromOption(v$1); j = j + 1 | 0; @@ -432,93 +413,79 @@ function keepMapU(a, f) { } function keepMap(a, f) { - return keepMapU(a, (function (a) { - return f(a); - })); + return keepMapU(a, Curry.__1(f)); } function forEachWithIndexU(a, f) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } function forEachWithIndex(a, f) { - forEachWithIndexU(a, (function (a, b) { - f(a, b); - })); + forEachWithIndexU(a, Curry.__2(f)); } function mapWithIndexU(a, f) { let l = a.length; let r = new Array(l); for(let i = 0; i < l; ++i){ - r[i] = f(i, a[i]); + r[i] = Curry._2(f, i, a[i]); } return r; } function mapWithIndex(a, f) { - return mapWithIndexU(a, (function (a, b) { - return f(a, b); - })); + return mapWithIndexU(a, Curry.__2(f)); } function reduceU(a, x, f) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } function reduce(a, x, f) { - return reduceU(a, x, (function (a, b) { - return f(a, b); - })); + return reduceU(a, x, Curry.__2(f)); } function reduceReverseU(a, x, f) { let r = x; for(let i = a.length - 1 | 0; i >= 0; --i){ - r = f(r, a[i]); + r = Curry._2(f, r, a[i]); } return r; } function reduceReverse(a, x, f) { - return reduceReverseU(a, x, (function (a, b) { - return f(a, b); - })); + return reduceReverseU(a, x, Curry.__2(f)); } function reduceReverse2U(a, b, x, f) { let r = x; let len = Caml.int_min(a.length, b.length); for(let i = len - 1 | 0; i >= 0; --i){ - r = f(r, a[i], b[i]); + r = Curry._3(f, r, a[i], b[i]); } return r; } function reduceReverse2(a, b, x, f) { - return reduceReverse2U(a, b, x, (function (a, b, c) { - return f(a, b, c); - })); + return reduceReverse2U(a, b, x, Curry.__3(f)); } function reduceWithIndexU(a, x, f) { let r = x; for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i], i); + r = Curry._3(f, r, a[i], i); } return r; } function reduceWithIndex(a, x, f) { - return reduceWithIndexU(a, x, (function (a, b, c) { - return f(a, b, c); - })); + return reduceWithIndexU(a, x, Curry.__3(f)); } function everyU(arr, b) { @@ -529,7 +496,7 @@ function everyU(arr, b) { if (i === len) { return true; } - if (!b(arr[i])) { + if (!Curry._1(b, arr[i])) { return false; } _i = i + 1 | 0; @@ -538,9 +505,7 @@ function everyU(arr, b) { } function every(arr, f) { - return everyU(arr, (function (b) { - return f(b); - })); + return everyU(arr, Curry.__1(f)); } function someU(arr, b) { @@ -551,7 +516,7 @@ function someU(arr, b) { if (i === len) { return false; } - if (b(arr[i])) { + if (Curry._1(b, arr[i])) { return true; } _i = i + 1 | 0; @@ -560,9 +525,7 @@ function someU(arr, b) { } function some(arr, f) { - return someU(arr, (function (b) { - return f(b); - })); + return someU(arr, Curry.__1(f)); } function everyAux2(arr1, arr2, _i, b, len) { @@ -571,7 +534,7 @@ function everyAux2(arr1, arr2, _i, b, len) { if (i === len) { return true; } - if (!b(arr1[i], arr2[i])) { + if (!Curry._2(b, arr1[i], arr2[i])) { return false; } _i = i + 1 | 0; @@ -584,9 +547,7 @@ function every2U(a, b, p) { } function every2(a, b, p) { - return every2U(a, b, (function (a, b) { - return p(a, b); - })); + return every2U(a, b, Curry.__2(p)); } function some2U(a, b, p) { @@ -597,7 +558,7 @@ function some2U(a, b, p) { if (i === len) { return false; } - if (p(a[i], b[i])) { + if (Curry._2(p, a[i], b[i])) { return true; } _i = i + 1 | 0; @@ -606,9 +567,7 @@ function some2U(a, b, p) { } function some2(a, b, p) { - return some2U(a, b, (function (a, b) { - return p(a, b); - })); + return some2U(a, b, Curry.__2(p)); } function eqU(a, b, p) { @@ -622,9 +581,7 @@ function eqU(a, b, p) { } function eq(a, b, p) { - return eqU(a, b, (function (a, b) { - return p(a, b); - })); + return eqU(a, b, Curry.__2(p)); } function cmpU(a, b, p) { @@ -641,7 +598,7 @@ function cmpU(a, b, p) { if (i === lena) { return 0; } - let c = p(a[i], b[i]); + let c = Curry._2(p, a[i], b[i]); if (c !== 0) { return c; } @@ -652,9 +609,7 @@ function cmpU(a, b, p) { } function cmp(a, b, p) { - return cmpU(a, b, (function (a, b) { - return p(a, b); - })); + return cmpU(a, b, Curry.__2(p)); } function partitionU(a, f) { @@ -665,7 +620,7 @@ function partitionU(a, f) { let a2 = new Array(l); for(let ii = 0; ii < l; ++ii){ let v = a[ii]; - if (f(v)) { + if (Curry._1(f, v)) { a1[i] = v; i = i + 1 | 0; } else { @@ -682,9 +637,7 @@ function partitionU(a, f) { } function partition(a, f) { - return partitionU(a, (function (x) { - return f(x); - })); + return partitionU(a, Curry.__1(f)); } function unzip(a) { @@ -714,32 +667,28 @@ function joinWithU(a, sep, toString) { let res = _res; let i = _i; if (i === lastIndex) { - return res + toString(a[i]); + return res + Curry._1(toString, a[i]); } - _res = res + (toString(a[i]) + sep); + _res = res + (Curry._1(toString, a[i]) + sep); _i = i + 1 | 0; continue; }; } function joinWith(a, sep, toString) { - return joinWithU(a, sep, (function (x) { - return toString(x); - })); + return joinWithU(a, sep, Curry.__1(toString)); } function initU(n, f) { let v = new Array(n); for(let i = 0; i < n; ++i){ - v[i] = f(i); + v[i] = Curry._1(f, i); } return v; } function init(n, f) { - return initU(n, (function (i) { - return f(i); - })); + return initU(n, Curry.__1(f)); } exports.get = get; diff --git a/lib/js/belt_HashMap.js b/lib/js/belt_HashMap.js index ba9697458a..e2800f05bd 100644 --- a/lib/js/belt_HashMap.js +++ b/lib/js/belt_HashMap.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_internalBuckets = require("./belt_internalBuckets.js"); let Belt_internalBucketsType = require("./belt_internalBucketsType.js"); @@ -14,7 +15,7 @@ function copyBucketReHash(hash, h_buckets, ndata_tail, _old_bucket) { if (old_bucket === undefined) { return; } - let nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); + let nidx = Curry._1(hash, old_bucket.key) & (h_buckets.length - 1 | 0); let tail = ndata_tail[nidx]; if (tail !== undefined) { tail.next = old_bucket; @@ -30,7 +31,7 @@ function copyBucketReHash(hash, h_buckets, ndata_tail, _old_bucket) { function replaceInBucket(eq, key, info, _cell) { while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { cell.value = info; return false; } @@ -46,7 +47,7 @@ function replaceInBucket(eq, key, info, _cell) { function set0(h, key, value, eq, hash) { let h_buckets = h.buckets; let buckets_len = h_buckets.length; - let i = hash(key) & (buckets_len - 1 | 0); + let i = Curry._1(hash, key) & (buckets_len - 1 | 0); let l = h_buckets[i]; if (l !== undefined) { if (replaceInBucket(eq, key, value, l)) { @@ -97,13 +98,13 @@ function set(h, key, value) { function remove(h, key) { let h_buckets = h.buckets; - let i = h.hash(key) & (h_buckets.length - 1 | 0); + let i = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let bucket = h_buckets[i]; if (bucket === undefined) { return; } let eq = h.eq; - if (eq(bucket.key, key)) { + if (Curry._2(eq, bucket.key, key)) { h_buckets[i] = bucket.next; h.size = h.size - 1 | 0; return; @@ -117,7 +118,7 @@ function remove(h, key) { return; } let cell_next = bucket$1.next; - if (eq(bucket$1.key, key)) { + if (Curry._2(eq, bucket$1.key, key)) { prec.next = cell_next; h.size = h.size - 1 | 0; return; @@ -131,25 +132,25 @@ function remove(h, key) { function get(h, key) { let h_buckets = h.buckets; - let nid = h.hash(key) & (h_buckets.length - 1 | 0); + let nid = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let cell1 = h_buckets[nid]; if (cell1 === undefined) { return; } let eq = h.eq; - if (eq(key, cell1.key)) { + if (Curry._2(eq, key, cell1.key)) { return Caml_option.some(cell1.value); } let cell2 = cell1.next; if (cell2 === undefined) { return; } - if (eq(key, cell2.key)) { + if (Curry._2(eq, key, cell2.key)) { return Caml_option.some(cell2.value); } let cell3 = cell2.next; if (cell3 !== undefined) { - if (eq(key, cell3.key)) { + if (Curry._2(eq, key, cell3.key)) { return Caml_option.some(cell3.value); } else { let _buckets = cell3.next; @@ -158,7 +159,7 @@ function get(h, key) { if (buckets === undefined) { return; } - if (eq(key, buckets.key)) { + if (Curry._2(eq, key, buckets.key)) { return Caml_option.some(buckets.value); } _buckets = buckets.next; @@ -171,14 +172,14 @@ function get(h, key) { function has(h, key) { let h_buckets = h.buckets; - let nid = h.hash(key) & (h_buckets.length - 1 | 0); + let nid = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let bucket = h_buckets[nid]; if (bucket !== undefined) { let _cell = bucket; let eq = h.eq; while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { return true; } let nextCell = cell.next; diff --git a/lib/js/belt_HashMapInt.js b/lib/js/belt_HashMapInt.js index 69e651f5a1..7c91e287d5 100644 --- a/lib/js/belt_HashMapInt.js +++ b/lib/js/belt_HashMapInt.js @@ -193,7 +193,7 @@ function size(h) { function fromArray(arr) { let len = arr.length; - let v = make(len); + let v = Belt_internalBucketsType.make(undefined, undefined, len); for(let i = 0; i < len; ++i){ let match = arr[i]; set(v, match[0], match[1]); diff --git a/lib/js/belt_HashMapString.js b/lib/js/belt_HashMapString.js index ee4a0d8f31..258b989a29 100644 --- a/lib/js/belt_HashMapString.js +++ b/lib/js/belt_HashMapString.js @@ -193,7 +193,7 @@ function size(h) { function fromArray(arr) { let len = arr.length; - let v = make(len); + let v = Belt_internalBucketsType.make(undefined, undefined, len); for(let i = 0; i < len; ++i){ let match = arr[i]; set(v, match[0], match[1]); diff --git a/lib/js/belt_HashSet.js b/lib/js/belt_HashSet.js index eba89cbe96..6a14a53214 100644 --- a/lib/js/belt_HashSet.js +++ b/lib/js/belt_HashSet.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_internalSetBuckets = require("./belt_internalSetBuckets.js"); let Belt_internalBucketsType = require("./belt_internalBucketsType.js"); @@ -9,7 +10,7 @@ function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { if (old_bucket === undefined) { return; } - let nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); + let nidx = Curry._1(hash, old_bucket.key) & (h_buckets.length - 1 | 0); let tail = ndata_tail[nidx]; if (tail !== undefined) { tail.next = old_bucket; @@ -25,13 +26,13 @@ function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { function remove(h, key) { let eq = h.eq; let h_buckets = h.buckets; - let i = h.hash(key) & (h_buckets.length - 1 | 0); + let i = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let l = h_buckets[i]; if (l === undefined) { return; } let next_cell = l.next; - if (eq(l.key, key)) { + if (Curry._2(eq, l.key, key)) { h.size = h.size - 1 | 0; h_buckets[i] = next_cell; return; @@ -42,7 +43,7 @@ function remove(h, key) { let cell = _cell; let prec = _prec; let cell_next = cell.next; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { prec.next = cell_next; h.size = h.size - 1 | 0; return; @@ -62,7 +63,7 @@ function remove(h, key) { function addBucket(h, key, _cell, eq) { while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { return; } let n = cell.next; @@ -82,7 +83,7 @@ function addBucket(h, key, _cell, eq) { function add0(h, key, hash, eq) { let h_buckets = h.buckets; let buckets_len = h_buckets.length; - let i = hash(key) & (buckets_len - 1 | 0); + let i = Curry._1(hash, key) & (buckets_len - 1 | 0); let l = h_buckets[i]; if (l !== undefined) { addBucket(h, key, l, eq); @@ -125,13 +126,13 @@ function add(h, key) { function has(h, key) { let eq = h.eq; let h_buckets = h.buckets; - let nid = h.hash(key) & (h_buckets.length - 1 | 0); + let nid = Curry._1(h.hash, key) & (h_buckets.length - 1 | 0); let bucket = h_buckets[nid]; if (bucket !== undefined) { let _cell = bucket; while(true) { let cell = _cell; - if (eq(cell.key, key)) { + if (Curry._2(eq, cell.key, key)) { return true; } let nextCell = cell.next; diff --git a/lib/js/belt_Id.js b/lib/js/belt_Id.js index 04d2ce0b37..2a855d8e40 100644 --- a/lib/js/belt_Id.js +++ b/lib/js/belt_Id.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); function MakeComparableU(M) { return M; @@ -7,9 +8,7 @@ function MakeComparableU(M) { function MakeComparable(M) { let cmp = M.cmp; - let cmp$1 = function (a, b) { - return cmp(a, b); - }; + let cmp$1 = Curry.__2(cmp); return { cmp: cmp$1 }; @@ -22,9 +21,7 @@ function comparableU(cmp) { } function comparable(cmp) { - let cmp$1 = function (a, b) { - return cmp(a, b); - }; + let cmp$1 = Curry.__2(cmp); return { cmp: cmp$1 }; @@ -36,13 +33,9 @@ function MakeHashableU(M) { function MakeHashable(M) { let hash = M.hash; - let hash$1 = function (a) { - return hash(a); - }; + let hash$1 = Curry.__1(hash); let eq = M.eq; - let eq$1 = function (a, b) { - return eq(a, b); - }; + let eq$1 = Curry.__2(eq); return { hash: hash$1, eq: eq$1 @@ -57,12 +50,8 @@ function hashableU(hash, eq) { } function hashable(hash, eq) { - let hash$1 = function (a) { - return hash(a); - }; - let eq$1 = function (a, b) { - return eq(a, b); - }; + let hash$1 = Curry.__1(hash); + let eq$1 = Curry.__2(eq); return { hash: hash$1, eq: eq$1 diff --git a/lib/js/belt_List.js b/lib/js/belt_List.js index 069df3dc72..b96dc8ab5c 100644 --- a/lib/js/belt_List.js +++ b/lib/js/belt_List.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_Array = require("./belt_Array.js"); let Caml_option = require("./caml_option.js"); let Belt_SortArray = require("./belt_SortArray.js"); @@ -112,7 +113,7 @@ function partitionAux(p, _cell, _precX, _precY) { hd: h, tl: /* [] */0 }; - if (p(h)) { + if (Curry._1(p, h)) { precX.tl = next; _precX = next; _cell = t; @@ -178,7 +179,7 @@ function copyAuxWitFilter(f, _cellX, _prec) { } let t = cellX.tl; let h = cellX.hd; - if (f(h)) { + if (Curry._1(f, h)) { let next = { hd: h, tl: /* [] */0 @@ -203,7 +204,7 @@ function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { } let t = cellX.tl; let h = cellX.hd; - if (f(h, i)) { + if (Curry._2(f, h, i)) { let next = { hd: h, tl: /* [] */0 @@ -228,7 +229,7 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { return; } let t = cellX.tl; - let h = f(cellX.hd); + let h = Curry._1(f, cellX.hd); if (h !== undefined) { let next = { hd: Caml_option.valFromOption(h), @@ -253,7 +254,7 @@ function removeAssocAuxWithMap(_cellX, x, _prec, f) { } let t = cellX.tl; let h = cellX.hd; - if (f(h[0], x)) { + if (Curry._2(f, h[0], x)) { prec.tl = t; return true; } @@ -277,7 +278,7 @@ function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { } let t = cellX.tl; let h = cellX.hd; - if (eq(h[0], x)) { + if (Curry._2(eq, h[0], x)) { prec.tl = { hd: [ x, @@ -306,7 +307,7 @@ function copyAuxWithMap(_cellX, _prec, f) { return; } let next = { - hd: f(cellX.hd), + hd: Curry._1(f, cellX.hd), tl: /* [] */0 }; prec.tl = next; @@ -354,7 +355,7 @@ function copyAuxWithMap2(f, _cellX, _cellY, _prec) { return; } let next = { - hd: f(cellX.hd, cellY.hd), + hd: Curry._2(f, cellX.hd, cellY.hd), tl: /* [] */0 }; prec.tl = next; @@ -374,7 +375,7 @@ function copyAuxWithMapI(f, _i, _cellX, _prec) { return; } let next = { - hd: f(i, cellX.hd), + hd: Curry._2(f, i, cellX.hd), tl: /* [] */0 }; prec.tl = next; @@ -518,7 +519,7 @@ function mapU(xs, f) { return /* [] */0; } let cell = { - hd: f(xs.hd), + hd: Curry._1(f, xs.hd), tl: /* [] */0 }; copyAuxWithMap(xs.tl, cell, f); @@ -526,9 +527,7 @@ function mapU(xs, f) { } function map(xs, f) { - return mapU(xs, (function (x) { - return f(x); - })); + return mapU(xs, Curry.__1(f)); } function zipByU(l1, l2, f) { @@ -539,7 +538,7 @@ function zipByU(l1, l2, f) { return /* [] */0; } let cell = { - hd: f(l1.hd, l2.hd), + hd: Curry._2(f, l1.hd, l2.hd), tl: /* [] */0 }; copyAuxWithMap2(f, l1.tl, l2.tl, cell); @@ -547,9 +546,7 @@ function zipByU(l1, l2, f) { } function zipBy(l1, l2, f) { - return zipByU(l1, l2, (function (x, y) { - return f(x, y); - })); + return zipByU(l1, l2, Curry.__2(f)); } function mapWithIndexU(xs, f) { @@ -557,7 +554,7 @@ function mapWithIndexU(xs, f) { return /* [] */0; } let cell = { - hd: f(0, xs.hd), + hd: Curry._2(f, 0, xs.hd), tl: /* [] */0 }; copyAuxWithMapI(f, 1, xs.tl, cell); @@ -565,9 +562,7 @@ function mapWithIndexU(xs, f) { } function mapWithIndex(xs, f) { - return mapWithIndexU(xs, (function (i, x) { - return f(i, x); - })); + return mapWithIndexU(xs, Curry.__2(f)); } function makeByU(n, f) { @@ -575,14 +570,14 @@ function makeByU(n, f) { return /* [] */0; } let headX = { - hd: f(0), + hd: Curry._1(f, 0), tl: /* [] */0 }; let cur = headX; let i = 1; while(i < n) { let v = { - hd: f(i), + hd: Curry._1(f, i), tl: /* [] */0 }; cur.tl = v; @@ -593,9 +588,7 @@ function makeByU(n, f) { } function makeBy(n, f) { - return makeByU(n, (function (x) { - return f(x); - })); + return makeByU(n, Curry.__1(f)); } function make(n, v) { @@ -761,7 +754,7 @@ function mapReverseU(l, f) { } _xs = xs.tl; _accu = { - hd: f(xs.hd), + hd: Curry._1(f, xs.hd), tl: accu }; continue; @@ -769,9 +762,7 @@ function mapReverseU(l, f) { } function mapReverse(l, f) { - return mapReverseU(l, (function (x) { - return f(x); - })); + return mapReverseU(l, Curry.__1(f)); } function forEachU(_xs, f) { @@ -780,16 +771,14 @@ function forEachU(_xs, f) { if (!xs) { return; } - f(xs.hd); + Curry._1(f, xs.hd); _xs = xs.tl; continue; }; } function forEach(xs, f) { - forEachU(xs, (function (x) { - return f(x); - })); + forEachU(xs, Curry.__1(f)); } function forEachWithIndexU(l, f) { @@ -801,7 +790,7 @@ function forEachWithIndexU(l, f) { if (!xs) { return; } - f(i, xs.hd); + Curry._2(f, i, xs.hd); _i = i + 1 | 0; _xs = xs.tl; continue; @@ -809,9 +798,7 @@ function forEachWithIndexU(l, f) { } function forEachWithIndex(l, f) { - forEachWithIndexU(l, (function (i, x) { - return f(i, x); - })); + forEachWithIndexU(l, Curry.__2(f)); } function reduceU(_l, _accu, f) { @@ -821,21 +808,19 @@ function reduceU(_l, _accu, f) { if (!l) { return accu; } - _accu = f(accu, l.hd); + _accu = Curry._2(f, accu, l.hd); _l = l.tl; continue; }; } function reduce(l, accu, f) { - return reduceU(l, accu, (function (acc, x) { - return f(acc, x); - })); + return reduceU(l, accu, Curry.__2(f)); } function reduceReverseUnsafeU(l, accu, f) { if (l) { - return f(reduceReverseUnsafeU(l.tl, accu, f), l.hd); + return Curry._2(f, reduceReverseUnsafeU(l.tl, accu, f), l.hd); } else { return accu; } @@ -851,9 +836,7 @@ function reduceReverseU(l, acc, f) { } function reduceReverse(l, accu, f) { - return reduceReverseU(l, accu, (function (a, b) { - return f(a, b); - })); + return reduceReverseU(l, accu, Curry.__2(f)); } function reduceWithIndexU(l, acc, f) { @@ -868,16 +851,14 @@ function reduceWithIndexU(l, acc, f) { return acc$1; } _i = i + 1 | 0; - _acc = f(acc$1, l$1.hd, i); + _acc = Curry._3(f, acc$1, l$1.hd, i); _l = l$1.tl; continue; }; } function reduceWithIndex(l, acc, f) { - return reduceWithIndexU(l, acc, (function (acc, x, i) { - return f(acc, x, i); - })); + return reduceWithIndexU(l, acc, Curry.__3(f)); } function mapReverse2U(l1, l2, f) { @@ -895,7 +876,7 @@ function mapReverse2U(l1, l2, f) { return accu; } _accu = { - hd: f(l1$1.hd, l2$1.hd), + hd: Curry._2(f, l1$1.hd, l2$1.hd), tl: accu }; _l2 = l2$1.tl; @@ -905,9 +886,7 @@ function mapReverse2U(l1, l2, f) { } function mapReverse2(l1, l2, f) { - return mapReverse2U(l1, l2, (function (a, b) { - return f(a, b); - })); + return mapReverse2U(l1, l2, Curry.__2(f)); } function forEach2U(_l1, _l2, f) { @@ -920,7 +899,7 @@ function forEach2U(_l1, _l2, f) { if (!l2) { return; } - f(l1.hd, l2.hd); + Curry._2(f, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -928,9 +907,7 @@ function forEach2U(_l1, _l2, f) { } function forEach2(l1, l2, f) { - forEach2U(l1, l2, (function (a, b) { - return f(a, b); - })); + forEach2U(l1, l2, Curry.__2(f)); } function reduce2U(_l1, _l2, _accu, f) { @@ -944,7 +921,7 @@ function reduce2U(_l1, _l2, _accu, f) { if (!l2) { return accu; } - _accu = f(accu, l1.hd, l2.hd); + _accu = Curry._3(f, accu, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -952,14 +929,12 @@ function reduce2U(_l1, _l2, _accu, f) { } function reduce2(l1, l2, acc, f) { - return reduce2U(l1, l2, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduce2U(l1, l2, acc, Curry.__3(f)); } function reduceReverse2UnsafeU(l1, l2, accu, f) { if (l1 && l2) { - return f(reduceReverse2UnsafeU(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); + return Curry._3(f, reduceReverse2UnsafeU(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); } else { return accu; } @@ -975,9 +950,7 @@ function reduceReverse2U(l1, l2, acc, f) { } function reduceReverse2(l1, l2, acc, f) { - return reduceReverse2U(l1, l2, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceReverse2U(l1, l2, acc, Curry.__3(f)); } function everyU(_xs, p) { @@ -986,7 +959,7 @@ function everyU(_xs, p) { if (!xs) { return true; } - if (!p(xs.hd)) { + if (!Curry._1(p, xs.hd)) { return false; } _xs = xs.tl; @@ -995,9 +968,7 @@ function everyU(_xs, p) { } function every(xs, p) { - return everyU(xs, (function (x) { - return p(x); - })); + return everyU(xs, Curry.__1(p)); } function someU(_xs, p) { @@ -1006,7 +977,7 @@ function someU(_xs, p) { if (!xs) { return false; } - if (p(xs.hd)) { + if (Curry._1(p, xs.hd)) { return true; } _xs = xs.tl; @@ -1015,9 +986,7 @@ function someU(_xs, p) { } function some(xs, p) { - return someU(xs, (function (x) { - return p(x); - })); + return someU(xs, Curry.__1(p)); } function every2U(_l1, _l2, p) { @@ -1030,7 +999,7 @@ function every2U(_l1, _l2, p) { if (!l2) { return true; } - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -1040,9 +1009,7 @@ function every2U(_l1, _l2, p) { } function every2(l1, l2, p) { - return every2U(l1, l2, (function (a, b) { - return p(a, b); - })); + return every2U(l1, l2, Curry.__2(p)); } function cmpByLength(_l1, _l2) { @@ -1079,7 +1046,7 @@ function cmpU(_l1, _l2, p) { if (!l2) { return 1; } - let c = p(l1.hd, l2.hd); + let c = Curry._2(p, l1.hd, l2.hd); if (c !== 0) { return c; } @@ -1090,9 +1057,7 @@ function cmpU(_l1, _l2, p) { } function cmp(l1, l2, f) { - return cmpU(l1, l2, (function (x, y) { - return f(x, y); - })); + return cmpU(l1, l2, Curry.__2(f)); } function eqU(_l1, _l2, p) { @@ -1109,7 +1074,7 @@ function eqU(_l1, _l2, p) { if (!l2) { return false; } - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -1119,9 +1084,7 @@ function eqU(_l1, _l2, p) { } function eq(l1, l2, f) { - return eqU(l1, l2, (function (x, y) { - return f(x, y); - })); + return eqU(l1, l2, Curry.__2(f)); } function some2U(_l1, _l2, p) { @@ -1134,7 +1097,7 @@ function some2U(_l1, _l2, p) { if (!l2) { return false; } - if (p(l1.hd, l2.hd)) { + if (Curry._2(p, l1.hd, l2.hd)) { return true; } _l2 = l2.tl; @@ -1144,9 +1107,7 @@ function some2U(_l1, _l2, p) { } function some2(l1, l2, p) { - return some2U(l1, l2, (function (a, b) { - return p(a, b); - })); + return some2U(l1, l2, Curry.__2(p)); } function hasU(_xs, x, eq) { @@ -1155,7 +1116,7 @@ function hasU(_xs, x, eq) { if (!xs) { return false; } - if (eq(xs.hd, x)) { + if (Curry._2(eq, xs.hd, x)) { return true; } _xs = xs.tl; @@ -1164,9 +1125,7 @@ function hasU(_xs, x, eq) { } function has(xs, x, eq) { - return hasU(xs, x, (function (a, b) { - return eq(a, b); - })); + return hasU(xs, x, Curry.__2(eq)); } function getAssocU(_xs, x, eq) { @@ -1176,7 +1135,7 @@ function getAssocU(_xs, x, eq) { return; } let match = xs.hd; - if (eq(match[0], x)) { + if (Curry._2(eq, match[0], x)) { return Caml_option.some(match[1]); } _xs = xs.tl; @@ -1185,9 +1144,7 @@ function getAssocU(_xs, x, eq) { } function getAssoc(xs, x, eq) { - return getAssocU(xs, x, (function (a, b) { - return eq(a, b); - })); + return getAssocU(xs, x, Curry.__2(eq)); } function hasAssocU(_xs, x, eq) { @@ -1196,7 +1153,7 @@ function hasAssocU(_xs, x, eq) { if (!xs) { return false; } - if (eq(xs.hd[0], x)) { + if (Curry._2(eq, xs.hd[0], x)) { return true; } _xs = xs.tl; @@ -1205,9 +1162,7 @@ function hasAssocU(_xs, x, eq) { } function hasAssoc(xs, x, eq) { - return hasAssocU(xs, x, (function (a, b) { - return eq(a, b); - })); + return hasAssocU(xs, x, Curry.__2(eq)); } function removeAssocU(xs, x, eq) { @@ -1216,7 +1171,7 @@ function removeAssocU(xs, x, eq) { } let l = xs.tl; let pair = xs.hd; - if (eq(pair[0], x)) { + if (Curry._2(eq, pair[0], x)) { return l; } let cell = { @@ -1232,9 +1187,7 @@ function removeAssocU(xs, x, eq) { } function removeAssoc(xs, x, eq) { - return removeAssocU(xs, x, (function (a, b) { - return eq(a, b); - })); + return removeAssocU(xs, x, Curry.__2(eq)); } function setAssocU(xs, x, k, eq) { @@ -1249,7 +1202,7 @@ function setAssocU(xs, x, k, eq) { } let l = xs.tl; let pair = xs.hd; - if (eq(pair[0], x)) { + if (Curry._2(eq, pair[0], x)) { return { hd: [ x, @@ -1277,9 +1230,7 @@ function setAssocU(xs, x, k, eq) { } function setAssoc(xs, x, k, eq) { - return setAssocU(xs, x, k, (function (a, b) { - return eq(a, b); - })); + return setAssocU(xs, x, k, Curry.__2(eq)); } function sortU(xs, cmp) { @@ -1289,9 +1240,7 @@ function sortU(xs, cmp) { } function sort(xs, cmp) { - return sortU(xs, (function (x, y) { - return cmp(x, y); - })); + return sortU(xs, Curry.__2(cmp)); } function getByU(_xs, p) { @@ -1301,7 +1250,7 @@ function getByU(_xs, p) { return; } let x = xs.hd; - if (p(x)) { + if (Curry._1(p, x)) { return Caml_option.some(x); } _xs = xs.tl; @@ -1310,9 +1259,7 @@ function getByU(_xs, p) { } function getBy(xs, p) { - return getByU(xs, (function (a) { - return p(a); - })); + return getByU(xs, Curry.__1(p)); } function keepU(_xs, p) { @@ -1323,7 +1270,7 @@ function keepU(_xs, p) { } let t = xs.tl; let h = xs.hd; - if (p(h)) { + if (Curry._1(p, h)) { let cell = { hd: h, tl: /* [] */0 @@ -1337,9 +1284,7 @@ function keepU(_xs, p) { } function keep(xs, p) { - return keepU(xs, (function (x) { - return p(x); - })); + return keepU(xs, Curry.__1(p)); } function keepWithIndexU(xs, p) { @@ -1353,7 +1298,7 @@ function keepWithIndexU(xs, p) { } let t = xs$1.tl; let h = xs$1.hd; - if (p(h, i)) { + if (Curry._2(p, h, i)) { let cell = { hd: h, tl: /* [] */0 @@ -1368,9 +1313,7 @@ function keepWithIndexU(xs, p) { } function keepWithIndex(xs, p) { - return keepWithIndexU(xs, (function (x, i) { - return p(x, i); - })); + return keepWithIndexU(xs, Curry.__2(p)); } function keepMapU(_xs, p) { @@ -1380,7 +1323,7 @@ function keepMapU(_xs, p) { return /* [] */0; } let t = xs.tl; - let h = p(xs.hd); + let h = Curry._1(p, xs.hd); if (h !== undefined) { let cell = { hd: Caml_option.valFromOption(h), @@ -1395,9 +1338,7 @@ function keepMapU(_xs, p) { } function keepMap(xs, p) { - return keepMapU(xs, (function (x) { - return p(x); - })); + return keepMapU(xs, Curry.__1(p)); } function partitionU(l, p) { @@ -1416,7 +1357,7 @@ function partitionU(l, p) { hd: h, tl: /* [] */0 }; - let b = p(h); + let b = Curry._1(p, h); partitionAux(p, l.tl, nextX, nextY); if (b) { return [ @@ -1432,9 +1373,7 @@ function partitionU(l, p) { } function partition(l, p) { - return partitionU(l, (function (x) { - return p(x); - })); + return partitionU(l, Curry.__1(p)); } function unzip(xs) { diff --git a/lib/js/belt_Map.js b/lib/js/belt_Map.js index 3db312ce0c..eb96116851 100644 --- a/lib/js/belt_Map.js +++ b/lib/js/belt_Map.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_MapDict = require("./belt_MapDict.js"); function fromArray(data, id) { @@ -58,9 +59,7 @@ function updateU(m, key, f) { } function update(m, key, f) { - return updateU(m, key, (function (a) { - return f(a); - })); + return updateU(m, key, Curry.__1(f)); } function split(m, x) { @@ -91,9 +90,7 @@ function mergeU(s1, s2, f) { } function merge(s1, s2, f) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - })); + return mergeU(s1, s2, Curry.__3(f)); } function make(id) { @@ -112,9 +109,7 @@ function findFirstByU(m, f) { } function findFirstBy(m, f) { - return findFirstByU(m, (function (a, b) { - return f(a, b); - })); + return Belt_MapDict.findFirstByU(m.data, Curry.__2(f)); } function forEachU(m, f) { @@ -122,9 +117,7 @@ function forEachU(m, f) { } function forEach(m, f) { - forEachU(m, (function (a, b) { - f(a, b); - })); + Belt_MapDict.forEachU(m.data, Curry.__2(f)); } function reduceU(m, acc, f) { @@ -132,9 +125,7 @@ function reduceU(m, acc, f) { } function reduce(m, acc, f) { - return reduceU(m, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(m, acc, Curry.__3(f)); } function everyU(m, f) { @@ -142,9 +133,7 @@ function everyU(m, f) { } function every(m, f) { - return everyU(m, (function (a, b) { - return f(a, b); - })); + return Belt_MapDict.everyU(m.data, Curry.__2(f)); } function someU(m, f) { @@ -152,9 +141,7 @@ function someU(m, f) { } function some(m, f) { - return someU(m, (function (a, b) { - return f(a, b); - })); + return Belt_MapDict.someU(m.data, Curry.__2(f)); } function keepU(m, f) { @@ -165,9 +152,7 @@ function keepU(m, f) { } function keep(m, f) { - return keepU(m, (function (a, b) { - return f(a, b); - })); + return keepU(m, Curry.__2(f)); } function partitionU(m, p) { @@ -186,9 +171,7 @@ function partitionU(m, p) { } function partition(m, p) { - return partitionU(m, (function (a, b) { - return p(a, b); - })); + return partitionU(m, Curry.__2(p)); } function mapU(m, f) { @@ -199,9 +182,7 @@ function mapU(m, f) { } function map(m, f) { - return mapU(m, (function (a) { - return f(a); - })); + return mapU(m, Curry.__1(f)); } function mapWithKeyU(m, f) { @@ -212,9 +193,7 @@ function mapWithKeyU(m, f) { } function mapWithKey(m, f) { - return mapWithKeyU(m, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(m, Curry.__2(f)); } function size(map) { @@ -298,9 +277,7 @@ function eqU(m1, m2, veq) { } function eq(m1, m2, veq) { - return eqU(m1, m2, (function (a, b) { - return veq(a, b); - })); + return eqU(m1, m2, Curry.__2(veq)); } function cmpU(m1, m2, vcmp) { @@ -308,9 +285,7 @@ function cmpU(m1, m2, vcmp) { } function cmp(m1, m2, vcmp) { - return cmpU(m1, m2, (function (a, b) { - return vcmp(a, b); - })); + return cmpU(m1, m2, Curry.__2(vcmp)); } function getData(m) { diff --git a/lib/js/belt_MapDict.js b/lib/js/belt_MapDict.js index f906153838..9eabd568fa 100644 --- a/lib/js/belt_MapDict.js +++ b/lib/js/belt_MapDict.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); @@ -8,7 +9,7 @@ function set(t, newK, newD, cmp) { return Belt_internalAVLtree.singleton(newK, newD); } let k = t.k; - let c = cmp(newK, k); + let c = Curry._2(cmp, newK, k); if (c === 0) { return Belt_internalAVLtree.updateValue(t, newD); } @@ -25,9 +26,9 @@ function set(t, newK, newD, cmp) { function updateU(t, newK, f, cmp) { if (t !== undefined) { let k = t.k; - let c = cmp(newK, k); + let c = Curry._2(cmp, newK, k); if (c === 0) { - let newD = f(Caml_option.some(t.v)); + let newD = Curry._1(f, Caml_option.some(t.v)); if (newD !== undefined) { return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(newD)); } @@ -66,7 +67,7 @@ function updateU(t, newK, f, cmp) { return Belt_internalAVLtree.bal(l$1, k, v, rr); } } - let newD$1 = f(undefined); + let newD$1 = Curry._1(f, undefined); if (newD$1 !== undefined) { return Belt_internalAVLtree.singleton(newK, Caml_option.valFromOption(newD$1)); } else { @@ -75,16 +76,14 @@ function updateU(t, newK, f, cmp) { } function update(t, newK, f, cmp) { - return updateU(t, newK, (function (a) { - return f(a); - }), cmp); + return updateU(t, newK, Curry.__1(f), cmp); } function removeAux0(n, x, cmp) { let v = n.k; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { if (l === undefined) { return r; @@ -145,7 +144,7 @@ function splitAuxPivot(n, x, pres, cmp) { let d = n.v; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { pres.contents = Caml_option.some(d); return [ @@ -203,7 +202,7 @@ function mergeU(s1, s2, f, cmp) { if (s1 === undefined) { if (s2 !== undefined) { return Belt_internalAVLtree.keepMapU(s2, (function (k, v) { - return f(k, undefined, Caml_option.some(v)); + return Curry._3(f, k, undefined, Caml_option.some(v)); })); } else { return; @@ -211,7 +210,7 @@ function mergeU(s1, s2, f, cmp) { } if (s2 === undefined) { return Belt_internalAVLtree.keepMapU(s1, (function (k, v) { - return f(k, Caml_option.some(v), undefined); + return Curry._3(f, k, Caml_option.some(v), undefined); })); } if (s1.h >= s2.h) { @@ -225,7 +224,7 @@ function mergeU(s1, s2, f, cmp) { let match = splitAuxPivot(s2, v1, d2, cmp); let d2$1 = d2.contents; let newLeft = mergeU(l1, match[0], f, cmp); - let newD = f(v1, Caml_option.some(d1), d2$1); + let newD = Curry._3(f, v1, Caml_option.some(d1), d2$1); let newRight = mergeU(r1, match[1], f, cmp); return Belt_internalAVLtree.concatOrJoin(newLeft, v1, newD, newRight); } @@ -239,15 +238,13 @@ function mergeU(s1, s2, f, cmp) { let match$1 = splitAuxPivot(s1, v2, d1$1, cmp); let d1$2 = d1$1.contents; let newLeft$1 = mergeU(match$1[0], l2, f, cmp); - let newD$1 = f(v2, d1$2, Caml_option.some(d2$2)); + let newD$1 = Curry._3(f, v2, d1$2, Caml_option.some(d2$2)); let newRight$1 = mergeU(match$1[1], r2, f, cmp); return Belt_internalAVLtree.concatOrJoin(newLeft$1, v2, newD$1, newRight$1); } function merge(s1, s2, f, cmp) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - }), cmp); + return mergeU(s1, s2, Curry.__3(f), cmp); } function removeMany(t, keys, cmp) { diff --git a/lib/js/belt_MapInt.js b/lib/js/belt_MapInt.js index 9143413026..cece70b016 100644 --- a/lib/js/belt_MapInt.js +++ b/lib/js/belt_MapInt.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_internalMapInt = require("./belt_internalMapInt.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); @@ -24,7 +25,7 @@ function updateU(t, x, f) { if (t !== undefined) { let k = t.k; if (x === k) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); } @@ -63,7 +64,7 @@ function updateU(t, x, f) { return Belt_internalAVLtree.bal(l$1, k, v, rr); } } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -72,9 +73,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - return updateU(t, x, (function (a) { - return f(a); - })); + return updateU(t, x, Curry.__1(f)); } function removeAux(n, x) { diff --git a/lib/js/belt_MapString.js b/lib/js/belt_MapString.js index d5f2530092..dc716a6924 100644 --- a/lib/js/belt_MapString.js +++ b/lib/js/belt_MapString.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); let Belt_internalMapString = require("./belt_internalMapString.js"); @@ -24,7 +25,7 @@ function updateU(t, x, f) { if (t !== undefined) { let k = t.k; if (x === k) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); } @@ -63,7 +64,7 @@ function updateU(t, x, f) { return Belt_internalAVLtree.bal(l$1, k, v, rr); } } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -72,9 +73,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - return updateU(t, x, (function (a) { - return f(a); - })); + return updateU(t, x, Curry.__1(f)); } function removeAux(n, x) { diff --git a/lib/js/belt_MutableMap.js b/lib/js/belt_MutableMap.js index 13e20ff3c9..ba7bf2f94e 100644 --- a/lib/js/belt_MutableMap.js +++ b/lib/js/belt_MutableMap.js @@ -1,11 +1,12 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); function removeMutateAux(nt, x, cmp) { let k = nt.k; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { let l = nt.l; let r = nt.r; @@ -88,9 +89,9 @@ function removeMany(d, xs) { function updateDone(t, x, f, cmp) { if (t !== undefined) { let k = t.k; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { t.v = Caml_option.valFromOption(data); return t; @@ -117,7 +118,7 @@ function updateDone(t, x, f, cmp) { } return Belt_internalAVLtree.balMutate(t); } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -136,9 +137,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - updateU(t, x, (function (a) { - return f(a); - })); + updateU(t, x, Curry.__1(f)); } function make(id) { @@ -153,7 +152,8 @@ function clear(m) { } function isEmpty(d) { - return d.data === undefined; + let x = d.data; + return x === undefined; } function minKey(m) { @@ -193,9 +193,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a, b) { - f(a, b); - })); + Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); } function reduceU(d, acc, cb) { @@ -203,9 +201,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b, c) { - return cb(a, b, c); - })); + return reduceU(d, acc, Curry.__3(cb)); } function everyU(d, p) { @@ -213,9 +209,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a, b) { - return p(a, b); - })); + return Belt_internalAVLtree.everyU(d.data, Curry.__2(p)); } function someU(d, p) { @@ -223,9 +217,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a, b) { - return p(a, b); - })); + return Belt_internalAVLtree.someU(d.data, Curry.__2(p)); } function size(d) { @@ -257,9 +249,7 @@ function cmpU(m1, m2, cmp) { } function cmp(m1, m2, cmp$1) { - return cmpU(m1, m2, (function (a, b) { - return cmp$1(a, b); - })); + return cmpU(m1, m2, Curry.__2(cmp$1)); } function eqU(m1, m2, cmp) { @@ -267,9 +257,7 @@ function eqU(m1, m2, cmp) { } function eq(m1, m2, cmp) { - return eqU(m1, m2, (function (a, b) { - return cmp(a, b); - })); + return eqU(m1, m2, Curry.__2(cmp)); } function mapU(m, f) { @@ -280,9 +268,7 @@ function mapU(m, f) { } function map(m, f) { - return mapU(m, (function (a) { - return f(a); - })); + return mapU(m, Curry.__1(f)); } function mapWithKeyU(m, f) { @@ -293,9 +279,7 @@ function mapWithKeyU(m, f) { } function mapWithKey(m, f) { - return mapWithKeyU(m, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(m, Curry.__2(f)); } function get(m, x) { diff --git a/lib/js/belt_MutableMapInt.js b/lib/js/belt_MutableMapInt.js index abc68b02b1..803f7a3fd0 100644 --- a/lib/js/belt_MutableMapInt.js +++ b/lib/js/belt_MutableMapInt.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_internalMapInt = require("./belt_internalMapInt.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); @@ -11,7 +12,8 @@ function make() { } function isEmpty(m) { - return m.data === undefined; + let x = m.data; + return x === undefined; } function clear(m) { @@ -65,9 +67,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a, b) { - f(a, b); - })); + Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); } function mapU(d, f) { @@ -77,9 +77,7 @@ function mapU(d, f) { } function map(d, f) { - return mapU(d, (function (a) { - return f(a); - })); + return mapU(d, Curry.__1(f)); } function mapWithKeyU(d, f) { @@ -89,9 +87,7 @@ function mapWithKeyU(d, f) { } function mapWithKey(d, f) { - return mapWithKeyU(d, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(d, Curry.__2(f)); } function reduceU(d, acc, f) { @@ -99,9 +95,7 @@ function reduceU(d, acc, f) { } function reduce(d, acc, f) { - return reduceU(d, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(d, acc, Curry.__3(f)); } function everyU(d, f) { @@ -109,9 +103,7 @@ function everyU(d, f) { } function every(d, f) { - return everyU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); } function someU(d, f) { @@ -119,9 +111,7 @@ function someU(d, f) { } function some(d, f) { - return someU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); } function size(d) { @@ -203,7 +193,7 @@ function updateDone(t, x, f) { if (t !== undefined) { let k = t.k; if (k === x) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { t.v = Caml_option.valFromOption(data); return t; @@ -231,7 +221,7 @@ function updateDone(t, x, f) { } return Belt_internalAVLtree.balMutate(t); } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -250,9 +240,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - updateU(t, x, (function (a) { - return f(a); - })); + updateU(t, x, Curry.__1(f)); } function removeArrayMutateAux(_t, xs, _i, len) { @@ -298,9 +286,7 @@ function cmpU(d0, d1, f) { } function cmp(d0, d1, f) { - return cmpU(d0, d1, (function (a, b) { - return f(a, b); - })); + return cmpU(d0, d1, Curry.__2(f)); } function eqU(d0, d1, f) { @@ -308,9 +294,7 @@ function eqU(d0, d1, f) { } function eq(d0, d1, f) { - return eqU(d0, d1, (function (a, b) { - return f(a, b); - })); + return eqU(d0, d1, Curry.__2(f)); } function get(d, x) { diff --git a/lib/js/belt_MutableMapString.js b/lib/js/belt_MutableMapString.js index 0db5237044..4c76e529d6 100644 --- a/lib/js/belt_MutableMapString.js +++ b/lib/js/belt_MutableMapString.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); let Belt_internalMapString = require("./belt_internalMapString.js"); @@ -11,7 +12,8 @@ function make() { } function isEmpty(m) { - return m.data === undefined; + let x = m.data; + return x === undefined; } function clear(m) { @@ -65,9 +67,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a, b) { - f(a, b); - })); + Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); } function mapU(d, f) { @@ -77,9 +77,7 @@ function mapU(d, f) { } function map(d, f) { - return mapU(d, (function (a) { - return f(a); - })); + return mapU(d, Curry.__1(f)); } function mapWithKeyU(d, f) { @@ -89,9 +87,7 @@ function mapWithKeyU(d, f) { } function mapWithKey(d, f) { - return mapWithKeyU(d, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(d, Curry.__2(f)); } function reduceU(d, acc, f) { @@ -99,9 +95,7 @@ function reduceU(d, acc, f) { } function reduce(d, acc, f) { - return reduceU(d, acc, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(d, acc, Curry.__3(f)); } function everyU(d, f) { @@ -109,9 +103,7 @@ function everyU(d, f) { } function every(d, f) { - return everyU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); } function someU(d, f) { @@ -119,9 +111,7 @@ function someU(d, f) { } function some(d, f) { - return someU(d, (function (a, b) { - return f(a, b); - })); + return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); } function size(d) { @@ -203,7 +193,7 @@ function updateDone(t, x, f) { if (t !== undefined) { let k = t.k; if (k === x) { - let data = f(Caml_option.some(t.v)); + let data = Curry._1(f, Caml_option.some(t.v)); if (data !== undefined) { t.v = Caml_option.valFromOption(data); return t; @@ -231,7 +221,7 @@ function updateDone(t, x, f) { } return Belt_internalAVLtree.balMutate(t); } - let data$1 = f(undefined); + let data$1 = Curry._1(f, undefined); if (data$1 !== undefined) { return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); } else { @@ -250,9 +240,7 @@ function updateU(t, x, f) { } function update(t, x, f) { - updateU(t, x, (function (a) { - return f(a); - })); + updateU(t, x, Curry.__1(f)); } function removeArrayMutateAux(_t, xs, _i, len) { @@ -298,9 +286,7 @@ function cmpU(d0, d1, f) { } function cmp(d0, d1, f) { - return cmpU(d0, d1, (function (a, b) { - return f(a, b); - })); + return cmpU(d0, d1, Curry.__2(f)); } function eqU(d0, d1, f) { @@ -308,9 +294,7 @@ function eqU(d0, d1, f) { } function eq(d0, d1, f) { - return eqU(d0, d1, (function (a, b) { - return f(a, b); - })); + return eqU(d0, d1, Curry.__2(f)); } function get(d, x) { diff --git a/lib/js/belt_MutableQueue.js b/lib/js/belt_MutableQueue.js index 6f4af135ad..87d980c1b1 100644 --- a/lib/js/belt_MutableQueue.js +++ b/lib/js/belt_MutableQueue.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function make() { @@ -156,7 +157,7 @@ function mapU(q, f) { let cell = _cell; let prev = _prev; if (cell !== undefined) { - let content = f(cell.content); + let content = Curry._1(f, cell.content); let res = { content: content, next: undefined @@ -176,9 +177,7 @@ function mapU(q, f) { } function map(q, f) { - return mapU(q, (function (a) { - return f(a); - })); + return mapU(q, Curry.__1(f)); } function isEmpty(q) { @@ -196,16 +195,14 @@ function forEachU(q, f) { if (cell === undefined) { return; } - f(cell.content); + Curry._1(f, cell.content); _cell = cell.next; continue; }; } function forEach(q, f) { - forEachU(q, (function (a) { - f(a); - })); + forEachU(q, Curry.__1(f)); } function reduceU(q, accu, f) { @@ -217,7 +214,7 @@ function reduceU(q, accu, f) { if (cell === undefined) { return accu$1; } - let accu$2 = f(accu$1, cell.content); + let accu$2 = Curry._2(f, accu$1, cell.content); _cell = cell.next; _accu = accu$2; continue; @@ -225,9 +222,7 @@ function reduceU(q, accu, f) { } function reduce(q, accu, f) { - return reduceU(q, accu, (function (a, b) { - return f(a, b); - })); + return reduceU(q, accu, Curry.__2(f)); } function transfer(q1, q2) { diff --git a/lib/js/belt_MutableSet.js b/lib/js/belt_MutableSet.js index 6b94e54528..d77074249b 100644 --- a/lib/js/belt_MutableSet.js +++ b/lib/js/belt_MutableSet.js @@ -1,11 +1,12 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_SortArray = require("./belt_SortArray.js"); let Belt_internalAVLset = require("./belt_internalAVLset.js"); function remove0(nt, x, cmp) { let k = nt.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { let l = nt.l; let r = nt.r; @@ -80,7 +81,7 @@ function removeMany(d, xs) { function removeCheck0(nt, x, removed, cmp) { let k = nt.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { removed.contents = true; let l = nt.l; @@ -132,7 +133,7 @@ function removeCheck(d, v) { function addCheck0(t, x, added, cmp) { if (t !== undefined) { let k = t.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { return t; } @@ -192,7 +193,8 @@ function make(id) { } function isEmpty(d) { - return d.data === undefined; + let n = d.data; + return n === undefined; } function minimum(d) { @@ -216,9 +218,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a) { - f(a); - })); + Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); } function reduceU(d, acc, cb) { @@ -226,9 +226,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b) { - return cb(a, b); - })); + return reduceU(d, acc, Curry.__2(cb)); } function everyU(d, p) { @@ -236,9 +234,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); } function someU(d, p) { @@ -246,9 +242,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.someU(d.data, Curry.__1(p)); } function size(d) { @@ -346,9 +340,7 @@ function keepU(d, p) { } function keep(d, p) { - return keepU(d, (function (a) { - return p(a); - })); + return keepU(d, Curry.__1(p)); } function partitionU(d, p) { @@ -367,9 +359,7 @@ function partitionU(d, p) { } function partition(d, p) { - return partitionU(d, (function (a) { - return p(a); - })); + return partitionU(d, Curry.__1(p)); } function subset(a, b) { @@ -398,7 +388,7 @@ function intersect(a, b) { let tmp = new Array(totalSize); Belt_internalAVLset.fillArray(match, 0, tmp); Belt_internalAVLset.fillArray(match$1, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { + if (Curry._2(cmp, tmp[sizea - 1 | 0], tmp[sizea]) < 0 || Curry._2(cmp, tmp[totalSize - 1 | 0], tmp[0]) < 0) { return { cmp: cmp, data: undefined @@ -434,7 +424,7 @@ function diff(a, b) { let tmp = new Array(totalSize); Belt_internalAVLset.fillArray(dataa, 0, tmp); Belt_internalAVLset.fillArray(match, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { + if (Curry._2(cmp, tmp[sizea - 1 | 0], tmp[sizea]) < 0 || Curry._2(cmp, tmp[totalSize - 1 | 0], tmp[0]) < 0) { return { cmp: cmp, data: Belt_internalAVLset.copy(dataa) @@ -470,7 +460,7 @@ function union(a, b) { let tmp = new Array(totalSize); Belt_internalAVLset.fillArray(dataa, 0, tmp); Belt_internalAVLset.fillArray(datab, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0) { + if (Curry._2(cmp, tmp[sizea - 1 | 0], tmp[sizea]) < 0) { return { cmp: cmp, data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) diff --git a/lib/js/belt_MutableSetInt.js b/lib/js/belt_MutableSetInt.js index 691e015f3e..e4c4240e39 100644 --- a/lib/js/belt_MutableSetInt.js +++ b/lib/js/belt_MutableSetInt.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_SortArrayInt = require("./belt_SortArrayInt.js"); let Belt_internalAVLset = require("./belt_internalAVLset.js"); let Belt_internalSetInt = require("./belt_internalSetInt.js"); @@ -189,7 +190,8 @@ function make() { } function isEmpty(d) { - return d.data === undefined; + let n = d.data; + return n === undefined; } function minimum(d) { @@ -213,9 +215,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a) { - f(a); - })); + Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); } function reduceU(d, acc, cb) { @@ -223,9 +223,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b) { - return cb(a, b); - })); + return reduceU(d, acc, Curry.__2(cb)); } function everyU(d, p) { @@ -233,9 +231,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); } function someU(d, p) { @@ -243,9 +239,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.someU(d.data, Curry.__1(p)); } function size(d) { @@ -334,9 +328,7 @@ function keepU(d, p) { } function keep(d, p) { - return keepU(d, (function (a) { - return p(a); - })); + return keepU(d, Curry.__1(p)); } function partitionU(d, p) { @@ -352,9 +344,7 @@ function partitionU(d, p) { } function partition(d, p) { - return partitionU(d, (function (a) { - return p(a); - })); + return partitionU(d, Curry.__1(p)); } function subset(a, b) { diff --git a/lib/js/belt_MutableSetString.js b/lib/js/belt_MutableSetString.js index c13ba1c2dc..5585530ff7 100644 --- a/lib/js/belt_MutableSetString.js +++ b/lib/js/belt_MutableSetString.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_internalAVLset = require("./belt_internalAVLset.js"); let Belt_SortArrayString = require("./belt_SortArrayString.js"); let Belt_internalSetString = require("./belt_internalSetString.js"); @@ -189,7 +190,8 @@ function make() { } function isEmpty(d) { - return d.data === undefined; + let n = d.data; + return n === undefined; } function minimum(d) { @@ -213,9 +215,7 @@ function forEachU(d, f) { } function forEach(d, f) { - forEachU(d, (function (a) { - f(a); - })); + Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); } function reduceU(d, acc, cb) { @@ -223,9 +223,7 @@ function reduceU(d, acc, cb) { } function reduce(d, acc, cb) { - return reduceU(d, acc, (function (a, b) { - return cb(a, b); - })); + return reduceU(d, acc, Curry.__2(cb)); } function everyU(d, p) { @@ -233,9 +231,7 @@ function everyU(d, p) { } function every(d, p) { - return everyU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); } function someU(d, p) { @@ -243,9 +239,7 @@ function someU(d, p) { } function some(d, p) { - return someU(d, (function (a) { - return p(a); - })); + return Belt_internalAVLset.someU(d.data, Curry.__1(p)); } function size(d) { @@ -334,9 +328,7 @@ function keepU(d, p) { } function keep(d, p) { - return keepU(d, (function (a) { - return p(a); - })); + return keepU(d, Curry.__1(p)); } function partitionU(d, p) { @@ -352,9 +344,7 @@ function partitionU(d, p) { } function partition(d, p) { - return partitionU(d, (function (a) { - return p(a); - })); + return partitionU(d, Curry.__1(p)); } function subset(a, b) { diff --git a/lib/js/belt_MutableStack.js b/lib/js/belt_MutableStack.js index aa95d97032..77438f19de 100644 --- a/lib/js/belt_MutableStack.js +++ b/lib/js/belt_MutableStack.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function make() { @@ -91,16 +92,14 @@ function forEachU(s, f) { if (s$1 === undefined) { return; } - f(s$1.head); + Curry._1(f, s$1.head); _s = s$1.tail; continue; }; } function forEach(s, f) { - forEachU(s, (function (x) { - f(x); - })); + forEachU(s, Curry.__1(f)); } function dynamicPopIterU(s, f) { @@ -110,15 +109,13 @@ function dynamicPopIterU(s, f) { return; } s.root = match.tail; - f(match.head); + Curry._1(f, match.head); continue; }; } function dynamicPopIter(s, f) { - dynamicPopIterU(s, (function (x) { - f(x); - })); + dynamicPopIterU(s, Curry.__1(f)); } exports.make = make; diff --git a/lib/js/belt_Option.js b/lib/js/belt_Option.js index 699dfdbf58..9b35ffba57 100644 --- a/lib/js/belt_Option.js +++ b/lib/js/belt_Option.js @@ -1,31 +1,28 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function keepU(opt, p) { - if (opt !== undefined && p(Caml_option.valFromOption(opt))) { + if (opt !== undefined && Curry._1(p, Caml_option.valFromOption(opt))) { return opt; } } function keep(opt, p) { - return keepU(opt, (function (x) { - return p(x); - })); + return keepU(opt, Curry.__1(p)); } function forEachU(opt, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return Curry._1(f, Caml_option.valFromOption(opt)); } } function forEach(opt, f) { - forEachU(opt, (function (x) { - f(x); - })); + forEachU(opt, Curry.__1(f)); } function getExn(x) { @@ -41,42 +38,36 @@ function getExn(x) { function mapWithDefaultU(opt, $$default, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return Curry._1(f, Caml_option.valFromOption(opt)); } else { return $$default; } } function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, (function (x) { - return f(x); - })); + return mapWithDefaultU(opt, $$default, Curry.__1(f)); } function mapU(opt, f) { if (opt !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(opt))); + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(opt))); } } function map(opt, f) { - return mapU(opt, (function (x) { - return f(x); - })); + return mapU(opt, Curry.__1(f)); } function flatMapU(opt, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return Curry._1(f, Caml_option.valFromOption(opt)); } } function flatMap(opt, f) { - return flatMapU(opt, (function (x) { - return f(x); - })); + return flatMapU(opt, Curry.__1(f)); } function getWithDefault(opt, $$default) { @@ -106,7 +97,7 @@ function isNone(x) { function eqU(a, b, f) { if (a !== undefined) { if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return Curry._2(f, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return false; } @@ -116,15 +107,13 @@ function eqU(a, b, f) { } function eq(a, b, f) { - return eqU(a, b, (function (x, y) { - return f(x, y); - })); + return eqU(a, b, Curry.__2(f)); } function cmpU(a, b, f) { if (a !== undefined) { if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return Curry._2(f, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return 1; } @@ -136,9 +125,7 @@ function cmpU(a, b, f) { } function cmp(a, b, f) { - return cmpU(a, b, (function (x, y) { - return f(x, y); - })); + return cmpU(a, b, Curry.__2(f)); } exports.keepU = keepU; diff --git a/lib/js/belt_Range.js b/lib/js/belt_Range.js index f5b60d1289..177cf3c146 100644 --- a/lib/js/belt_Range.js +++ b/lib/js/belt_Range.js @@ -1,16 +1,15 @@ 'use strict'; +let Curry = require("./curry.js"); function forEachU(s, f, action) { for(let i = s; i <= f; ++i){ - action(i); + Curry._1(action, i); } } function forEach(s, f, action) { - forEachU(s, f, (function (a) { - action(a); - })); + forEachU(s, f, Curry.__1(action)); } function everyU(_s, f, p) { @@ -19,7 +18,7 @@ function everyU(_s, f, p) { if (s > f) { return true; } - if (!p(s)) { + if (!Curry._1(p, s)) { return false; } _s = s + 1 | 0; @@ -28,9 +27,7 @@ function everyU(_s, f, p) { } function every(s, f, p) { - return everyU(s, f, (function (a) { - return p(a); - })); + return everyU(s, f, Curry.__1(p)); } function everyByU(s, f, step, p) { @@ -41,7 +38,7 @@ function everyByU(s, f, step, p) { if (s$1 > f) { return true; } - if (!p(s$1)) { + if (!Curry._1(p, s$1)) { return false; } _s = s$1 + step | 0; @@ -53,9 +50,7 @@ function everyByU(s, f, step, p) { } function everyBy(s, f, step, p) { - return everyByU(s, f, step, (function (a) { - return p(a); - })); + return everyByU(s, f, step, Curry.__1(p)); } function someU(_s, f, p) { @@ -64,7 +59,7 @@ function someU(_s, f, p) { if (s > f) { return false; } - if (p(s)) { + if (Curry._1(p, s)) { return true; } _s = s + 1 | 0; @@ -73,9 +68,7 @@ function someU(_s, f, p) { } function some(s, f, p) { - return someU(s, f, (function (a) { - return p(a); - })); + return someU(s, f, Curry.__1(p)); } function someByU(s, f, step, p) { @@ -86,7 +79,7 @@ function someByU(s, f, step, p) { if (s$1 > f) { return false; } - if (p(s$1)) { + if (Curry._1(p, s$1)) { return true; } _s = s$1 + step | 0; @@ -98,9 +91,7 @@ function someByU(s, f, step, p) { } function someBy(s, f, step, p) { - return someByU(s, f, step, (function (a) { - return p(a); - })); + return someByU(s, f, step, Curry.__1(p)); } exports.forEachU = forEachU; diff --git a/lib/js/belt_Result.js b/lib/js/belt_Result.js index 24ac6ac449..d3ba2043d7 100644 --- a/lib/js/belt_Result.js +++ b/lib/js/belt_Result.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); function getExn(x) { if (x.TAG === "Ok") { @@ -14,23 +15,21 @@ function getExn(x) { function mapWithDefaultU(opt, $$default, f) { if (opt.TAG === "Ok") { - return f(opt._0); + return Curry._1(f, opt._0); } else { return $$default; } } function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, (function (x) { - return f(x); - })); + return mapWithDefaultU(opt, $$default, Curry.__1(f)); } function mapU(opt, f) { if (opt.TAG === "Ok") { return { TAG: "Ok", - _0: f(opt._0) + _0: Curry._1(f, opt._0) }; } else { return { @@ -41,14 +40,12 @@ function mapU(opt, f) { } function map(opt, f) { - return mapU(opt, (function (x) { - return f(x); - })); + return mapU(opt, Curry.__1(f)); } function flatMapU(opt, f) { if (opt.TAG === "Ok") { - return f(opt._0); + return Curry._1(f, opt._0); } else { return { TAG: "Error", @@ -58,9 +55,7 @@ function flatMapU(opt, f) { } function flatMap(opt, f) { - return flatMapU(opt, (function (x) { - return f(x); - })); + return flatMapU(opt, Curry.__1(f)); } function getWithDefault(opt, $$default) { @@ -90,7 +85,7 @@ function isError(x) { function eqU(a, b, f) { if (a.TAG === "Ok") { if (b.TAG === "Ok") { - return f(a._0, b._0); + return Curry._2(f, a._0, b._0); } else { return false; } @@ -102,15 +97,13 @@ function eqU(a, b, f) { } function eq(a, b, f) { - return eqU(a, b, (function (x, y) { - return f(x, y); - })); + return eqU(a, b, Curry.__2(f)); } function cmpU(a, b, f) { if (a.TAG === "Ok") { if (b.TAG === "Ok") { - return f(a._0, b._0); + return Curry._2(f, a._0, b._0); } else { return 1; } @@ -122,9 +115,7 @@ function cmpU(a, b, f) { } function cmp(a, b, f) { - return cmpU(a, b, (function (x, y) { - return f(x, y); - })); + return cmpU(a, b, Curry.__2(f)); } exports.getExn = getExn; diff --git a/lib/js/belt_Set.js b/lib/js/belt_Set.js index f159790896..a48d9ad746 100644 --- a/lib/js/belt_Set.js +++ b/lib/js/belt_Set.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_SetDict = require("./belt_SetDict.js"); function fromArray(data, id) { @@ -127,9 +128,7 @@ function forEachU(m, f) { } function forEach(m, f) { - forEachU(m, (function (a) { - f(a); - })); + Belt_SetDict.forEachU(m.data, Curry.__1(f)); } function reduceU(m, acc, f) { @@ -137,9 +136,7 @@ function reduceU(m, acc, f) { } function reduce(m, acc, f) { - return reduceU(m, acc, (function (a, b) { - return f(a, b); - })); + return reduceU(m, acc, Curry.__2(f)); } function everyU(m, f) { @@ -147,9 +144,7 @@ function everyU(m, f) { } function every(m, f) { - return everyU(m, (function (a) { - return f(a); - })); + return Belt_SetDict.everyU(m.data, Curry.__1(f)); } function someU(m, f) { @@ -157,9 +152,7 @@ function someU(m, f) { } function some(m, f) { - return someU(m, (function (a) { - return f(a); - })); + return Belt_SetDict.someU(m.data, Curry.__1(f)); } function keepU(m, f) { @@ -170,9 +163,7 @@ function keepU(m, f) { } function keep(m, f) { - return keepU(m, (function (a) { - return f(a); - })); + return keepU(m, Curry.__1(f)); } function partitionU(m, f) { @@ -191,9 +182,7 @@ function partitionU(m, f) { } function partition(m, f) { - return partitionU(m, (function (a) { - return f(a); - })); + return partitionU(m, Curry.__1(f)); } function size(m) { diff --git a/lib/js/belt_SetDict.js b/lib/js/belt_SetDict.js index f9fcded08d..ac6aa23cde 100644 --- a/lib/js/belt_SetDict.js +++ b/lib/js/belt_SetDict.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_internalAVLset = require("./belt_internalAVLset.js"); function add(t, x, cmp) { @@ -7,7 +8,7 @@ function add(t, x, cmp) { return Belt_internalAVLset.singleton(x); } let k = t.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { return t; } @@ -36,7 +37,7 @@ function remove(t, x, cmp) { let v = t.v; let l = t.l; let r = t.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { if (l === undefined) { return r; @@ -90,7 +91,7 @@ function splitAuxNoPivot(cmp, n, x) { let v = n.v; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return [ l, @@ -127,7 +128,7 @@ function splitAuxPivot(cmp, n, x, pres) { let v = n.v; let l = n.l; let r = n.r; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { pres.contents = true; return [ diff --git a/lib/js/belt_SortArray.js b/lib/js/belt_SortArray.js index 2ae3650d58..fedb451b62 100644 --- a/lib/js/belt_SortArray.js +++ b/lib/js/belt_SortArray.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_Array = require("./belt_Array.js"); function sortedLengthAuxMore(xs, _prec, _acc, len, lt) { @@ -10,7 +11,7 @@ function sortedLengthAuxMore(xs, _prec, _acc, len, lt) { return acc; } let v = xs[acc]; - if (!lt(v, prec)) { + if (!Curry._2(lt, v, prec)) { return acc; } _acc = acc + 1 | 0; @@ -26,7 +27,7 @@ function strictlySortedLengthU(xs, lt) { } let x0 = xs[0]; let x1 = xs[1]; - if (lt(x0, x1)) { + if (Curry._2(lt, x0, x1)) { let _prec = x1; let _acc = 2; while(true) { @@ -36,14 +37,14 @@ function strictlySortedLengthU(xs, lt) { return acc; } let v = xs[acc]; - if (!lt(prec, v)) { + if (!Curry._2(lt, prec, v)) { return acc; } _acc = acc + 1 | 0; _prec = v; continue; }; - } else if (lt(x1, x0)) { + } else if (Curry._2(lt, x1, x0)) { return -sortedLengthAuxMore(xs, x1, 2, len, lt) | 0; } else { return 1; @@ -51,9 +52,7 @@ function strictlySortedLengthU(xs, lt) { } function strictlySortedLength(xs, lt) { - return strictlySortedLengthU(xs, (function (x, y) { - return lt(x, y); - })); + return strictlySortedLengthU(xs, Curry.__2(lt)); } function isSortedU(a, cmp) { @@ -68,7 +67,7 @@ function isSortedU(a, cmp) { if (i === last_bound) { return true; } - if (cmp(a[i], a[i + 1 | 0]) > 0) { + if (Curry._2(cmp, a[i], a[i + 1 | 0]) > 0) { return false; } _i = i + 1 | 0; @@ -78,9 +77,7 @@ function isSortedU(a, cmp) { } function isSorted(a, cmp) { - return isSortedU(a, (function (x, y) { - return cmp(x, y); - })); + return isSortedU(a, Curry.__2(cmp)); } function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { @@ -97,7 +94,7 @@ function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) let i2 = _i2; let s1 = _s1; let i1 = _i1; - if (cmp(s1, s2) <= 0) { + if (Curry._2(cmp, s1, s2) <= 0) { dst[d] = s1; let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -134,7 +131,7 @@ function unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) let i2 = _i2; let s1 = _s1; let i1 = _i1; - let c = cmp(s1, s2); + let c = Curry._2(cmp, s1, s2); if (c < 0) { dst[d] = s1; let i1$1 = i1 + 1 | 0; @@ -184,9 +181,7 @@ function unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) } function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (function (x, y) { - return cmp(x, y); - })); + return unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); } function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { @@ -203,7 +198,7 @@ function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, let i2 = _i2; let s1 = _s1; let i1 = _i1; - let c = cmp(s1, s2); + let c = Curry._2(cmp, s1, s2); if (c < 0) { let i1$1 = i1 + 1 | 0; if (i1$1 >= src1r) { @@ -239,9 +234,7 @@ function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, } function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (function (x, y) { - return cmp(x, y); - })); + return intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); } function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { @@ -258,7 +251,7 @@ function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) let i2 = _i2; let s1 = _s1; let i1 = _i1; - let c = cmp(s1, s2); + let c = Curry._2(cmp, s1, s2); if (c < 0) { dst[d] = s1; let d$1 = d + 1 | 0; @@ -300,16 +293,14 @@ function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) } function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (function (x, y) { - return cmp(x, y); - })); + return diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); } function insertionSort(src, srcofs, dst, dstofs, len, cmp) { for(let i = 0; i < len; ++i){ let e = src[srcofs + i | 0]; let j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(dst[j], e) > 0) { + while(j >= dstofs && Curry._2(cmp, dst[j], e) > 0) { dst[j + 1 | 0] = dst[j]; j = j - 1 | 0; }; @@ -342,9 +333,7 @@ function stableSortInPlaceByU(a, cmp) { } function stableSortInPlaceBy(a, cmp) { - stableSortInPlaceByU(a, (function (x, y) { - return cmp(x, y); - })); + stableSortInPlaceByU(a, Curry.__2(cmp)); } function stableSortByU(a, cmp) { @@ -354,9 +343,7 @@ function stableSortByU(a, cmp) { } function stableSortBy(a, cmp) { - return stableSortByU(a, (function (x, y) { - return cmp(x, y); - })); + return stableSortByU(a, Curry.__2(cmp)); } function binarySearchByU(sorted, key, cmp) { @@ -365,12 +352,12 @@ function binarySearchByU(sorted, key, cmp) { return -1; } let lo = sorted[0]; - let c = cmp(key, lo); + let c = Curry._2(cmp, key, lo); if (c < 0) { return -1; } let hi = sorted[len - 1 | 0]; - let c2 = cmp(key, hi); + let c2 = Curry._2(cmp, key, hi); if (c2 > 0) { return -(len + 1 | 0) | 0; } else { @@ -381,13 +368,13 @@ function binarySearchByU(sorted, key, cmp) { let lo$1 = _lo; let mid = (lo$1 + hi$1 | 0) / 2 | 0; let midVal = sorted[mid]; - let c$1 = cmp(key, midVal); + let c$1 = Curry._2(cmp, key, midVal); if (c$1 === 0) { return mid; } if (c$1 < 0) { if (hi$1 === mid) { - if (cmp(sorted[lo$1], key) === 0) { + if (Curry._2(cmp, sorted[lo$1], key) === 0) { return lo$1; } else { return -(hi$1 + 1 | 0) | 0; @@ -397,7 +384,7 @@ function binarySearchByU(sorted, key, cmp) { continue; } if (lo$1 === mid) { - if (cmp(sorted[hi$1], key) === 0) { + if (Curry._2(cmp, sorted[hi$1], key) === 0) { return hi$1; } else { return -(hi$1 + 1 | 0) | 0; @@ -410,9 +397,7 @@ function binarySearchByU(sorted, key, cmp) { } function binarySearchBy(sorted, key, cmp) { - return binarySearchByU(sorted, key, (function (x, y) { - return cmp(x, y); - })); + return binarySearchByU(sorted, key, Curry.__2(cmp)); } let Int; diff --git a/lib/js/belt_internalAVLset.js b/lib/js/belt_internalAVLset.js index aa3c4de016..d9f2856adf 100644 --- a/lib/js/belt_internalAVLset.js +++ b/lib/js/belt_internalAVLset.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_SortArray = require("./belt_SortArray.js"); @@ -170,16 +171,14 @@ function forEachU(_n, f) { return; } forEachU(n.l, f); - f(n.v); + Curry._1(f, n.v); _n = n.r; continue; }; } function forEach(n, f) { - forEachU(n, (function (a) { - f(a); - })); + forEachU(n, Curry.__1(f)); } function reduceU(_s, _accu, f) { @@ -189,16 +188,14 @@ function reduceU(_s, _accu, f) { if (s === undefined) { return accu; } - _accu = f(reduceU(s.l, accu, f), s.v); + _accu = Curry._2(f, reduceU(s.l, accu, f), s.v); _s = s.r; continue; }; } function reduce(s, accu, f) { - return reduceU(s, accu, (function (a, b) { - return f(a, b); - })); + return reduceU(s, accu, Curry.__2(f)); } function everyU(_n, p) { @@ -207,7 +204,7 @@ function everyU(_n, p) { if (n === undefined) { return true; } - if (!p(n.v)) { + if (!Curry._1(p, n.v)) { return false; } if (!everyU(n.l, p)) { @@ -219,9 +216,7 @@ function everyU(_n, p) { } function every(n, p) { - return everyU(n, (function (a) { - return p(a); - })); + return everyU(n, Curry.__1(p)); } function someU(_n, p) { @@ -230,7 +225,7 @@ function someU(_n, p) { if (n === undefined) { return false; } - if (p(n.v)) { + if (Curry._1(p, n.v)) { return true; } if (someU(n.l, p)) { @@ -242,9 +237,7 @@ function someU(_n, p) { } function some(n, p) { - return someU(n, (function (a) { - return p(a); - })); + return someU(n, Curry.__1(p)); } function addMinElement(n, v) { @@ -306,7 +299,7 @@ function partitionSharedU(n, p) { let match = partitionSharedU(n.l, p); let lf = match[1]; let lt = match[0]; - let pv = p(value); + let pv = Curry._1(p, value); let match$1 = partitionSharedU(n.r, p); let rf = match$1[1]; let rt = match$1[0]; @@ -324,9 +317,7 @@ function partitionSharedU(n, p) { } function partitionShared(n, p) { - return partitionSharedU(n, (function (a) { - return p(a); - })); + return partitionSharedU(n, Curry.__1(p)); } function lengthNode(n) { @@ -424,7 +415,7 @@ function fillArrayWithPartition(_n, cursor, arr, p) { if (l !== undefined) { fillArrayWithPartition(l, cursor, arr, p); } - if (p(v)) { + if (Curry._1(p, v)) { let c = cursor.forward; arr[c] = v; cursor.forward = c + 1 | 0; @@ -449,7 +440,7 @@ function fillArrayWithFilter(_n, _i, arr, p) { let l = n.l; let r = n.r; let next = l !== undefined ? fillArrayWithFilter(l, i, arr, p) : i; - let rnext = p(v) ? (arr[next] = v, next + 1 | 0) : next; + let rnext = Curry._1(p, v) ? (arr[next] = v, next + 1 | 0) : next; if (r === undefined) { return rnext; } @@ -549,7 +540,7 @@ function keepSharedU(n, p) { let l = n.l; let r = n.r; let newL = keepSharedU(l, p); - let pv = p(v); + let pv = Curry._1(p, v); let newR = keepSharedU(r, p); if (pv) { if (l === newL && r === newR) { @@ -563,9 +554,7 @@ function keepSharedU(n, p) { } function keepShared(n, p) { - return keepSharedU(n, (function (a) { - return p(a); - })); + return keepSharedU(n, Curry.__1(p)); } function keepCopyU(n, p) { @@ -579,9 +568,7 @@ function keepCopyU(n, p) { } function keepCopy(n, p) { - return keepCopyU(n, (function (x) { - return p(x); - })); + return keepCopyU(n, Curry.__1(p)); } function partitionCopyU(n, p) { @@ -607,9 +594,7 @@ function partitionCopyU(n, p) { } function partitionCopy(n, p) { - return partitionCopyU(n, (function (a) { - return p(a); - })); + return partitionCopyU(n, Curry.__1(p)); } function has(_t, x, cmp) { @@ -619,7 +604,7 @@ function has(_t, x, cmp) { return false; } let v = t.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return true; } @@ -645,7 +630,7 @@ function cmp(s1, s2, cmp$1) { } let h2 = e2.hd; let h1 = e1.hd; - let c = cmp$1(h1.v, h2.v); + let c = Curry._2(cmp$1, h1.v, h2.v); if (c !== 0) { return c; } @@ -680,7 +665,7 @@ function subset(_s1, _s2, cmp) { let v2 = s2.v; let l2 = s2.l; let r2 = s2.r; - let c = cmp(v1, v2); + let c = Curry._2(cmp, v1, v2); if (c === 0) { if (!subset(l1, l2, cmp)) { return false; @@ -711,7 +696,7 @@ function get(_n, x, cmp) { return; } let v = n.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return Caml_option.some(v); } @@ -727,7 +712,7 @@ function getUndefined(_n, x, cmp) { return; } let v = n.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return v; } @@ -741,7 +726,7 @@ function getExn(_n, x, cmp) { let n = _n; if (n !== undefined) { let v = n.v; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return v; } @@ -855,7 +840,7 @@ function addMutate(cmp, t, x) { return singleton(x); } let k = t.v; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { return t; } @@ -876,7 +861,7 @@ function fromArray(xs, cmp) { return; } let next = Belt_SortArray.strictlySortedLengthU(xs, (function (x, y) { - return cmp(x, y) < 0; + return Curry._2(cmp, x, y) < 0; })); let result; if (next >= 0) { diff --git a/lib/js/belt_internalAVLtree.js b/lib/js/belt_internalAVLtree.js index 70f0d5cc11..c06d5f31a5 100644 --- a/lib/js/belt_internalAVLtree.js +++ b/lib/js/belt_internalAVLtree.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_SortArray = require("./belt_SortArray.js"); @@ -254,7 +255,7 @@ function findFirstByU(n, p) { } let v = n.k; let d = n.v; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); if (pvd) { return [ v, @@ -269,9 +270,7 @@ function findFirstByU(n, p) { } function findFirstBy(n, p) { - return findFirstByU(n, (function (a, b) { - return p(a, b); - })); + return findFirstByU(n, Curry.__2(p)); } function forEachU(_n, f) { @@ -281,16 +280,14 @@ function forEachU(_n, f) { return; } forEachU(n.l, f); - f(n.k, n.v); + Curry._2(f, n.k, n.v); _n = n.r; continue; }; } function forEach(n, f) { - forEachU(n, (function (a, b) { - f(a, b); - })); + forEachU(n, Curry.__2(f)); } function mapU(n, f) { @@ -298,7 +295,7 @@ function mapU(n, f) { return; } let newLeft = mapU(n.l, f); - let newD = f(n.v); + let newD = Curry._1(f, n.v); let newRight = mapU(n.r, f); return { k: n.k, @@ -310,9 +307,7 @@ function mapU(n, f) { } function map(n, f) { - return mapU(n, (function (a) { - return f(a); - })); + return mapU(n, Curry.__1(f)); } function mapWithKeyU(n, f) { @@ -321,7 +316,7 @@ function mapWithKeyU(n, f) { } let key = n.k; let newLeft = mapWithKeyU(n.l, f); - let newD = f(key, n.v); + let newD = Curry._2(f, key, n.v); let newRight = mapWithKeyU(n.r, f); return { k: key, @@ -333,9 +328,7 @@ function mapWithKeyU(n, f) { } function mapWithKey(n, f) { - return mapWithKeyU(n, (function (a, b) { - return f(a, b); - })); + return mapWithKeyU(n, Curry.__2(f)); } function reduceU(_m, _accu, f) { @@ -349,16 +342,14 @@ function reduceU(_m, _accu, f) { let d = m.v; let l = m.l; let r = m.r; - _accu = f(reduceU(l, accu, f), v, d); + _accu = Curry._3(f, reduceU(l, accu, f), v, d); _m = r; continue; }; } function reduce(m, accu, f) { - return reduceU(m, accu, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(m, accu, Curry.__3(f)); } function everyU(_n, p) { @@ -367,7 +358,7 @@ function everyU(_n, p) { if (n === undefined) { return true; } - if (!p(n.k, n.v)) { + if (!Curry._2(p, n.k, n.v)) { return false; } if (!everyU(n.l, p)) { @@ -379,9 +370,7 @@ function everyU(_n, p) { } function every(n, p) { - return everyU(n, (function (a, b) { - return p(a, b); - })); + return everyU(n, Curry.__2(p)); } function someU(_n, p) { @@ -390,7 +379,7 @@ function someU(_n, p) { if (n === undefined) { return false; } - if (p(n.k, n.v)) { + if (Curry._2(p, n.k, n.v)) { return true; } if (someU(n.l, p)) { @@ -402,9 +391,7 @@ function someU(_n, p) { } function some(n, p) { - return someU(n, (function (a, b) { - return p(a, b); - })); + return someU(n, Curry.__2(p)); } function addMinElement(n, k, v) { @@ -481,7 +468,7 @@ function keepSharedU(n, p) { let v = n.k; let d = n.v; let newLeft = keepSharedU(n.l, p); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let newRight = keepSharedU(n.r, p); if (pvd) { return join(newLeft, v, d, newRight); @@ -491,9 +478,7 @@ function keepSharedU(n, p) { } function keepShared(n, p) { - return keepSharedU(n, (function (a, b) { - return p(a, b); - })); + return keepSharedU(n, Curry.__2(p)); } function keepMapU(n, p) { @@ -503,7 +488,7 @@ function keepMapU(n, p) { let v = n.k; let d = n.v; let newLeft = keepMapU(n.l, p); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let newRight = keepMapU(n.r, p); if (pvd !== undefined) { return join(newLeft, v, Caml_option.valFromOption(pvd), newRight); @@ -513,9 +498,7 @@ function keepMapU(n, p) { } function keepMap(n, p) { - return keepMapU(n, (function (a, b) { - return p(a, b); - })); + return keepMapU(n, Curry.__2(p)); } function partitionSharedU(n, p) { @@ -530,7 +513,7 @@ function partitionSharedU(n, p) { let match = partitionSharedU(n.l, p); let lf = match[1]; let lt = match[0]; - let pvd = p(key, value); + let pvd = Curry._2(p, key, value); let match$1 = partitionSharedU(n.r, p); let rf = match$1[1]; let rt = match$1[0]; @@ -548,9 +531,7 @@ function partitionSharedU(n, p) { } function partitionShared(n, p) { - return partitionSharedU(n, (function (a, b) { - return p(a, b); - })); + return partitionSharedU(n, Curry.__2(p)); } function lengthNode(n) { @@ -817,11 +798,11 @@ function cmpU(s1, s2, kcmp, vcmp) { } let h2 = e2.hd; let h1 = e1.hd; - let c = kcmp(h1.k, h2.k); + let c = Curry._2(kcmp, h1.k, h2.k); if (c !== 0) { return c; } - let cx = vcmp(h1.v, h2.v); + let cx = Curry._2(vcmp, h1.v, h2.v); if (cx !== 0) { return cx; } @@ -837,9 +818,7 @@ function cmpU(s1, s2, kcmp, vcmp) { } function cmp(s1, s2, kcmp, vcmp) { - return cmpU(s1, s2, kcmp, (function (a, b) { - return vcmp(a, b); - })); + return cmpU(s1, s2, kcmp, Curry.__2(vcmp)); } function eqU(s1, s2, kcmp, veq) { @@ -859,7 +838,7 @@ function eqU(s1, s2, kcmp, veq) { } let h2 = e2.hd; let h1 = e1.hd; - if (!(kcmp(h1.k, h2.k) === 0 && veq(h1.v, h2.v))) { + if (!(Curry._2(kcmp, h1.k, h2.k) === 0 && Curry._2(veq, h1.v, h2.v))) { return false; } _e2 = stackAllLeft(h2.r, e2.tl); @@ -872,9 +851,7 @@ function eqU(s1, s2, kcmp, veq) { } function eq(s1, s2, kcmp, veq) { - return eqU(s1, s2, kcmp, (function (a, b) { - return veq(a, b); - })); + return eqU(s1, s2, kcmp, Curry.__2(veq)); } function get(_n, x, cmp) { @@ -884,7 +861,7 @@ function get(_n, x, cmp) { return; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return Caml_option.some(n.v); } @@ -900,7 +877,7 @@ function getUndefined(_n, x, cmp) { return; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return n.v; } @@ -914,7 +891,7 @@ function getExn(_n, x, cmp) { let n = _n; if (n !== undefined) { let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return n.v; } @@ -936,7 +913,7 @@ function getWithDefault(_n, x, def, cmp) { return def; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return n.v; } @@ -952,7 +929,7 @@ function has(_n, x, cmp) { return false; } let v = n.k; - let c = cmp(x, v); + let c = Curry._2(cmp, x, v); if (c === 0) { return true; } @@ -1052,7 +1029,7 @@ function updateMutate(t, x, data, cmp) { return singleton(x, data); } let k = t.k; - let c = cmp(x, k); + let c = Curry._2(cmp, x, k); if (c === 0) { t.v = data; return t; @@ -1074,7 +1051,7 @@ function fromArray(xs, cmp) { return; } let next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return cmp(param[0], param$1[0]) < 0; + return Curry._2(cmp, param[0], param$1[0]) < 0; })); let result; if (next >= 0) { diff --git a/lib/js/belt_internalBuckets.js b/lib/js/belt_internalBuckets.js index 21423c0177..cdb9d8e87a 100644 --- a/lib/js/belt_internalBuckets.js +++ b/lib/js/belt_internalBuckets.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_Array = require("./belt_Array.js"); let Caml_option = require("./caml_option.js"); @@ -72,7 +73,7 @@ function do_bucket_iter(f, _buckets) { if (buckets === undefined) { return; } - f(buckets.key, buckets.value); + Curry._2(f, buckets.key, buckets.value); _buckets = buckets.next; continue; }; @@ -86,9 +87,7 @@ function forEachU(h, f) { } function forEach(h, f) { - forEachU(h, (function (a, b) { - return f(a, b); - })); + forEachU(h, Curry.__2(f)); } function do_bucket_fold(f, _b, _accu) { @@ -98,7 +97,7 @@ function do_bucket_fold(f, _b, _accu) { if (b === undefined) { return accu; } - _accu = f(accu, b.key, b.value); + _accu = Curry._3(f, accu, b.key, b.value); _b = b.next; continue; }; @@ -114,9 +113,7 @@ function reduceU(h, init, f) { } function reduce(h, init, f) { - return reduceU(h, init, (function (a, b, c) { - return f(a, b, c); - })); + return reduceU(h, init, Curry.__3(f)); } function getMaxBucketLength(h) { @@ -156,7 +153,7 @@ function filterMapInplaceBucket(f, h, i, _prec, _cell) { let cell = _cell; let prec = _prec; let n = cell.next; - let data = f(cell.key, cell.value); + let data = Curry._2(f, cell.key, cell.value); if (data !== undefined) { if (prec !== undefined) { cell.next = cell; @@ -198,9 +195,7 @@ function keepMapInPlaceU(h, f) { } function keepMapInPlace(h, f) { - keepMapInPlaceU(h, (function (a, b) { - return f(a, b); - })); + keepMapInPlaceU(h, Curry.__2(f)); } function fillArray(_i, arr, _cell) { @@ -225,7 +220,7 @@ function fillArrayMap(_i, arr, _cell, f) { while(true) { let cell = _cell; let i = _i; - arr[i] = f(cell); + arr[i] = Curry._1(f, cell); let v = cell.next; if (v === undefined) { return i + 1 | 0; diff --git a/lib/js/belt_internalMapInt.js b/lib/js/belt_internalMapInt.js index 4130367f1b..f16606b2f4 100644 --- a/lib/js/belt_internalMapInt.js +++ b/lib/js/belt_internalMapInt.js @@ -1,6 +1,7 @@ 'use strict'; let Caml = require("./caml.js"); +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_SortArray = require("./belt_SortArray.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); @@ -194,7 +195,7 @@ function mergeU(s1, s2, f) { let l1 = s1.l; let r1 = s1.r; let match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, Curry._3(f, v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); } } else if (s2 === undefined) { @@ -205,13 +206,11 @@ function mergeU(s1, s2, f) { let l2 = s2.l; let r2 = s2.r; let match$1 = split(v2, s1); - return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, Curry._3(f, v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); } function merge(s1, s2, f) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - })); + return mergeU(s1, s2, Curry.__3(f)); } function compareAux(_e1, _e2, vcmp) { @@ -230,7 +229,7 @@ function compareAux(_e1, _e2, vcmp) { if (c !== 0) { return c; } - let cx = vcmp(h1.v, h2.v); + let cx = Curry._2(vcmp, h1.v, h2.v); if (cx !== 0) { return cx; } @@ -253,9 +252,7 @@ function cmpU(s1, s2, cmp) { } function cmp(s1, s2, f) { - return cmpU(s1, s2, (function (a, b) { - return f(a, b); - })); + return cmpU(s1, s2, Curry.__2(f)); } function eqAux(_e1, _e2, eq) { @@ -270,7 +267,7 @@ function eqAux(_e1, _e2, eq) { } let h2 = e2.hd; let h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { + if (!(h1.k === h2.k && Curry._2(eq, h1.v, h2.v))) { return false; } _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); @@ -290,9 +287,7 @@ function eqU(s1, s2, eq) { } function eq(s1, s2, f) { - return eqU(s1, s2, (function (a, b) { - return f(a, b); - })); + return eqU(s1, s2, Curry.__2(f)); } function addMutate(t, x, data) { diff --git a/lib/js/belt_internalMapString.js b/lib/js/belt_internalMapString.js index 0397f66799..e385576174 100644 --- a/lib/js/belt_internalMapString.js +++ b/lib/js/belt_internalMapString.js @@ -1,6 +1,7 @@ 'use strict'; let Caml = require("./caml.js"); +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let Belt_SortArray = require("./belt_SortArray.js"); let Belt_internalAVLtree = require("./belt_internalAVLtree.js"); @@ -194,7 +195,7 @@ function mergeU(s1, s2, f) { let l1 = s1.l; let r1 = s1.r; let match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, Curry._3(f, v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); } } else if (s2 === undefined) { @@ -205,13 +206,11 @@ function mergeU(s1, s2, f) { let l2 = s2.l; let r2 = s2.r; let match$1 = split(v2, s1); - return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); + return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, Curry._3(f, v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); } function merge(s1, s2, f) { - return mergeU(s1, s2, (function (a, b, c) { - return f(a, b, c); - })); + return mergeU(s1, s2, Curry.__3(f)); } function compareAux(_e1, _e2, vcmp) { @@ -230,7 +229,7 @@ function compareAux(_e1, _e2, vcmp) { if (c !== 0) { return c; } - let cx = vcmp(h1.v, h2.v); + let cx = Curry._2(vcmp, h1.v, h2.v); if (cx !== 0) { return cx; } @@ -253,9 +252,7 @@ function cmpU(s1, s2, cmp) { } function cmp(s1, s2, f) { - return cmpU(s1, s2, (function (a, b) { - return f(a, b); - })); + return cmpU(s1, s2, Curry.__2(f)); } function eqAux(_e1, _e2, eq) { @@ -270,7 +267,7 @@ function eqAux(_e1, _e2, eq) { } let h2 = e2.hd; let h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { + if (!(h1.k === h2.k && Curry._2(eq, h1.v, h2.v))) { return false; } _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); @@ -290,9 +287,7 @@ function eqU(s1, s2, eq) { } function eq(s1, s2, f) { - return eqU(s1, s2, (function (a, b) { - return f(a, b); - })); + return eqU(s1, s2, Curry.__2(f)); } function addMutate(t, x, data) { diff --git a/lib/js/belt_internalSetBuckets.js b/lib/js/belt_internalSetBuckets.js index 95789558f2..e0a390a6e1 100644 --- a/lib/js/belt_internalSetBuckets.js +++ b/lib/js/belt_internalSetBuckets.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Belt_Array = require("./belt_Array.js"); function copyAuxCont(_c, _prec) { @@ -69,7 +70,7 @@ function doBucketIter(f, _buckets) { if (buckets === undefined) { return; } - f(buckets.key); + Curry._1(f, buckets.key); _buckets = buckets.next; continue; }; @@ -83,9 +84,7 @@ function forEachU(h, f) { } function forEach(h, f) { - forEachU(h, (function (a) { - f(a); - })); + forEachU(h, Curry.__1(f)); } function fillArray(_i, arr, _cell) { @@ -124,7 +123,7 @@ function doBucketFold(f, _b, _accu) { if (b === undefined) { return accu; } - _accu = f(accu, b.key); + _accu = Curry._2(f, accu, b.key); _b = b.next; continue; }; @@ -140,9 +139,7 @@ function reduceU(h, init, f) { } function reduce(h, init, f) { - return reduceU(h, init, (function (a, b) { - return f(a, b); - })); + return reduceU(h, init, Curry.__2(f)); } function getMaxBucketLength(h) { diff --git a/lib/js/buffer.js b/lib/js/buffer.js index 160c5a977f..c1142a0832 100644 --- a/lib/js/buffer.js +++ b/lib/js/buffer.js @@ -1,6 +1,7 @@ 'use strict'; let Bytes = require("./bytes.js"); +let Curry = require("./curry.js"); let $$String = require("./string.js"); let Caml_bytes = require("./caml_bytes.js"); let Caml_string = require("./caml_string.js"); @@ -25,39 +26,39 @@ function to_bytes(b) { } function sub(b, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (b.position - len | 0))) { - return Bytes.sub_string(b.buffer, ofs, len); + if (ofs < 0 || len < 0 || ofs > (b.position - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.sub" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.sub" - } - }); + return Bytes.sub_string(b.buffer, ofs, len); } function blit(src, srcoff, dst, dstoff, len) { - if (!(len < 0 || srcoff < 0 || srcoff > (src.position - len | 0) || dstoff < 0 || dstoff > (dst.length - len | 0))) { - return Bytes.blit(src.buffer, srcoff, dst, dstoff, len); + if (len < 0 || srcoff < 0 || srcoff > (src.position - len | 0) || dstoff < 0 || dstoff > (dst.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.blit" - } - }); + Bytes.blit(src.buffer, srcoff, dst, dstoff, len); } function nth(b, ofs) { - if (!(ofs < 0 || ofs >= b.position)) { - return b.buffer[ofs]; + if (ofs < 0 || ofs >= b.position) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.nth" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.nth" - } - }); + return b.buffer[ofs]; } function length(b) { @@ -446,7 +447,7 @@ function add_substitute(b, f, s) { } let j = i + 1 | 0; let match = find_ident(s, j, lim); - add_string(b, f(match[0])); + add_string(b, Curry._1(f, match[0])); _i = match[1]; _previous = /* ' ' */32; continue; @@ -454,16 +455,15 @@ function add_substitute(b, f, s) { } function truncate(b, len) { - if (!(len < 0 || len > b.position)) { - b.position = len; - return; + if (len < 0 || len > b.position) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.truncate" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Buffer.truncate" - } - }); + b.position = len; } exports.create = create; diff --git a/lib/js/bytes.js b/lib/js/bytes.js index c8dd7b3cac..0a846043cd 100644 --- a/lib/js/bytes.js +++ b/lib/js/bytes.js @@ -2,6 +2,7 @@ let Caml = require("./caml.js"); let Char = require("./char.js"); +let Curry = require("./curry.js"); let Caml_bytes = require("./caml_bytes.js"); let Caml_js_exceptions = require("./caml_js_exceptions.js"); @@ -63,7 +64,7 @@ function make(n, c) { function init(n, f) { let s = Caml_bytes.create(n); for(let i = 0; i < n; ++i){ - s[i] = f(i); + s[i] = Curry._1(f, i); } return s; } @@ -148,15 +149,15 @@ function $plus$plus(a, b) { if (match$1) { return c; } - if (!match$2) { - return c; + if (match$2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.extend" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.extend" - } - }); + return c; } function extend(s, left, right) { @@ -179,66 +180,65 @@ function extend(s, left, right) { } function fill(s, ofs, len, c) { - if (!(ofs < 0 || len < 0 || ofs > (s.length - len | 0))) { - return unsafe_fill(s, ofs, len, c); + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.fill / Bytes.fill" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.fill / Bytes.fill" - } - }); + unsafe_fill(s, ofs, len, c); } function blit(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - return unsafe_blit(s1, ofs1, s2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.blit" - } - }); + unsafe_blit(s1, ofs1, s2, ofs2, len); } function blit_string(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - if (len <= 0) { - return; - } - let off1 = s1.length - ofs1 | 0; - if (len <= off1) { - for(let i = 0; i < len; ++i){ - s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); - } - return; - } - for(let i$1 = 0; i$1 < off1; ++i$1){ - s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); - } - for(let i$2 = off1; i$2 < len; ++i$2){ - s2[ofs2 + i$2 | 0] = /* '\000' */0; + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.blit / Bytes.blit_string" + } + }); + } + if (len <= 0) { + return; + } + let off1 = s1.length - ofs1 | 0; + if (len <= off1) { + for(let i = 0; i < len; ++i){ + s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); } return; } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.blit / Bytes.blit_string" - } - }); + for(let i$1 = 0; i$1 < off1; ++i$1){ + s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); + } + for(let i$2 = off1; i$2 < len; ++i$2){ + s2[ofs2 + i$2 | 0] = /* '\000' */0; + } } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -446,7 +446,7 @@ function map(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(s[i]); + r[i] = Curry._1(f, s[i]); } return r; } @@ -458,7 +458,7 @@ function mapi(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(i, s[i]); + r[i] = Curry._2(f, i, s[i]); } return r; } @@ -476,7 +476,7 @@ function apply1(f, s) { return s; } let r = copy(s); - r[0] = f(s[0]); + r[0] = Curry._1(f, s[0]); return r; } @@ -530,28 +530,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -577,15 +577,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -607,15 +607,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/js/bytesLabels.js b/lib/js/bytesLabels.js index c8dd7b3cac..0a846043cd 100644 --- a/lib/js/bytesLabels.js +++ b/lib/js/bytesLabels.js @@ -2,6 +2,7 @@ let Caml = require("./caml.js"); let Char = require("./char.js"); +let Curry = require("./curry.js"); let Caml_bytes = require("./caml_bytes.js"); let Caml_js_exceptions = require("./caml_js_exceptions.js"); @@ -63,7 +64,7 @@ function make(n, c) { function init(n, f) { let s = Caml_bytes.create(n); for(let i = 0; i < n; ++i){ - s[i] = f(i); + s[i] = Curry._1(f, i); } return s; } @@ -148,15 +149,15 @@ function $plus$plus(a, b) { if (match$1) { return c; } - if (!match$2) { - return c; + if (match$2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.extend" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.extend" - } - }); + return c; } function extend(s, left, right) { @@ -179,66 +180,65 @@ function extend(s, left, right) { } function fill(s, ofs, len, c) { - if (!(ofs < 0 || len < 0 || ofs > (s.length - len | 0))) { - return unsafe_fill(s, ofs, len, c); + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.fill / Bytes.fill" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.fill / Bytes.fill" - } - }); + unsafe_fill(s, ofs, len, c); } function blit(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - return unsafe_blit(s1, ofs1, s2, ofs2, len); + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.blit" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Bytes.blit" - } - }); + unsafe_blit(s1, ofs1, s2, ofs2, len); } function blit_string(s1, ofs1, s2, ofs2, len) { - if (!(len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0))) { - if (len <= 0) { - return; - } - let off1 = s1.length - ofs1 | 0; - if (len <= off1) { - for(let i = 0; i < len; ++i){ - s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); - } - return; - } - for(let i$1 = 0; i$1 < off1; ++i$1){ - s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); - } - for(let i$2 = off1; i$2 < len; ++i$2){ - s2[ofs2 + i$2 | 0] = /* '\000' */0; + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.blit / Bytes.blit_string" + } + }); + } + if (len <= 0) { + return; + } + let off1 = s1.length - ofs1 | 0; + if (len <= off1) { + for(let i = 0; i < len; ++i){ + s2[ofs2 + i | 0] = s1.codePointAt(ofs1 + i | 0); } return; } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.blit / Bytes.blit_string" - } - }); + for(let i$1 = 0; i$1 < off1; ++i$1){ + s2[ofs2 + i$1 | 0] = s1.codePointAt(ofs1 + i$1 | 0); + } + for(let i$2 = off1; i$2 < len; ++i$2){ + s2[ofs2 + i$2 | 0] = /* '\000' */0; + } } function iter(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); + Curry._1(f, a[i]); } } function iteri(f, a) { for(let i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); + Curry._2(f, i, a[i]); } } @@ -446,7 +446,7 @@ function map(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(s[i]); + r[i] = Curry._1(f, s[i]); } return r; } @@ -458,7 +458,7 @@ function mapi(f, s) { } let r = Caml_bytes.create(l); for(let i = 0; i < l; ++i){ - r[i] = f(i, s[i]); + r[i] = Curry._2(f, i, s[i]); } return r; } @@ -476,7 +476,7 @@ function apply1(f, s) { return s; } let r = copy(s); - r[0] = f(s[0]); + r[0] = Curry._1(f, s[0]); return r; } @@ -530,28 +530,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -577,15 +577,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -607,15 +607,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/js/caml.js b/lib/js/caml.js index 15e8b80485..c3729dc091 100644 --- a/lib/js/caml.js +++ b/lib/js/caml.js @@ -166,10 +166,10 @@ function i64_le(x, y) { } function i64_min(x, y) { - if (i64_lt(x, y)) { - return x; - } else { + if (i64_ge(x, y)) { return y; + } else { + return x; } } diff --git a/lib/js/camlinternalLazy.js b/lib/js/camlinternalLazy.js index 4125262ab5..a97091fe5d 100644 --- a/lib/js/camlinternalLazy.js +++ b/lib/js/camlinternalLazy.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_exceptions = require("./caml_exceptions.js"); function is_val(l) { @@ -9,7 +10,7 @@ function is_val(l) { let Undefined = /* @__PURE__ */Caml_exceptions.create("CamlinternalLazy.Undefined"); function forward_with_closure(blk, closure) { - let result = closure(); + let result = Curry._1(closure, undefined); blk.VAL = result; blk.LAZY_DONE = true; return result; diff --git a/lib/js/char.js b/lib/js/char.js index d4dd8308c7..2ae5bbaca9 100644 --- a/lib/js/char.js +++ b/lib/js/char.js @@ -3,15 +3,15 @@ let Bytes = require("./bytes.js"); function chr(n) { - if (!(n < 0 || n > 255)) { - return n; + if (n < 0 || n > 255) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Char.chr" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Char.chr" - } - }); + return n; } function escaped(param) { diff --git a/lib/js/digest.js b/lib/js/digest.js index d62b9b57a8..51307ddf23 100644 --- a/lib/js/digest.js +++ b/lib/js/digest.js @@ -16,15 +16,15 @@ function bytes(b) { } function substring(str, ofs, len) { - if (!(ofs < 0 || len < 0 || ofs > (str.length - len | 0))) { - return Caml_md5.md5_string(str, ofs, len); + if (ofs < 0 || len < 0 || ofs > (str.length - len | 0)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Digest.substring" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Digest.substring" - } - }); + return Caml_md5.md5_string(str, ofs, len); } function subbytes(b, ofs, len) { diff --git a/lib/js/filename.js b/lib/js/filename.js index 8b1245ba55..df025ea5f8 100644 --- a/lib/js/filename.js +++ b/lib/js/filename.js @@ -1,6 +1,8 @@ 'use strict'; let Sys = require("./sys.js"); +let Bytes = require("./bytes.js"); +let Curry = require("./curry.js"); let Buffer = require("./buffer.js"); let $$String = require("./string.js"); let Caml_sys = require("./caml_sys.js"); @@ -17,7 +19,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - if (!is_dir_sep(name, n)) { + if (!Curry._2(is_dir_sep, name, n)) { let _n$1 = n; let p = n + 1 | 0; while(true) { @@ -25,7 +27,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { if (n$1 < 0) { return $$String.sub(name, 0, p); } - if (is_dir_sep(name, n$1)) { + if (Curry._2(is_dir_sep, name, n$1)) { return $$String.sub(name, n$1 + 1 | 0, (p - n$1 | 0) - 1 | 0); } _n$1 = n$1 - 1 | 0; @@ -48,21 +50,21 @@ function generic_dirname(is_dir_sep, current_dir_name, name) { if (n < 0) { return $$String.sub(name, 0, 1); } - if (!is_dir_sep(name, n)) { + if (!Curry._2(is_dir_sep, name, n)) { let _n$1 = n; while(true) { let n$1 = _n$1; if (n$1 < 0) { return current_dir_name; } - if (is_dir_sep(name, n$1)) { + if (Curry._2(is_dir_sep, name, n$1)) { let _n$2 = n$1; while(true) { let n$2 = _n$2; if (n$2 < 0) { return $$String.sub(name, 0, 1); } - if (!is_dir_sep(name, n$2)) { + if (!Curry._2(is_dir_sep, name, n$2)) { return $$String.sub(name, 0, n$2 + 1 | 0); } _n$2 = n$2 - 1 | 0; @@ -193,7 +195,7 @@ function check_suffix$1(name, suff) { return false; } let s = $$String.sub(name, name.length - suff.length | 0, suff.length); - return $$String.lowercase_ascii(s) === $$String.lowercase_ascii(suff); + return Bytes.unsafe_to_string(Bytes.lowercase_ascii(Bytes.unsafe_of_string(s))) === Bytes.unsafe_to_string(Bytes.lowercase_ascii(Bytes.unsafe_of_string(suff))); } let temp_dir_name$1; @@ -373,7 +375,7 @@ let dir_sep = match[2]; function concat(dirname, filename) { let l = dirname.length; - if (l === 0 || is_dir_sep$2(dirname, l - 1 | 0)) { + if (l === 0 || Curry._2(is_dir_sep$2, dirname, l - 1 | 0)) { return dirname + filename; } else { return dirname + (dir_sep + filename); @@ -382,29 +384,29 @@ function concat(dirname, filename) { function chop_suffix(name, suff) { let n = name.length - suff.length | 0; - if (n >= 0) { - return $$String.sub(name, 0, n); + if (n < 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Filename.chop_suffix" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Filename.chop_suffix" - } - }); + return $$String.sub(name, 0, n); } function extension_len(name) { let _i = name.length - 1 | 0; while(true) { let i = _i; - if (i < 0 || is_dir_sep$2(name, i)) { + if (i < 0 || Curry._2(is_dir_sep$2, name, i)) { return 0; } if (Caml_string.get(name, i) === /* '.' */46) { let _i$1 = i - 1 | 0; while(true) { let i$1 = _i$1; - if (i$1 < 0 || is_dir_sep$2(name, i$1)) { + if (i$1 < 0 || Curry._2(is_dir_sep$2, name, i$1)) { return 0; } if (Caml_string.get(name, i$1) !== /* '.' */46) { @@ -430,15 +432,15 @@ function extension(name) { function chop_extension(name) { let l = extension_len(name); - if (l !== 0) { - return $$String.sub(name, 0, name.length - l | 0); + if (l === 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Filename.chop_extension" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Filename.chop_extension" - } - }); + return $$String.sub(name, 0, name.length - l | 0); } function remove_extension(name) { diff --git a/lib/js/genlex.js b/lib/js/genlex.js index d7603a2256..55f524893e 100644 --- a/lib/js/genlex.js +++ b/lib/js/genlex.js @@ -105,8 +105,8 @@ function make_lexer(keywords) { case 13 : case 26 : case 32 : - exit = 2; - break; + Stream.junk(strm__); + continue; case 34 : Stream.junk(strm__); reset_buffer(); @@ -175,10 +175,11 @@ function make_lexer(keywords) { store(/* '-' */45); store(c$2); return number(strm__); + } else { + reset_buffer(); + store(/* '-' */45); + return ident2(strm__); } - reset_buffer(); - store(/* '-' */45); - return ident2(strm__); case 48 : case 49 : case 50 : @@ -189,7 +190,7 @@ function make_lexer(keywords) { case 55 : case 56 : case 57 : - exit = 5; + exit = 4; break; case 0 : case 1 : @@ -238,7 +239,7 @@ function make_lexer(keywords) { case 62 : case 63 : case 64 : - exit = 4; + exit = 3; break; } @@ -247,7 +248,7 @@ function make_lexer(keywords) { switch (c) { case 92 : case 94 : - exit = 4; + exit = 3; break; case 91 : case 93 : @@ -255,14 +256,14 @@ function make_lexer(keywords) { exit = 1; break; default: - exit = 3; + exit = 2; } } } else { exit = c >= 127 ? ( - c > 255 || c < 192 ? 1 : 3 + c > 255 || c < 192 ? 1 : 2 ) : ( - c !== 125 ? 4 : 1 + c !== 125 ? 3 : 1 ); } switch (exit) { @@ -270,49 +271,42 @@ function make_lexer(keywords) { Stream.junk(strm__); return keyword_or_error(c); case 2 : - Stream.junk(strm__); - continue; - case 3 : Stream.junk(strm__); reset_buffer(); store(c); while(true) { let c$3 = Stream.peek(strm__); - if (c$3 !== undefined) { - let exit$1 = 0; - if (c$3 >= 91) { - if (c$3 > 122 || c$3 < 95) { - if (!(c$3 > 255 || c$3 < 192)) { - exit$1 = 2; - } - - } else if (c$3 !== 96) { - exit$1 = 2; - } - - } else if (c$3 >= 48) { - if (c$3 > 64 || c$3 < 58) { - exit$1 = 2; + if (c$3 === undefined) { + return ident_or_keyword(get_string()); + } + if (c$3 >= 91) { + if (c$3 > 122 || c$3 < 95) { + if (c$3 > 255 || c$3 < 192) { + return ident_or_keyword(get_string()); } - } else if (c$3 === 39) { - exit$1 = 2; + } else if (c$3 === 96) { + return ident_or_keyword(get_string()); } - if (exit$1 === 2) { - Stream.junk(strm__); - store(c$3); - continue; + + } else if (c$3 >= 48) { + if (!(c$3 > 64 || c$3 < 58)) { + return ident_or_keyword(get_string()); } + } else if (c$3 !== 39) { + return ident_or_keyword(get_string()); } - return ident_or_keyword(get_string()); + Stream.junk(strm__); + store(c$3); + continue; }; - case 4 : + case 3 : Stream.junk(strm__); reset_buffer(); store(c); return ident2(strm__); - case 5 : + case 4 : Stream.junk(strm__); reset_buffer(); store(c); @@ -324,81 +318,80 @@ function make_lexer(keywords) { let ident2 = function (strm__) { while(true) { let c = Stream.peek(strm__); - if (c !== undefined) { - let exit = 0; - if (c >= 94) { - if (c > 125 || c < 95) { - if (c < 127) { - exit = 2; - } - - } else if (c === 124) { - exit = 2; - } - - } else if (c >= 65) { - if (c === 92) { - exit = 2; + if (c === undefined) { + return ident_or_keyword(get_string()); + } + if (c >= 94) { + if (c > 125 || c < 95) { + if (c >= 127) { + return ident_or_keyword(get_string()); } - } else if (c >= 33) { - switch (c) { - case 34 : - case 39 : - case 40 : - case 41 : - case 44 : - case 46 : - case 48 : - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - case 55 : - case 56 : - case 57 : - case 59 : - break; - case 33 : - case 35 : - case 36 : - case 37 : - case 38 : - case 42 : - case 43 : - case 45 : - case 47 : - case 58 : - case 60 : - case 61 : - case 62 : - case 63 : - case 64 : - exit = 2; - break; - - } + } else if (c !== 124) { + return ident_or_keyword(get_string()); } - if (exit === 2) { - Stream.junk(strm__); - store(c); - continue; + + } else if (c >= 65) { + if (c !== 92) { + return ident_or_keyword(get_string()); } + } else { + if (c < 33) { + return ident_or_keyword(get_string()); + } + switch (c) { + case 34 : + case 39 : + case 40 : + case 41 : + case 44 : + case 46 : + case 48 : + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + case 59 : + return ident_or_keyword(get_string()); + case 33 : + case 35 : + case 36 : + case 37 : + case 38 : + case 42 : + case 43 : + case 45 : + case 47 : + case 58 : + case 60 : + case 61 : + case 62 : + case 63 : + case 64 : + break; + + } } - return ident_or_keyword(get_string()); + Stream.junk(strm__); + store(c); + continue; }; }; let number = function (strm__) { while(true) { let c = Stream.peek(strm__); if (c !== undefined) { - let exit = 0; if (c >= 58) { if (!(c !== 69 && c !== 101)) { - exit = 2; + Stream.junk(strm__); + store(/* 'E' */69); + return exponent_part(strm__); } } else if (c !== 46) { @@ -434,12 +427,6 @@ function make_lexer(keywords) { }; }; } - if (exit === 2) { - Stream.junk(strm__); - store(/* 'E' */69); - return exponent_part(strm__); - } - } return { TAG: "Int", @@ -449,15 +436,13 @@ function make_lexer(keywords) { }; let exponent_part = function (strm__) { let c = Stream.peek(strm__); - if (c === undefined) { + if (c !== undefined && !(c !== 43 && c !== 45)) { + Stream.junk(strm__); + store(c); return end_exponent_part(strm__); - } - if (c !== 43 && c !== 45) { + } else { return end_exponent_part(strm__); } - Stream.junk(strm__); - store(c); - return end_exponent_part(strm__); }; let end_exponent_part = function (strm__) { while(true) { @@ -690,4 +675,4 @@ function make_lexer(keywords) { } exports.make_lexer = make_lexer; -/* Hashtbl Not a pure module */ +/* No side effect */ diff --git a/lib/js/hashtbl.js b/lib/js/hashtbl.js index e06bff9294..b8f48938a0 100644 --- a/lib/js/hashtbl.js +++ b/lib/js/hashtbl.js @@ -1,8 +1,8 @@ 'use strict'; let Caml = require("./caml.js"); -let Lazy = require("./lazy.js"); let $$Array = require("./array.js"); +let Curry = require("./curry.js"); let Random = require("./random.js"); let Caml_obj = require("./caml_obj.js"); let Caml_hash = require("./caml_hash.js"); @@ -39,7 +39,7 @@ function is_randomized() { return randomized.contents; } -let prng = Lazy.from_fun(function () { +let prng = CamlinternalLazy.from_fun(function () { return Random.State.make_self_init(); }); @@ -178,7 +178,7 @@ function resize(indexfun, h) { data: data, next: "Empty" }); - let nidx = indexfun(h, key); + let nidx = Curry._2(indexfun, h, key); let tail = Caml_array.get(ndata_tail, nidx); if (typeof tail !== "object") { Caml_array.set(ndata, nidx, cell); @@ -450,7 +450,7 @@ function iter(f, h) { let key = param.key; let data = param.data; let next = param.next; - f(key, data); + Curry._2(f, key, data); _param = next; continue; }; @@ -498,7 +498,7 @@ function filter_map_inplace_bucket(f, h, i, _prec, _param) { let key = param.key; let data = param.data; let next = param.next; - let data$1 = f(key, data); + let data$1 = Curry._2(f, key, data); if (data$1 !== undefined) { if (typeof prec !== "object") { Caml_array.set(h.data, i, param); @@ -552,7 +552,7 @@ function fold(f, h, init) { let key = b.key; let data = b.data; let next = b.next; - _accu = f(key, data, accu); + _accu = Curry._3(f, key, data, accu); _b = next; continue; }; @@ -618,7 +618,7 @@ function stats(h) { function MakeSeeded(H) { let key_index = function (h, key) { - return H.hash(h.seed, key) & (h.data.length - 1 | 0); + return Curry._2(H.hash, h.seed, key) & (h.data.length - 1 | 0); }; let add = function (h, key, data) { let i = key_index(h, key); @@ -647,7 +647,7 @@ function MakeSeeded(H) { } let k = param.key; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { h.size = h.size - 1 | 0; if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); @@ -673,7 +673,7 @@ function MakeSeeded(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (H.equal(key, k1)) { + if (Curry._2(H.equal, key, k1)) { return d1; } if (typeof next1 !== "object") { @@ -686,7 +686,7 @@ function MakeSeeded(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (H.equal(key, k2)) { + if (Curry._2(H.equal, key, k2)) { return d2; } if (typeof next2 !== "object") { @@ -699,7 +699,7 @@ function MakeSeeded(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (H.equal(key, k3)) { + if (Curry._2(H.equal, key, k3)) { return d3; } else { let _param = next3; @@ -715,7 +715,7 @@ function MakeSeeded(H) { let k = param.key; let data = param.data; let next = param.next; - if (H.equal(key, k)) { + if (Curry._2(H.equal, key, k)) { return data; } _param = next; @@ -731,7 +731,7 @@ function MakeSeeded(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (H.equal(key, k1)) { + if (Curry._2(H.equal, key, k1)) { return Caml_option.some(d1); } if (typeof next1 !== "object") { @@ -740,7 +740,7 @@ function MakeSeeded(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (H.equal(key, k2)) { + if (Curry._2(H.equal, key, k2)) { return Caml_option.some(d2); } if (typeof next2 !== "object") { @@ -749,7 +749,7 @@ function MakeSeeded(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (H.equal(key, k3)) { + if (Curry._2(H.equal, key, k3)) { return Caml_option.some(d3); } else { let _param = next3; @@ -761,7 +761,7 @@ function MakeSeeded(H) { let k = param.key; let data = param.data; let next = param.next; - if (H.equal(key, k)) { + if (Curry._2(H.equal, key, k)) { return Caml_option.some(data); } _param = next; @@ -779,7 +779,7 @@ function MakeSeeded(H) { let k = param.key; let d = param.data; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { return { hd: d, tl: find_in_bucket(next) @@ -799,7 +799,7 @@ function MakeSeeded(H) { } let k = param.key; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { param.key = key; param.data = data; return false; @@ -836,7 +836,7 @@ function MakeSeeded(H) { } let k = param.key; let next = param.next; - if (H.equal(k, key)) { + if (Curry._2(H.equal, k, key)) { return true; } _param = next; @@ -866,7 +866,7 @@ function MakeSeeded(H) { function Make(H) { let equal = H.equal; let key_index = function (h, key) { - return H.hash(key) & (h.data.length - 1 | 0); + return Curry._1(H.hash, key) & (h.data.length - 1 | 0); }; let add = function (h, key, data) { let i = key_index(h, key); @@ -895,7 +895,7 @@ function Make(H) { } let k = param.key; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { h.size = h.size - 1 | 0; if (typeof prec !== "object") { return Caml_array.set(h.data, i, next); @@ -921,7 +921,7 @@ function Make(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (equal(key, k1)) { + if (Curry._2(equal, key, k1)) { return d1; } if (typeof next1 !== "object") { @@ -934,7 +934,7 @@ function Make(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (equal(key, k2)) { + if (Curry._2(equal, key, k2)) { return d2; } if (typeof next2 !== "object") { @@ -947,7 +947,7 @@ function Make(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (equal(key, k3)) { + if (Curry._2(equal, key, k3)) { return d3; } else { let _param = next3; @@ -963,7 +963,7 @@ function Make(H) { let k = param.key; let data = param.data; let next = param.next; - if (equal(key, k)) { + if (Curry._2(equal, key, k)) { return data; } _param = next; @@ -979,7 +979,7 @@ function Make(H) { let k1 = match.key; let d1 = match.data; let next1 = match.next; - if (equal(key, k1)) { + if (Curry._2(equal, key, k1)) { return Caml_option.some(d1); } if (typeof next1 !== "object") { @@ -988,7 +988,7 @@ function Make(H) { let k2 = next1.key; let d2 = next1.data; let next2 = next1.next; - if (equal(key, k2)) { + if (Curry._2(equal, key, k2)) { return Caml_option.some(d2); } if (typeof next2 !== "object") { @@ -997,7 +997,7 @@ function Make(H) { let k3 = next2.key; let d3 = next2.data; let next3 = next2.next; - if (equal(key, k3)) { + if (Curry._2(equal, key, k3)) { return Caml_option.some(d3); } else { let _param = next3; @@ -1009,7 +1009,7 @@ function Make(H) { let k = param.key; let data = param.data; let next = param.next; - if (equal(key, k)) { + if (Curry._2(equal, key, k)) { return Caml_option.some(data); } _param = next; @@ -1027,7 +1027,7 @@ function Make(H) { let k = param.key; let d = param.data; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { return { hd: d, tl: find_in_bucket(next) @@ -1047,7 +1047,7 @@ function Make(H) { } let k = param.key; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { param.key = key; param.data = data; return false; @@ -1084,7 +1084,7 @@ function Make(H) { } let k = param.key; let next = param.next; - if (equal(k, key)) { + if (Curry._2(equal, k, key)) { return true; } _param = next; @@ -1140,4 +1140,4 @@ exports.hash = hash; exports.seeded_hash = seeded_hash; exports.hash_param = hash_param; exports.seeded_hash_param = seeded_hash_param; -/* prng Not a pure module */ +/* No side effect */ diff --git a/lib/js/hashtblLabels.js b/lib/js/hashtblLabels.js index 57c37b4f41..ea6f6504c1 100644 --- a/lib/js/hashtblLabels.js +++ b/lib/js/hashtblLabels.js @@ -1,31 +1,22 @@ 'use strict'; +let Curry = require("./curry.js"); let Hashtbl = require("./hashtbl.js"); -function add(tbl, key, data) { - Hashtbl.add(tbl, key, data); -} +let add = Hashtbl.add; -function replace(tbl, key, data) { - Hashtbl.replace(tbl, key, data); -} +let replace = Hashtbl.replace; function iter(f, tbl) { - Hashtbl.iter((function (key, data) { - f(key, data); - }), tbl); + Hashtbl.iter(Curry.__2(f), tbl); } function filter_map_inplace(f, tbl) { - Hashtbl.filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Hashtbl.filter_map_inplace(Curry.__2(f), tbl); } function fold(f, tbl, init) { - return Hashtbl.fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Hashtbl.fold(Curry.__3(f), tbl, init); } function MakeSeeded(H) { @@ -35,26 +26,16 @@ function MakeSeeded(H) { let iter = include.iter; let filter_map_inplace = include.filter_map_inplace; let fold = include.fold; - let add$1 = function (tbl, key, data) { - add(tbl, key, data); - }; - let replace$1 = function (tbl, key, data) { - replace(tbl, key, data); - }; + let add$1 = Curry.__3(add); + let replace$1 = Curry.__3(replace); let iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); + Curry._2(iter, Curry.__2(f), tbl); }; let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Curry._2(filter_map_inplace, Curry.__2(f), tbl); }; let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Curry._3(fold, Curry.__3(f), tbl, init); }; return { create: include.create, @@ -78,7 +59,7 @@ function MakeSeeded(H) { function Make(H) { let hash = function (_seed, x) { - return H.hash(x); + return Curry._1(H.hash, x); }; let H_equal = H.equal; let H$1 = { @@ -92,29 +73,19 @@ function Make(H) { let iter = include.iter; let filter_map_inplace = include.filter_map_inplace; let fold = include.fold; - let add$1 = function (tbl, key, data) { - add(tbl, key, data); - }; - let replace$1 = function (tbl, key, data) { - replace(tbl, key, data); - }; + let add$1 = Curry.__3(add); + let replace$1 = Curry.__3(replace); let iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); + Curry._2(iter, Curry.__2(f), tbl); }; let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Curry._2(filter_map_inplace, Curry.__2(f), tbl); }; let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Curry._3(fold, Curry.__3(f), tbl, init); }; let create$1 = function (sz) { - return create(false, sz); + return Curry._2(create, false, sz); }; return { create: create$1, @@ -194,4 +165,4 @@ exports.filter_map_inplace = filter_map_inplace; exports.fold = fold; exports.MakeSeeded = MakeSeeded; exports.Make = Make; -/* Hashtbl Not a pure module */ +/* No side effect */ diff --git a/lib/js/js_dict.js b/lib/js/js_dict.js index 4ee3231c38..6042a9a2d4 100644 --- a/lib/js/js_dict.js +++ b/lib/js/js_dict.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function get(dict, k) { @@ -68,7 +69,7 @@ function map(f, source) { let l = keys.length; for(let i = 0; i < l; ++i){ let key = keys[i]; - target[key] = f(source[key]); + target[key] = Curry._1(f, source[key]); } return target; } diff --git a/lib/js/js_null.js b/lib/js/js_null.js index 73f42da3cf..1ef3498370 100644 --- a/lib/js/js_null.js +++ b/lib/js/js_null.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function test(x) { @@ -17,7 +18,7 @@ function getExn(f) { function bind(x, f) { if (x !== null) { - return f(x); + return Curry._1(f, x); } else { return null; } @@ -25,7 +26,7 @@ function bind(x, f) { function iter(x, f) { if (x !== null) { - return f(x); + return Curry._1(f, x); } } diff --git a/lib/js/js_null_undefined.js b/lib/js/js_null_undefined.js index 334fe5e479..aa47b04228 100644 --- a/lib/js/js_null_undefined.js +++ b/lib/js/js_null_undefined.js @@ -1,18 +1,19 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function bind(x, f) { if (x == null) { return x; } else { - return f(x); + return Curry._1(f, x); } } function iter(x, f) { if (!(x == null)) { - return f(x); + return Curry._1(f, x); } } diff --git a/lib/js/js_option.js b/lib/js/js_option.js index bdd59b6389..39d0f19069 100644 --- a/lib/js/js_option.js +++ b/lib/js/js_option.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function some(x) { @@ -12,7 +13,7 @@ function isSome(x) { function isSomeValue(eq, v, x) { if (x !== undefined) { - return eq(v, Caml_option.valFromOption(x)); + return Curry._2(eq, v, Caml_option.valFromOption(x)); } else { return false; } @@ -34,7 +35,7 @@ function getExn(x) { function equal(eq, a, b) { if (a !== undefined) { if (b !== undefined) { - return eq(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return Curry._2(eq, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return false; } @@ -45,14 +46,14 @@ function equal(eq, a, b) { function andThen(f, x) { if (x !== undefined) { - return f(Caml_option.valFromOption(x)); + return Curry._1(f, Caml_option.valFromOption(x)); } } function map(f, x) { if (x !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(x))); + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(x))); } } @@ -70,7 +71,7 @@ function filter(f, x) { return; } let x$1 = Caml_option.valFromOption(x); - if (f(x$1)) { + if (Curry._1(f, x$1)) { return Caml_option.some(x$1); } diff --git a/lib/js/js_undefined.js b/lib/js/js_undefined.js index fcbfb19305..e0d4948a54 100644 --- a/lib/js/js_undefined.js +++ b/lib/js/js_undefined.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function test(x) { @@ -21,14 +22,14 @@ function getExn(f) { function bind(x, f) { if (x !== undefined) { - return f(x); + return Curry._1(f, x); } } function iter(x, f) { if (x !== undefined) { - return f(x); + return Curry._1(f, x); } } diff --git a/lib/js/lazy.js b/lib/js/lazy.js index 30aefe8c5e..4172877d98 100644 --- a/lib/js/lazy.js +++ b/lib/js/lazy.js @@ -1,16 +1,15 @@ 'use strict'; +let Curry = require("./curry.js"); let CamlinternalLazy = require("./camlinternalLazy.js"); function from_fun(f) { return CamlinternalLazy.from_fun(function () { - return f(); + return Curry._1(f, undefined); }); } -function from_val(v) { - return CamlinternalLazy.from_val(v); -} +let from_val = CamlinternalLazy.from_val; let Undefined = CamlinternalLazy.Undefined; diff --git a/lib/js/lexing.js b/lib/js/lexing.js index fc24dc97ac..bb9e821aac 100644 --- a/lib/js/lexing.js +++ b/lib/js/lexing.js @@ -1,6 +1,7 @@ 'use strict'; let Bytes = require("./bytes.js"); +let Curry = require("./curry.js"); let Caml_array = require("./caml_array.js"); let Caml_bytes = require("./caml_bytes.js"); let Caml_lexer = require("./caml_lexer.js"); @@ -46,7 +47,7 @@ function from_function(f) { return { refill_buff: (function (x) { let aux_buffer = Caml_bytes.create(512); - let read = f(aux_buffer, aux_buffer.length); + let read = Curry._2(f, aux_buffer, aux_buffer.length); let n = read > 0 ? read : (x.lex_eof_reached = true, 0); if ((x.lex_buffer_len + n | 0) > x.lex_buffer.length) { if (((x.lex_buffer_len - x.lex_start_pos | 0) + n | 0) <= x.lex_buffer.length) { diff --git a/lib/js/list.js b/lib/js/list.js index 436c025ee2..29e7ac19f9 100644 --- a/lib/js/list.js +++ b/lib/js/list.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_obj = require("./caml_obj.js"); let Pervasives = require("./pervasives.js"); let Caml_option = require("./caml_option.js"); @@ -136,7 +137,7 @@ function init_tailrec_aux(_acc, _i, n, f) { } _i = i + 1 | 0; _acc = { - hd: f(i), + hd: Curry._1(f, i), tl: acc }; continue; @@ -147,7 +148,7 @@ function init_aux(i, n, f) { if (i >= n) { return /* [] */0; } - let r = f(i); + let r = Curry._1(f, i); return { hd: r, tl: init_aux(i + 1 | 0, n, f) @@ -155,19 +156,19 @@ function init_aux(i, n, f) { } function init(len, f) { - if (len >= 0) { - if (len > 10000) { - return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); - } else { - return init_aux(0, len, f); - } + if (len < 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.init" + } + }); + } + if (len > 10000) { + return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); + } else { + return init_aux(0, len, f); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.init" - } - }); } function flatten(param) { @@ -182,7 +183,7 @@ function map(f, param) { if (!param) { return /* [] */0; } - let r = f(param.hd); + let r = Curry._1(f, param.hd); return { hd: r, tl: map(f, param.tl) @@ -193,7 +194,7 @@ function mapi(i, f, param) { if (!param) { return /* [] */0; } - let r = f(i, param.hd); + let r = Curry._2(f, i, param.hd); return { hd: r, tl: mapi(i + 1 | 0, f, param.tl) @@ -215,7 +216,7 @@ function rev_map(f, l) { } _param = param.tl; _accu = { - hd: f(param.hd), + hd: Curry._1(f, param.hd), tl: accu }; continue; @@ -228,7 +229,7 @@ function iter(f, _param) { if (!param) { return; } - f(param.hd); + Curry._1(f, param.hd); _param = param.tl; continue; }; @@ -243,7 +244,7 @@ function iteri(f, l) { if (!param) { return; } - f(i, param.hd); + Curry._2(f, i, param.hd); _param = param.tl; _i = i + 1 | 0; continue; @@ -258,14 +259,14 @@ function fold_left(f, _accu, _l) { return accu; } _l = l.tl; - _accu = f(accu, l.hd); + _accu = Curry._2(f, accu, l.hd); continue; }; } function fold_right(f, l, accu) { if (l) { - return f(l.hd, fold_right(f, l.tl, accu)); + return Curry._2(f, l.hd, fold_right(f, l.tl, accu)); } else { return accu; } @@ -274,7 +275,7 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - let r = f(l1.hd, l2.hd); + let r = Curry._2(f, l1.hd, l2.hd); return { hd: r, tl: map2(f, l1.tl, l2.tl) @@ -311,7 +312,7 @@ function rev_map2(f, l1, l2) { _l2 = l2$1.tl; _l1 = l1$1.tl; _accu = { - hd: f(l1$1.hd, l2$1.hd), + hd: Curry._2(f, l1$1.hd, l2$1.hd), tl: accu }; continue; @@ -323,15 +324,15 @@ function rev_map2(f, l1, l2) { } }); } - if (!l2$1) { - return accu; + if (l2$1) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.rev_map2" - } - }); + return accu; }; } @@ -341,7 +342,7 @@ function iter2(f, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - f(l1.hd, l2.hd); + Curry._2(f, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -374,7 +375,7 @@ function fold_left2(f, _accu, _l1, _l2) { if (l2) { _l2 = l2.tl; _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); + _accu = Curry._3(f, accu, l1.hd, l2.hd); continue; } throw new Error("Invalid_argument", { @@ -384,22 +385,22 @@ function fold_left2(f, _accu, _l1, _l2) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_left2" - } - }); + return accu; }; } function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + return Curry._3(f, l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } throw new Error("Invalid_argument", { cause: { @@ -408,15 +409,15 @@ function fold_right2(f, l1, l2, accu) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2" - } - }); + return accu; } function for_all(p, _param) { @@ -425,7 +426,7 @@ function for_all(p, _param) { if (!param) { return true; } - if (!p(param.hd)) { + if (!Curry._1(p, param.hd)) { return false; } _param = param.tl; @@ -439,7 +440,7 @@ function exists(p, _param) { if (!param) { return false; } - if (p(param.hd)) { + if (Curry._1(p, param.hd)) { return true; } _param = param.tl; @@ -453,7 +454,7 @@ function for_all2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -485,7 +486,7 @@ function exists2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (p(l1.hd, l2.hd)) { + if (Curry._2(p, l1.hd, l2.hd)) { return true; } _l2 = l2.tl; @@ -672,7 +673,7 @@ function find(p, _param) { let param = _param; if (param) { let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return x; } _param = param.tl; @@ -693,7 +694,7 @@ function find_opt(p, _param) { return; } let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return Caml_option.some(x); } _param = param.tl; @@ -712,7 +713,7 @@ function find_all(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _accu = { hd: x, @@ -741,7 +742,7 @@ function partition(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _yes = { hd: x, @@ -817,7 +818,7 @@ function merge(cmp, l1, l2) { } let h2 = l2.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { return { hd: h1, tl: merge(cmp, l1.tl, l2) @@ -866,8 +867,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { + if (Curry._2(cmp, x1, x2) <= 0) { + if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x1, tl: { @@ -878,7 +879,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x1, tl: { @@ -901,7 +902,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x2, tl: { @@ -912,7 +913,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) <= 0) { + } else if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x2, tl: { @@ -946,7 +947,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) <= 0) { + if (Curry._2(cmp, x1$1, x2$1) <= 0) { return { hd: x1$1, tl: { @@ -986,7 +987,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) > 0) { + if (Curry._2(cmp, h1, h2) > 0) { _accu = { hd: h1, tl: accu @@ -1012,8 +1013,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { + if (Curry._2(cmp, x1, x2) > 0) { + if (Curry._2(cmp, x2, x3) > 0) { return { hd: x1, tl: { @@ -1024,7 +1025,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x1, tl: { @@ -1047,7 +1048,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x2, tl: { @@ -1058,7 +1059,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) > 0) { + } else if (Curry._2(cmp, x2, x3) > 0) { return { hd: x2, tl: { @@ -1092,7 +1093,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) > 0) { + if (Curry._2(cmp, x1$1, x2$1) > 0) { return { hd: x1$1, tl: { @@ -1132,7 +1133,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { _accu = { hd: h1, tl: accu @@ -1167,9 +1168,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1194,7 +1195,7 @@ function sort_uniq(cmp, l) { } } if (c < 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1216,7 +1217,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1249,7 +1250,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1271,7 +1272,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1314,7 +1315,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1362,7 +1363,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, @@ -1398,9 +1399,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1425,7 +1426,7 @@ function sort_uniq(cmp, l) { } } if (c > 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1447,7 +1448,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1480,7 +1481,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1502,7 +1503,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1545,7 +1546,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1593,7 +1594,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, diff --git a/lib/js/listLabels.js b/lib/js/listLabels.js index 6f81e7afde..f63f6bb629 100644 --- a/lib/js/listLabels.js +++ b/lib/js/listLabels.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_obj = require("./caml_obj.js"); let Pervasives = require("./pervasives.js"); let Caml_option = require("./caml_option.js"); @@ -136,7 +137,7 @@ function init_tailrec_aux(_acc, _i, n, f) { } _i = i + 1 | 0; _acc = { - hd: f(i), + hd: Curry._1(f, i), tl: acc }; continue; @@ -147,7 +148,7 @@ function init_aux(i, n, f) { if (i >= n) { return /* [] */0; } - let r = f(i); + let r = Curry._1(f, i); return { hd: r, tl: init_aux(i + 1 | 0, n, f) @@ -155,19 +156,19 @@ function init_aux(i, n, f) { } function init(len, f) { - if (len >= 0) { - if (len > 10000) { - return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); - } else { - return init_aux(0, len, f); - } + if (len < 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.init" + } + }); + } + if (len > 10000) { + return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); + } else { + return init_aux(0, len, f); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.init" - } - }); } function flatten(param) { @@ -182,7 +183,7 @@ function map(f, param) { if (!param) { return /* [] */0; } - let r = f(param.hd); + let r = Curry._1(f, param.hd); return { hd: r, tl: map(f, param.tl) @@ -193,7 +194,7 @@ function mapi(i, f, param) { if (!param) { return /* [] */0; } - let r = f(i, param.hd); + let r = Curry._2(f, i, param.hd); return { hd: r, tl: mapi(i + 1 | 0, f, param.tl) @@ -215,7 +216,7 @@ function rev_map(f, l) { } _param = param.tl; _accu = { - hd: f(param.hd), + hd: Curry._1(f, param.hd), tl: accu }; continue; @@ -228,7 +229,7 @@ function iter(f, _param) { if (!param) { return; } - f(param.hd); + Curry._1(f, param.hd); _param = param.tl; continue; }; @@ -243,7 +244,7 @@ function iteri(f, l) { if (!param) { return; } - f(i, param.hd); + Curry._2(f, i, param.hd); _param = param.tl; _i = i + 1 | 0; continue; @@ -258,14 +259,14 @@ function fold_left(f, _accu, _l) { return accu; } _l = l.tl; - _accu = f(accu, l.hd); + _accu = Curry._2(f, accu, l.hd); continue; }; } function fold_right(f, l, accu) { if (l) { - return f(l.hd, fold_right(f, l.tl, accu)); + return Curry._2(f, l.hd, fold_right(f, l.tl, accu)); } else { return accu; } @@ -274,7 +275,7 @@ function fold_right(f, l, accu) { function map2(f, l1, l2) { if (l1) { if (l2) { - let r = f(l1.hd, l2.hd); + let r = Curry._2(f, l1.hd, l2.hd); return { hd: r, tl: map2(f, l1.tl, l2.tl) @@ -311,7 +312,7 @@ function rev_map2(f, l1, l2) { _l2 = l2$1.tl; _l1 = l1$1.tl; _accu = { - hd: f(l1$1.hd, l2$1.hd), + hd: Curry._2(f, l1$1.hd, l2$1.hd), tl: accu }; continue; @@ -323,15 +324,15 @@ function rev_map2(f, l1, l2) { } }); } - if (!l2$1) { - return accu; + if (l2$1) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.rev_map2" - } - }); + return accu; }; } @@ -341,7 +342,7 @@ function iter2(f, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - f(l1.hd, l2.hd); + Curry._2(f, l1.hd, l2.hd); _l2 = l2.tl; _l1 = l1.tl; continue; @@ -374,7 +375,7 @@ function fold_left2(f, _accu, _l1, _l2) { if (l2) { _l2 = l2.tl; _l1 = l1.tl; - _accu = f(accu, l1.hd, l2.hd); + _accu = Curry._3(f, accu, l1.hd, l2.hd); continue; } throw new Error("Invalid_argument", { @@ -384,22 +385,22 @@ function fold_left2(f, _accu, _l1, _l2) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_left2" - } - }); + return accu; }; } function fold_right2(f, l1, l2, accu) { if (l1) { if (l2) { - return f(l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + return Curry._3(f, l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } throw new Error("Invalid_argument", { cause: { @@ -408,15 +409,15 @@ function fold_right2(f, l1, l2, accu) { } }); } - if (!l2) { - return accu; + if (l2) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "List.fold_right2" - } - }); + return accu; } function for_all(p, _param) { @@ -425,7 +426,7 @@ function for_all(p, _param) { if (!param) { return true; } - if (!p(param.hd)) { + if (!Curry._1(p, param.hd)) { return false; } _param = param.tl; @@ -439,7 +440,7 @@ function exists(p, _param) { if (!param) { return false; } - if (p(param.hd)) { + if (Curry._1(p, param.hd)) { return true; } _param = param.tl; @@ -453,7 +454,7 @@ function for_all2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (!p(l1.hd, l2.hd)) { + if (!Curry._2(p, l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -485,7 +486,7 @@ function exists2(p, _l1, _l2) { let l1 = _l1; if (l1) { if (l2) { - if (p(l1.hd, l2.hd)) { + if (Curry._2(p, l1.hd, l2.hd)) { return true; } _l2 = l2.tl; @@ -672,7 +673,7 @@ function find(p, _param) { let param = _param; if (param) { let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return x; } _param = param.tl; @@ -693,7 +694,7 @@ function find_opt(p, _param) { return; } let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { return Caml_option.some(x); } _param = param.tl; @@ -712,7 +713,7 @@ function find_all(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _accu = { hd: x, @@ -741,7 +742,7 @@ function partition(p, l) { } let l$1 = param.tl; let x = param.hd; - if (p(x)) { + if (Curry._1(p, x)) { _param = l$1; _yes = { hd: x, @@ -817,7 +818,7 @@ function merge(cmp, l1, l2) { } let h2 = l2.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { return { hd: h1, tl: merge(cmp, l1.tl, l2) @@ -866,8 +867,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) <= 0) { - if (cmp(x2, x3) <= 0) { + if (Curry._2(cmp, x1, x2) <= 0) { + if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x1, tl: { @@ -878,7 +879,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x1, tl: { @@ -901,7 +902,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) <= 0) { + } else if (Curry._2(cmp, x1, x3) <= 0) { return { hd: x2, tl: { @@ -912,7 +913,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) <= 0) { + } else if (Curry._2(cmp, x2, x3) <= 0) { return { hd: x2, tl: { @@ -946,7 +947,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) <= 0) { + if (Curry._2(cmp, x1$1, x2$1) <= 0) { return { hd: x1$1, tl: { @@ -986,7 +987,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) > 0) { + if (Curry._2(cmp, h1, h2) > 0) { _accu = { hd: h1, tl: accu @@ -1012,8 +1013,8 @@ function stable_sort(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - if (cmp(x1, x2) > 0) { - if (cmp(x2, x3) > 0) { + if (Curry._2(cmp, x1, x2) > 0) { + if (Curry._2(cmp, x2, x3) > 0) { return { hd: x1, tl: { @@ -1024,7 +1025,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x1, tl: { @@ -1047,7 +1048,7 @@ function stable_sort(cmp, l) { } }; } - } else if (cmp(x1, x3) > 0) { + } else if (Curry._2(cmp, x1, x3) > 0) { return { hd: x2, tl: { @@ -1058,7 +1059,7 @@ function stable_sort(cmp, l) { } } }; - } else if (cmp(x2, x3) > 0) { + } else if (Curry._2(cmp, x2, x3) > 0) { return { hd: x2, tl: { @@ -1092,7 +1093,7 @@ function stable_sort(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - if (cmp(x1$1, x2$1) > 0) { + if (Curry._2(cmp, x1$1, x2$1) > 0) { return { hd: x1$1, tl: { @@ -1132,7 +1133,7 @@ function stable_sort(cmp, l) { } let h2 = l2$1.hd; let h1 = l1.hd; - if (cmp(h1, h2) <= 0) { + if (Curry._2(cmp, h1, h2) <= 0) { _accu = { hd: h1, tl: accu @@ -1167,9 +1168,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1194,7 +1195,7 @@ function sort_uniq(cmp, l) { } } if (c < 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1216,7 +1217,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1249,7 +1250,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1271,7 +1272,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1314,7 +1315,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1362,7 +1363,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, @@ -1398,9 +1399,9 @@ function sort_uniq(cmp, l) { let x3 = match$1.hd; let x2 = match.hd; let x1 = l.hd; - let c = cmp(x1, x2); + let c = Curry._2(cmp, x1, x2); if (c === 0) { - let c$1 = cmp(x2, x3); + let c$1 = Curry._2(cmp, x2, x3); if (c$1 === 0) { return { hd: x2, @@ -1425,7 +1426,7 @@ function sort_uniq(cmp, l) { } } if (c > 0) { - let c$2 = cmp(x2, x3); + let c$2 = Curry._2(cmp, x2, x3); if (c$2 === 0) { return { hd: x1, @@ -1447,7 +1448,7 @@ function sort_uniq(cmp, l) { } }; } - let c$3 = cmp(x1, x3); + let c$3 = Curry._2(cmp, x1, x3); if (c$3 === 0) { return { hd: x1, @@ -1480,7 +1481,7 @@ function sort_uniq(cmp, l) { }; } } - let c$4 = cmp(x1, x3); + let c$4 = Curry._2(cmp, x1, x3); if (c$4 === 0) { return { hd: x2, @@ -1502,7 +1503,7 @@ function sort_uniq(cmp, l) { } }; } - let c$5 = cmp(x2, x3); + let c$5 = Curry._2(cmp, x2, x3); if (c$5 === 0) { return { hd: x2, @@ -1545,7 +1546,7 @@ function sort_uniq(cmp, l) { if (match$2) { let x2$1 = match$2.hd; let x1$1 = l.hd; - let c$6 = cmp(x1$1, x2$1); + let c$6 = Curry._2(cmp, x1$1, x2$1); if (c$6 === 0) { return { hd: x1$1, @@ -1593,7 +1594,7 @@ function sort_uniq(cmp, l) { let h2 = l2$1.hd; let t1 = l1.tl; let h1 = l1.hd; - let c$7 = cmp(h1, h2); + let c$7 = Curry._2(cmp, h1, h2); if (c$7 === 0) { _accu = { hd: h1, diff --git a/lib/js/map.js b/lib/js/map.js index cd35da063b..5e0b1e1da3 100644 --- a/lib/js/map.js +++ b/lib/js/map.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function Make(funarg) { @@ -120,7 +121,7 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { if (d === data) { return param; @@ -160,7 +161,7 @@ function Make(funarg) { } }); } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return param.d; } @@ -179,7 +180,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -194,7 +195,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -215,7 +216,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.l; @@ -230,7 +231,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _d0 = param$1.d; _v0 = v$1; @@ -255,7 +256,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -270,7 +271,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -291,7 +292,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _d0 = param.d; let _param$1 = param.r; @@ -306,7 +307,7 @@ function Make(funarg) { ]; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _d0 = param$1.d; _v0 = v$1; @@ -326,7 +327,7 @@ function Make(funarg) { if (typeof param !== "object") { return; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return Caml_option.some(param.d); } @@ -340,7 +341,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -458,7 +459,7 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return merge(l, r); } @@ -479,7 +480,7 @@ function Make(funarg) { }; let update = function (x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -497,9 +498,9 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -539,7 +540,7 @@ function Make(funarg) { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -549,7 +550,7 @@ function Make(funarg) { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -566,7 +567,7 @@ function Make(funarg) { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -584,7 +585,7 @@ function Make(funarg) { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -595,7 +596,7 @@ function Make(funarg) { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -611,7 +612,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -681,7 +682,7 @@ function Make(funarg) { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -714,7 +715,7 @@ function Make(funarg) { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -732,7 +733,7 @@ function Make(funarg) { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; let union = function (f, s1, s2) { if (typeof s1 !== "object") { @@ -751,7 +752,7 @@ function Make(funarg) { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -761,7 +762,7 @@ function Make(funarg) { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -775,7 +776,7 @@ function Make(funarg) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -799,7 +800,7 @@ function Make(funarg) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -849,11 +850,11 @@ function Make(funarg) { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -878,10 +879,10 @@ function Make(funarg) { if (typeof e2 !== "object") { return false; } - if (funarg.compare(e1._0, e2._0) !== 0) { + if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); diff --git a/lib/js/mapLabels.js b/lib/js/mapLabels.js index 466d54c7fa..8949bd1ae3 100644 --- a/lib/js/mapLabels.js +++ b/lib/js/mapLabels.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function Make(Ord) { @@ -120,7 +121,7 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { if (d === data) { return param; @@ -160,7 +161,7 @@ function Make(Ord) { } }); } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return param.d; } @@ -180,7 +181,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -201,7 +202,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, param.d, f, param.l); } _param = param.r; @@ -220,7 +221,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -237,7 +238,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, param.d, f, param.l); } _param = param.r; @@ -256,7 +257,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -277,7 +278,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, param.d, f, param.r); } _param = param.l; @@ -296,7 +297,7 @@ function Make(Ord) { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -313,7 +314,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, param.d, f, param.r); } _param = param.l; @@ -326,7 +327,7 @@ function Make(Ord) { if (typeof param !== "object") { return; } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return Caml_option.some(param.d); } @@ -340,7 +341,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return true; } @@ -458,7 +459,7 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return merge(l, r); } @@ -479,7 +480,7 @@ function Make(Ord) { }; let update = function (x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -497,9 +498,9 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -539,7 +540,7 @@ function Make(Ord) { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -549,7 +550,7 @@ function Make(Ord) { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -566,7 +567,7 @@ function Make(Ord) { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -584,7 +585,7 @@ function Make(Ord) { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -595,7 +596,7 @@ function Make(Ord) { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -611,7 +612,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -681,7 +682,7 @@ function Make(Ord) { let d = param.d; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return [ l, @@ -714,7 +715,7 @@ function Make(Ord) { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -732,7 +733,7 @@ function Make(Ord) { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; let union = function (f, s1, s2) { if (typeof s1 !== "object") { @@ -751,7 +752,7 @@ function Make(Ord) { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -761,7 +762,7 @@ function Make(Ord) { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -775,7 +776,7 @@ function Make(Ord) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -799,7 +800,7 @@ function Make(Ord) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -849,11 +850,11 @@ function Make(Ord) { if (typeof e2 !== "object") { return 1; } - let c = Ord.compare(e1._0, e2._0); + let c = Curry._2(Ord.compare, e1._0, e2._0); if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -878,10 +879,10 @@ function Make(Ord) { if (typeof e2 !== "object") { return false; } - if (Ord.compare(e1._0, e2._0) !== 0) { + if (Curry._2(Ord.compare, e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); diff --git a/lib/js/moreLabels.js b/lib/js/moreLabels.js index aec5317d26..2fb37caea2 100644 --- a/lib/js/moreLabels.js +++ b/lib/js/moreLabels.js @@ -1,6 +1,7 @@ 'use strict'; let List = require("./list.js"); +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); let HashtblLabels = require("./hashtblLabels.js"); @@ -150,7 +151,7 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { if (d === data) { return param; @@ -190,7 +191,7 @@ let $$Map = { } }); } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return param.d; } @@ -210,7 +211,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -231,7 +232,7 @@ let $$Map = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, param.d, f, param.l); } _param = param.r; @@ -250,7 +251,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _d0 = param.d; _v0 = v; @@ -267,7 +268,7 @@ let $$Map = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, param.d, f, param.l); } _param = param.r; @@ -286,7 +287,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -307,7 +308,7 @@ let $$Map = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, param.d, f, param.r); } _param = param.l; @@ -326,7 +327,7 @@ let $$Map = { ]; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _d0 = param.d; _v0 = v; @@ -343,7 +344,7 @@ let $$Map = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, param.d, f, param.r); } _param = param.l; @@ -356,7 +357,7 @@ let $$Map = { if (typeof param !== "object") { return; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return Caml_option.some(param.d); } @@ -370,7 +371,7 @@ let $$Map = { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -488,7 +489,7 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return merge(l, r); } @@ -509,7 +510,7 @@ let $$Map = { }; let update = function (x, f, param) { if (typeof param !== "object") { - let data = f(undefined); + let data = Curry._1(f, undefined); if (data !== undefined) { return { TAG: "Node", @@ -527,9 +528,9 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { - let data$1 = f(Caml_option.some(d)); + let data$1 = Curry._1(f, Caml_option.some(d)); if (data$1 === undefined) { return merge(l, r); } @@ -569,7 +570,7 @@ let $$Map = { return; } iter(f, param.l); - f(param.v, param.d); + Curry._2(f, param.v, param.d); _param = param.r; continue; }; @@ -579,7 +580,7 @@ let $$Map = { return "Empty"; } let l$p = map(f, param.l); - let d$p = f(param.d); + let d$p = Curry._1(f, param.d); let r$p = map(f, param.r); return { TAG: "Node", @@ -596,7 +597,7 @@ let $$Map = { } let v = param.v; let l$p = mapi(f, param.l); - let d$p = f(v, param.d); + let d$p = Curry._2(f, v, param.d); let r$p = mapi(f, param.r); return { TAG: "Node", @@ -614,7 +615,7 @@ let $$Map = { if (typeof m !== "object") { return accu; } - _accu = f(m.v, m.d, fold(f, m.l, accu)); + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); _m = m.r; continue; }; @@ -625,7 +626,7 @@ let $$Map = { if (typeof param !== "object") { return true; } - if (!p(param.v, param.d)) { + if (!Curry._2(p, param.v, param.d)) { return false; } if (!for_all(p, param.l)) { @@ -641,7 +642,7 @@ let $$Map = { if (typeof param !== "object") { return false; } - if (p(param.v, param.d)) { + if (Curry._2(p, param.v, param.d)) { return true; } if (exists(p, param.l)) { @@ -711,7 +712,7 @@ let $$Map = { let d = param.d; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -744,7 +745,7 @@ let $$Map = { let v1 = s1.v; if (s1.h >= height(s2)) { let match = split(v1, s2); - return concat_or_join(merge$1(f, s1.l, match[0]), v1, f(v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); } } @@ -762,7 +763,7 @@ let $$Map = { } let v2 = s2.v; let match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2.l), v2, f(v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); }; let union = function (f, s1, s2) { if (typeof s1 !== "object") { @@ -781,7 +782,7 @@ let $$Map = { let l = union(f, s1.l, match[0]); let r = union(f, s1.r, match[2]); if (d2$1 !== undefined) { - return concat_or_join(l, v1, f(v1, d1, Caml_option.valFromOption(d2$1)), r); + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); } else { return join(l, v1, d1, r); } @@ -791,7 +792,7 @@ let $$Map = { let l$1 = union(f, match$1[0], s2.l); let r$1 = union(f, match$1[2], s2.r); if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, f(v2, Caml_option.valFromOption(d1$1), d2), r$1); + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); } else { return join(l$1, v2, d2, r$1); } @@ -805,7 +806,7 @@ let $$Map = { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let r$p = filter(p, r); if (pvd) { if (l === l$p && r === r$p) { @@ -829,7 +830,7 @@ let $$Map = { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pvd = p(v, d); + let pvd = Curry._2(p, v, d); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -879,11 +880,11 @@ let $$Map = { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } - let c$1 = cmp(e1._1, e2._1); + let c$1 = Curry._2(cmp, e1._1, e2._1); if (c$1 !== 0) { return c$1; } @@ -908,10 +909,10 @@ let $$Map = { if (typeof e2 !== "object") { return false; } - if (funarg.compare(e1._0, e2._0) !== 0) { + if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { return false; } - if (!cmp(e1._1, e2._1)) { + if (!Curry._2(cmp, e1._1, e2._1)) { return false; } _e2 = cons_enum(e2._2, e2._3); @@ -1084,7 +1085,7 @@ let $$Set = { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return param; } @@ -1252,7 +1253,7 @@ let $$Set = { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -1288,7 +1289,7 @@ let $$Set = { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -1303,7 +1304,7 @@ let $$Set = { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return merge(l, r); } @@ -1413,7 +1414,7 @@ let $$Set = { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -1443,7 +1444,7 @@ let $$Set = { } let r2 = s2.r; let l2 = s2.l; - let c = funarg.compare(v1, s2.v); + let c = Curry._2(funarg.compare, v1, s2.v); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -1485,7 +1486,7 @@ let $$Set = { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -1497,7 +1498,7 @@ let $$Set = { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -1508,7 +1509,7 @@ let $$Set = { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -1524,7 +1525,7 @@ let $$Set = { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -1542,7 +1543,7 @@ let $$Set = { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -1565,7 +1566,7 @@ let $$Set = { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -1617,7 +1618,7 @@ let $$Set = { }); } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return v; } @@ -1633,7 +1634,7 @@ let $$Set = { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -1653,7 +1654,7 @@ let $$Set = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, f, param.l); } _param = param.r; @@ -1668,7 +1669,7 @@ let $$Set = { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -1684,7 +1685,7 @@ let $$Set = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, f, param.l); } _param = param.r; @@ -1699,7 +1700,7 @@ let $$Set = { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -1719,7 +1720,7 @@ let $$Set = { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, f, param.r); } _param = param.l; @@ -1734,7 +1735,7 @@ let $$Set = { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -1750,7 +1751,7 @@ let $$Set = { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, f, param.r); } _param = param.l; @@ -1764,7 +1765,7 @@ let $$Set = { return; } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return Caml_option.some(v); } @@ -1773,7 +1774,7 @@ let $$Set = { }; }; let try_join = function (l, v, r) { - if ((l === "Empty" || funarg.compare(max_elt(l), v) < 0) && (r === "Empty" || funarg.compare(v, min_elt(r)) < 0)) { + if ((l === "Empty" || Curry._2(funarg.compare, max_elt(l), v) < 0) && (r === "Empty" || Curry._2(funarg.compare, v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); @@ -1787,7 +1788,7 @@ let $$Set = { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; @@ -1975,4 +1976,4 @@ let $$Set = { exports.Hashtbl = Hashtbl; exports.$$Map = $$Map; exports.$$Set = $$Set; -/* HashtblLabels Not a pure module */ +/* No side effect */ diff --git a/lib/js/parsing.js b/lib/js/parsing.js index a5da32f420..7c9f805da6 100644 --- a/lib/js/parsing.js +++ b/lib/js/parsing.js @@ -1,6 +1,7 @@ 'use strict'; let $$Array = require("./array.js"); +let Curry = require("./curry.js"); let Lexing = require("./lexing.js"); let Caml_obj = require("./caml_obj.js"); let Caml_array = require("./caml_array.js"); @@ -80,7 +81,7 @@ function yyparse(tables, start, lexer, lexbuf) { let match = Caml_parser.parse_engine(tables, env, cmd, arg); switch (match) { case "Read_token" : - let t = lexer(lexbuf); + let t = Curry._1(lexer, lexbuf); env.symb_start = lexbuf.lex_start_p; env.symb_end = lexbuf.lex_curr_p; _arg = t; @@ -107,7 +108,7 @@ function yyparse(tables, start, lexer, lexbuf) { try { match$1 = [ "Semantic_action_computed", - Caml_array.get(tables.actions, env.rule_number)(env) + Curry._1(Caml_array.get(tables.actions, env.rule_number), env) ]; } catch (raw_exn){ @@ -127,7 +128,7 @@ function yyparse(tables, start, lexer, lexbuf) { _cmd = match$1[0]; continue; case "Call_error_function" : - tables.error_function("syntax error"); + Curry._1(tables.error_function, "syntax error"); _arg = undefined; _cmd = "Error_detected"; continue; @@ -211,7 +212,7 @@ function rhs_end(n) { } function is_current_lookahead(tok) { - return current_lookahead_fun.contents(tok); + return Curry._1(current_lookahead_fun.contents, tok); } function parse_error(param) { diff --git a/lib/js/pervasives.js b/lib/js/pervasives.js index 851b6b0782..9a01509278 100644 --- a/lib/js/pervasives.js +++ b/lib/js/pervasives.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_sys = require("./caml_sys.js"); let Caml_format = require("./caml_format.js"); let Caml_string = require("./caml_string.js"); @@ -41,7 +42,7 @@ function lnot(x) { let min_int = -2147483648; function classify_float(x) { - if (isFinite(x)) { + if (Curry._1(isFinite, x)) { if (Math.abs(x) >= 2.22507385850720138e-308) { return "FP_normal"; } else if (x !== 0) { @@ -49,7 +50,7 @@ function classify_float(x) { } else { return "FP_zero"; } - } else if (isNaN(x)) { + } else if (Curry._1(isNaN, x)) { return "FP_nan"; } else { return "FP_infinite"; @@ -185,7 +186,7 @@ function print_int(i) { } function print_float(i) { - console.log(string_of_float(i)); + console.log(valid_float_lexem(Caml_format.format_float("%.12g", i))); } function print_string(prim) { @@ -201,13 +202,13 @@ let exit_function = { function at_exit(f) { let g = exit_function.contents; exit_function.contents = (function () { - f(); - g(); + Curry._1(f, undefined); + Curry._1(g, undefined); }); } function exit(retcode) { - exit_function.contents(); + Curry._1(exit_function.contents, undefined); return Caml_sys.sys_exit(retcode); } diff --git a/lib/js/queue.js b/lib/js/queue.js index ca975f36f1..477ae6ec33 100644 --- a/lib/js/queue.js +++ b/lib/js/queue.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); let Caml_exceptions = require("./caml_exceptions.js"); let Empty = /* @__PURE__ */Caml_exceptions.create("Queue.Empty"); @@ -116,7 +117,7 @@ function iter(f, q) { return; } let next = cell.next; - f(cell.content); + Curry._1(f, cell.content); _cell = next; continue; }; @@ -132,7 +133,7 @@ function fold(f, accu, q) { return accu$1; } let next = cell.next; - let accu$2 = f(accu$1, cell.content); + let accu$2 = Curry._2(f, accu$1, cell.content); _cell = next; _accu = accu$2; continue; diff --git a/lib/js/random.js b/lib/js/random.js index 68552595f8..bf7a70c1b7 100644 --- a/lib/js/random.js +++ b/lib/js/random.js @@ -74,65 +74,65 @@ function bits(s) { } function int(s, bound) { - if (!(bound > 1073741823 || bound <= 0)) { - while(true) { - let r = bits(s); - let v = r % bound; - if ((r - v | 0) <= ((1073741823 - bound | 0) + 1 | 0)) { - return v; - } - continue; - }; + if (bound > 1073741823 || bound <= 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Random.int" - } - }); + while(true) { + let r = bits(s); + let v = r % bound; + if ((r - v | 0) <= ((1073741823 - bound | 0) + 1 | 0)) { + return v; + } + continue; + }; } function int32(s, bound) { - if (bound > 0) { - while(true) { - let b1 = bits(s); - let b2 = ((bits(s) & 1) << 30); - let r = b1 | b2; - let v = r % bound; - if ((r - v | 0) <= ((Int32.max_int - bound | 0) + 1 | 0)) { - return v; - } - continue; - }; + if (bound <= 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int32" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Random.int32" - } - }); + while(true) { + let b1 = bits(s); + let b2 = ((bits(s) & 1) << 30); + let r = b1 | b2; + let v = r % bound; + if ((r - v | 0) <= ((Int32.max_int - bound | 0) + 1 | 0)) { + return v; + } + continue; + }; } function int64(s, bound) { - if (!Caml.i64_le(bound, Caml_int64.zero)) { - while(true) { - let b1 = Caml_int64.of_int32(bits(s)); - let b2 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s)), 30); - let b3 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s) & 7), 60); - let r = Caml_int64.or_(b1, Caml_int64.or_(b2, b3)); - let v = Caml_int64.mod_(r, bound); - if (!Caml.i64_gt(Caml_int64.sub(r, v), Caml_int64.add(Caml_int64.sub(Int64.max_int, bound), Caml_int64.one))) { - return v; - } - continue; - }; + if (Caml.i64_le(bound, Caml_int64.zero)) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int64" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Random.int64" - } - }); + while(true) { + let b1 = Caml_int64.of_int32(bits(s)); + let b2 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s)), 30); + let b3 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s) & 7), 60); + let r = Caml_int64.or_(b1, Caml_int64.or_(b2, b3)); + let v = Caml_int64.mod_(r, bound); + if (!Caml.i64_gt(Caml_int64.sub(r, v), Caml_int64.add(Caml_int64.sub(Int64.max_int, bound), Caml_int64.one))) { + return v; + } + continue; + }; } function rawfloat(s) { @@ -227,7 +227,7 @@ function int64$1(bound) { } function float$1(scale) { - return float($$default, scale); + return rawfloat($$default) * scale; } function bool$1() { diff --git a/lib/js/set.js b/lib/js/set.js index de2d6b2629..c7d617b2e5 100644 --- a/lib/js/set.js +++ b/lib/js/set.js @@ -1,6 +1,7 @@ 'use strict'; let List = require("./list.js"); +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function Make(funarg) { @@ -100,7 +101,7 @@ function Make(funarg) { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return param; } @@ -259,7 +260,7 @@ function Make(funarg) { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return [ l, @@ -295,7 +296,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - let c = funarg.compare(x, param.v); + let c = Curry._2(funarg.compare, x, param.v); if (c === 0) { return true; } @@ -310,7 +311,7 @@ function Make(funarg) { let r = param.r; let v = param.v; let l = param.l; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { if (typeof l !== "object") { return r; @@ -428,7 +429,7 @@ function Make(funarg) { if (typeof e2 !== "object") { return 1; } - let c = funarg.compare(e1._0, e2._0); + let c = Curry._2(funarg.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -455,7 +456,7 @@ function Make(funarg) { } let r2 = s2.r; let l2 = s2.l; - let c = funarg.compare(v1, s2.v); + let c = Curry._2(funarg.compare, v1, s2.v); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -497,7 +498,7 @@ function Make(funarg) { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -509,7 +510,7 @@ function Make(funarg) { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -520,7 +521,7 @@ function Make(funarg) { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -536,7 +537,7 @@ function Make(funarg) { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -554,7 +555,7 @@ function Make(funarg) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -577,7 +578,7 @@ function Make(funarg) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -629,7 +630,7 @@ function Make(funarg) { }); } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return v; } @@ -648,7 +649,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -658,7 +659,7 @@ function Make(funarg) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -678,7 +679,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.l; while(true) { @@ -688,7 +689,7 @@ function Make(funarg) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.l; _v0 = v$1; continue; @@ -712,7 +713,7 @@ function Make(funarg) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -722,7 +723,7 @@ function Make(funarg) { return v0; } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -742,7 +743,7 @@ function Make(funarg) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { let _v0 = v; let _param$1 = param.r; while(true) { @@ -752,7 +753,7 @@ function Make(funarg) { return Caml_option.some(v0); } let v$1 = param$1.v; - if (f(v$1)) { + if (Curry._1(f, v$1)) { _param$1 = param$1.r; _v0 = v$1; continue; @@ -772,7 +773,7 @@ function Make(funarg) { return; } let v = param.v; - let c = funarg.compare(x, v); + let c = Curry._2(funarg.compare, x, v); if (c === 0) { return Caml_option.some(v); } @@ -788,11 +789,11 @@ function Make(funarg) { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; - } else if ((l$p === "Empty" || funarg.compare(max_elt(l$p), v$p) < 0) && (r$p === "Empty" || funarg.compare(v$p, min_elt(r$p)) < 0)) { + } else if ((l$p === "Empty" || Curry._2(funarg.compare, max_elt(l$p), v$p) < 0) && (r$p === "Empty" || Curry._2(funarg.compare, v$p, min_elt(r$p)) < 0)) { return join(l$p, v$p, r$p); } else { return union(l$p, add(v$p, r$p)); diff --git a/lib/js/setLabels.js b/lib/js/setLabels.js index 9cbf5ee04b..aa0a8f097b 100644 --- a/lib/js/setLabels.js +++ b/lib/js/setLabels.js @@ -1,6 +1,7 @@ 'use strict'; let List = require("./list.js"); +let Curry = require("./curry.js"); let Caml_option = require("./caml_option.js"); function Make(Ord) { @@ -100,7 +101,7 @@ function Make(Ord) { let r = param.r; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return param; } @@ -268,7 +269,7 @@ function Make(Ord) { let r = param.r; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return [ l, @@ -304,7 +305,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - let c = Ord.compare(x, param.v); + let c = Curry._2(Ord.compare, x, param.v); if (c === 0) { return true; } @@ -319,7 +320,7 @@ function Make(Ord) { let r = param.r; let v = param.v; let l = param.l; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return merge(l, r); } @@ -429,7 +430,7 @@ function Make(Ord) { if (typeof e2 !== "object") { return 1; } - let c = Ord.compare(e1._0, e2._0); + let c = Curry._2(Ord.compare, e1._0, e2._0); if (c !== 0) { return c; } @@ -459,7 +460,7 @@ function Make(Ord) { } let r2 = s2.r; let l2 = s2.l; - let c = Ord.compare(v1, s2.v); + let c = Curry._2(Ord.compare, v1, s2.v); if (c === 0) { if (!subset(l1, l2)) { return false; @@ -501,7 +502,7 @@ function Make(Ord) { return; } iter(f, param.l); - f(param.v); + Curry._1(f, param.v); _param = param.r; continue; }; @@ -513,7 +514,7 @@ function Make(Ord) { if (typeof s !== "object") { return accu; } - _accu = f(s.v, fold(f, s.l, accu)); + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); _s = s.r; continue; }; @@ -524,7 +525,7 @@ function Make(Ord) { if (typeof param !== "object") { return true; } - if (!p(param.v)) { + if (!Curry._1(p, param.v)) { return false; } if (!for_all(p, param.l)) { @@ -540,7 +541,7 @@ function Make(Ord) { if (typeof param !== "object") { return false; } - if (p(param.v)) { + if (Curry._1(p, param.v)) { return true; } if (exists(p, param.l)) { @@ -558,7 +559,7 @@ function Make(Ord) { let v = param.v; let l = param.l; let l$p = filter(p, l); - let pv = p(v); + let pv = Curry._1(p, v); let r$p = filter(p, r); if (pv) { if (l === l$p && r === r$p) { @@ -581,7 +582,7 @@ function Make(Ord) { let match = partition(p, param.l); let lf = match[1]; let lt = match[0]; - let pv = p(v); + let pv = Curry._1(p, v); let match$1 = partition(p, param.r); let rf = match$1[1]; let rt = match$1[0]; @@ -633,7 +634,7 @@ function Make(Ord) { }); } let v = param.v; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return v; } @@ -649,7 +650,7 @@ function Make(Ord) { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -669,7 +670,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_aux(v, f, param.l); } _param = param.r; @@ -684,7 +685,7 @@ function Make(Ord) { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.l; _v0 = v; continue; @@ -700,7 +701,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_first_opt_aux(v, f, param.l); } _param = param.r; @@ -715,7 +716,7 @@ function Make(Ord) { return v0; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -735,7 +736,7 @@ function Make(Ord) { }); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_aux(v, f, param.r); } _param = param.l; @@ -750,7 +751,7 @@ function Make(Ord) { return Caml_option.some(v0); } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { _param = param.r; _v0 = v; continue; @@ -766,7 +767,7 @@ function Make(Ord) { return; } let v = param.v; - if (f(v)) { + if (Curry._1(f, v)) { return find_last_opt_aux(v, f, param.r); } _param = param.l; @@ -780,7 +781,7 @@ function Make(Ord) { return; } let v = param.v; - let c = Ord.compare(x, v); + let c = Curry._2(Ord.compare, x, v); if (c === 0) { return Caml_option.some(v); } @@ -789,7 +790,7 @@ function Make(Ord) { }; }; let try_join = function (l, v, r) { - if ((l === "Empty" || Ord.compare(max_elt(l), v) < 0) && (r === "Empty" || Ord.compare(v, min_elt(r)) < 0)) { + if ((l === "Empty" || Curry._2(Ord.compare, max_elt(l), v) < 0) && (r === "Empty" || Curry._2(Ord.compare, v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); @@ -803,7 +804,7 @@ function Make(Ord) { let v = param.v; let l = param.l; let l$p = map(f, l); - let v$p = f(v); + let v$p = Curry._1(f, v); let r$p = map(f, r); if (l === l$p && v === v$p && r === r$p) { return param; diff --git a/lib/js/sort.js b/lib/js/sort.js index b67fc300e9..fe40df1d29 100644 --- a/lib/js/sort.js +++ b/lib/js/sort.js @@ -1,5 +1,6 @@ 'use strict'; +let Curry = require("./curry.js"); function merge(order, l1, l2) { if (!l1) { @@ -10,7 +11,7 @@ function merge(order, l1, l2) { } let h2 = l2.hd; let h1 = l1.hd; - if (order(h1, h2)) { + if (Curry._2(order, h1, h2)) { return { hd: h1, tl: merge(order, l1.tl, l2) @@ -41,7 +42,7 @@ function list(order, l) { } let e2 = match.hd; return { - hd: order(e, e2) ? ({ + hd: Curry._2(order, e, e2) ? ({ hd: e, tl: { hd: e2, @@ -100,12 +101,12 @@ function array(cmp, arr) { return; } let mid = ((lo + hi | 0) >>> 1); - if (cmp(arr[mid], arr[lo])) { + if (Curry._2(cmp, arr[mid], arr[lo])) { swap(arr, mid, lo); } - if (cmp(arr[hi], arr[mid])) { + if (Curry._2(cmp, arr[hi], arr[mid])) { swap(arr, mid, hi); - if (cmp(arr[mid], arr[lo])) { + if (Curry._2(cmp, arr[mid], arr[lo])) { swap(arr, mid, lo); } @@ -113,7 +114,7 @@ function array(cmp, arr) { let pivot = arr[mid]; let i = lo + 1 | 0; let j = hi - 1 | 0; - if (!cmp(pivot, arr[hi]) || !cmp(arr[lo], pivot)) { + if (!Curry._2(cmp, pivot, arr[hi]) || !Curry._2(cmp, arr[lo], pivot)) { throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", @@ -122,10 +123,10 @@ function array(cmp, arr) { }); } while(i < j) { - while(!cmp(pivot, arr[i])) { + while(!Curry._2(cmp, pivot, arr[i])) { i = i + 1 | 0; }; - while(!cmp(arr[j], pivot)) { + while(!Curry._2(cmp, arr[j], pivot)) { j = j - 1 | 0; }; if (i < j) { @@ -147,10 +148,10 @@ function array(cmp, arr) { qsort(0, arr.length - 1 | 0); for(let i = 1 ,i_finish = arr.length; i < i_finish; ++i){ let val_i = arr[i]; - if (!cmp(arr[i - 1 | 0], val_i)) { + if (!Curry._2(cmp, arr[i - 1 | 0], val_i)) { arr[i] = arr[i - 1 | 0]; let j = i - 1 | 0; - while(j >= 1 && !cmp(arr[j - 1 | 0], val_i)) { + while(j >= 1 && !Curry._2(cmp, arr[j - 1 | 0], val_i)) { arr[j] = arr[j - 1 | 0]; j = j - 1 | 0; }; diff --git a/lib/js/stream.js b/lib/js/stream.js index 8912267e9e..b7f56e1336 100644 --- a/lib/js/stream.js +++ b/lib/js/stream.js @@ -1,7 +1,7 @@ 'use strict'; -let Lazy = require("./lazy.js"); let List = require("./list.js"); +let Curry = require("./curry.js"); let Caml_bytes = require("./caml_bytes.js"); let Caml_option = require("./caml_option.js"); let Caml_string = require("./caml_string.js"); @@ -84,7 +84,7 @@ function get_data(count, _d) { return "Sempty"; } } - let a$1 = g.func(count); + let a$1 = Curry._1(g.func, count); if (a$1 !== undefined) { return { TAG: "Scons", @@ -137,7 +137,7 @@ function peek_data(s) { if (a !== undefined) { return Caml_option.valFromOption(a); } - let x = g.func(s.count); + let x = Curry._1(g.func, s.count); g.curr = Caml_option.some(x); return x; @@ -266,7 +266,7 @@ function iter(f, strm) { return; } junk(strm); - f(Caml_option.valFromOption(a)); + Curry._1(f, Caml_option.valFromOption(a)); _param = undefined; continue; }; @@ -362,32 +362,38 @@ function ising(i) { } function lapp(f, s) { + let f$1 = function () { + return { + TAG: "Sapp", + _0: data(Curry._1(f, undefined)), + _1: data(s) + }; + }; return { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { - return { - TAG: "Sapp", - _0: data(f()), - _1: data(s) - }; + _0: CamlinternalLazy.from_fun(function () { + return f$1(); }) } }; } function lcons(f, s) { + let f$1 = function () { + return { + TAG: "Scons", + _0: Curry._1(f, undefined), + _1: data(s) + }; + }; return { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { - return { - TAG: "Scons", - _0: f(), - _1: data(s) - }; + _0: CamlinternalLazy.from_fun(function () { + return f$1(); }) } }; @@ -398,10 +404,10 @@ function lsing(f) { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { + _0: CamlinternalLazy.from_fun(function () { return { TAG: "Scons", - _0: f(), + _0: Curry._1(f, undefined), _1: "Sempty" }; }) @@ -414,8 +420,8 @@ function slazy(f) { count: 0, data: { TAG: "Slazy", - _0: Lazy.from_fun(function () { - return data(f()); + _0: CamlinternalLazy.from_fun(function () { + return data(Curry._1(f, undefined)); }) } }; @@ -429,7 +435,7 @@ function dump_data(f, param) { switch (param.TAG) { case "Scons" : console.log("Scons ("); - f(param._0); + Curry._1(f, param._0); console.log(", "); dump_data(f, param._1); console.log(")"); diff --git a/lib/js/string.js b/lib/js/string.js index 75ba5054f7..aa7d5dc456 100644 --- a/lib/js/string.js +++ b/lib/js/string.js @@ -3,6 +3,7 @@ let Caml = require("./caml.js"); let $$Array = require("./array.js"); let Bytes = require("./bytes.js"); +let Curry = require("./curry.js"); let Caml_string = require("./caml_string.js"); let Caml_js_exceptions = require("./caml_js_exceptions.js"); @@ -20,13 +21,13 @@ function concat(sep, xs) { function iter(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(s.codePointAt(i)); + Curry._1(f, s.codePointAt(i)); } } function iteri(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(i, s.codePointAt(i)); + Curry._2(f, i, s.codePointAt(i)); } } @@ -128,28 +129,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -175,15 +176,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -205,15 +206,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/js/stringLabels.js b/lib/js/stringLabels.js index af81310fe7..d1b13c3144 100644 --- a/lib/js/stringLabels.js +++ b/lib/js/stringLabels.js @@ -3,6 +3,7 @@ let Caml = require("./caml.js"); let $$Array = require("./array.js"); let Bytes = require("./bytes.js"); +let Curry = require("./curry.js"); let Caml_string = require("./caml_string.js"); let Caml_js_exceptions = require("./caml_js_exceptions.js"); @@ -14,9 +15,7 @@ function sub(s, ofs, len) { return Bytes.unsafe_to_string(Bytes.sub(Bytes.unsafe_of_string(s), ofs, len)); } -function blit(src, src_pos, dst, dst_pos, len) { - Bytes.blit_string(src, src_pos, dst, dst_pos, len); -} +let blit = Bytes.blit_string; function concat(sep, xs) { return $$Array.of_list(xs).join(sep); @@ -24,13 +23,13 @@ function concat(sep, xs) { function iter(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(s.codePointAt(i)); + Curry._1(f, s.codePointAt(i)); } } function iteri(f, s) { for(let i = 0 ,i_finish = s.length; i < i_finish; ++i){ - f(i, s.codePointAt(i)); + Curry._2(f, i, s.codePointAt(i)); } } @@ -132,28 +131,28 @@ function index_opt(s, c) { function index_from(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from / Bytes.index_from" - } - }); + return index_rec(s, l, i, c); } function index_from_opt(s, i, c) { let l = s.length; - if (!(i < 0 || i > l)) { - return index_rec_opt(s, l, i, c); + if (i < 0 || i > l) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.index_from_opt / Bytes.index_from_opt" - } - }); + return index_rec_opt(s, l, i, c); } function rindex_rec(s, _i, c) { @@ -179,15 +178,15 @@ function rindex(s, c) { } function rindex_from(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from / Bytes.rindex_from" - } - }); + return rindex_rec(s, i, c); } function rindex_rec_opt(s, _i, c) { @@ -209,15 +208,15 @@ function rindex_opt(s, c) { } function rindex_from_opt(s, i, c) { - if (!(i < -1 || i >= s.length)) { - return rindex_rec_opt(s, i, c); + if (i < -1 || i >= s.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "String.rindex_from_opt / Bytes.rindex_from_opt" - } - }); + return rindex_rec_opt(s, i, c); } function contains_from(s, i, c) { diff --git a/lib/js/sys.js b/lib/js/sys.js index 8239622f87..48a03282b9 100644 --- a/lib/js/sys.js +++ b/lib/js/sys.js @@ -45,20 +45,7 @@ function set_signal(sig_num, sig_beh) { let Break = /* @__PURE__ */Caml_exceptions.create("Sys.Break"); function catch_break(on) { - if (on) { - return set_signal(-6, { - TAG: "Signal_handle", - _0: (function (param) { - throw new Error(Break, { - cause: { - RE_EXN_ID: Break - } - }); - }) - }); - } else { - return set_signal(-6, "Signal_default"); - } + } function enable_runtime_warnings(param) { diff --git a/lib/js/uchar.js b/lib/js/uchar.js index 27e3a6e7ac..87523c8fb6 100644 --- a/lib/js/uchar.js +++ b/lib/js/uchar.js @@ -15,30 +15,30 @@ function succ(u) { if (u === 55295) { return 57344; } - if (u !== 1114111) { - return u + 1 | 0; + if (u === 1114111) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "U+10FFFF has no successor" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "U+10FFFF has no successor" - } - }); + return u + 1 | 0; } function pred(u) { if (u === 57344) { return 55295; } - if (u !== 0) { - return u - 1 | 0; + if (u === 0) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "U+0000 has no predecessor" + } + }); } - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "U+0000 has no predecessor" - } - }); + return u - 1 | 0; } function is_valid(i) {