diff --git a/CHANGELOG.md b/CHANGELOG.md index ad9d276661..633db87633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Removed empty line at the end of `switch` statement - Removed empty `default` case from `switch` statement in the generated code - Optimised the Type Extension runtime code and removed trailing `/1` from `RE_EXN_ID` https://github.com/rescript-lang/rescript-compiler/pull/6958 +- Compact output for anonymous functions. https://github.com/rescript-lang/rescript-compiler/pull/6945 #### :bug: Bug Fix - Fix issue where long layout break added a trailing comma in partial application `...`. https://github.com/rescript-lang/rescript-compiler/pull/6949 diff --git a/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js b/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js index e2a8d1556e..575038f3f6 100644 --- a/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js +++ b/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js @@ -33,7 +33,7 @@ let Gpr3987ReproOk = { make: make }; -React.createElement(make, makeProps("test", (function (param, param$1) { +React.createElement(make, makeProps("test", ((param, param$1) => { }), undefined)); @@ -47,7 +47,7 @@ let Gpr3987ReproOk2 = { React.createElement(Gpr_3987_test$Gpr3987ReproOk2, { value: "test", - onChange: (function (param, param$1) { + onChange: ((param, param$1) => { }) }); @@ -62,7 +62,7 @@ let Gpr3987ReproError = { React.createElement(Gpr_3987_test$Gpr3987ReproError, { value: "test", - onChange: (function (param, param$1) { + onChange: ((param, param$1) => { }) }); diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index a09885ae2f..44fdebef6b 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -163,7 +163,7 @@ let raw_snippet_exp_simple_enough (s : string) = let exp_need_paren (e : J.expression) = match e.expression_desc with (* | Caml_uninitialized_obj _ *) - | Call ({ expression_desc = Fun _ | Raw_js_code _ }, _, _) -> true + | Call ({ expression_desc = Raw_js_code _ }, _, _) -> true | Raw_js_code { code_info = Exp _ } | Fun _ | Caml_block @@ -360,6 +360,12 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t) ~fn_stat (* the context will be continued after this function *) let outer_cxt = Ext_pp_scope.merge cxt set_env in + (* whether the function output can use arrow syntax *) + let arrow = match fn_state with + | Name_top _ -> false + | _ -> not is_method + in + (* the context used to be printed inside this function when printing a function, @@ -385,10 +391,31 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t) ~fn_stat function_body ?directive ~return_unit cxt f b)) else let cxt = - P.paren_group f 1 (fun _ -> formal_parameter_list inner_cxt f l) + match l with + | [ single ] when arrow -> + Ext_pp_scope.ident inner_cxt f single + | l -> + P.paren_group f 1 (fun _ -> formal_parameter_list inner_cxt f l) in P.space f; - P.brace_vgroup f 1 (fun _ -> function_body ?directive ~return_unit cxt f b) + if arrow then ( + P.string f (L.arrow); + P.space f; + ); + match b with + | [ { statement_desc = Return { expression_desc = Undefined _ } } ] + when arrow + -> + P.string f "{"; + P.string f "}"; + + | [ { statement_desc = Return e } ] | [ { statement_desc = Exp e } ] + when arrow && directive == None + -> (if exp_need_paren e then P.paren_group f 0 else P.group f 0) + (fun _ -> ignore (expression ~level:0 cxt f e)) + + | _ -> + P.brace_vgroup f 1 (fun _ -> function_body ?directive ~return_unit cxt f b) in let enclose () = let handle () = @@ -396,24 +423,18 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t) ~fn_stat match fn_state with | Is_return -> return_sp f; - P.string f (L.function_async ~async); - P.space f; + P.string f (L.function_ ~async ~arrow); + param_body () + | No_name _ -> + P.string f (L.function_ ~async ~arrow); param_body () - | No_name { single_arg } -> - (* see # 1692, add a paren for annoymous function for safety *) - P.cond_paren_group f (not single_arg) (fun _ -> - P.string f (L.function_async ~async); - P.space f; - param_body ()) | Name_non_top x -> ignore (pp_var_assign inner_cxt f x : cxt); - P.string f (L.function_async ~async); - P.space f; + P.string f (L.function_ ~async ~arrow); param_body (); semi f | Name_top x -> - P.string f (L.function_async ~async); - P.space f; + P.string f (L.function_ ~async ~arrow); ignore (Ext_pp_scope.ident inner_cxt f x : cxt); param_body ()) in @@ -504,8 +525,9 @@ and expression_desc cxt ~(level : int) f x : cxt = expression ~level:0 cxt f e2) | Fun { is_method; params; body; env; return_unit; async; directive } -> (* TODO: dump for comments *) - pp_function ?directive ~is_method cxt f ~fn_state:default_fn_exp_state params body - env ~return_unit ~async + pp_function ?directive ~is_method ~return_unit ~async + ~fn_state:default_fn_exp_state + cxt f params body env (* TODO: when [e] is [Js_raw_code] with arity print it in a more precise way @@ -520,7 +542,11 @@ and expression_desc cxt ~(level : int) f x : cxt = P.group f 0 (fun _ -> match (info, el) with | { arity = Full }, _ | _, [] -> - let cxt = expression ~level:15 cxt f e in + let cxt = + P.cond_paren_group f + (match e.expression_desc with Fun _ -> true | _ -> false) + (fun () -> expression ~level:15 cxt f e ) + in P.paren_group f 0 (fun _ -> match el with | [ @@ -538,9 +564,9 @@ and expression_desc cxt ~(level : int) f x : cxt = }; }; ] -> - pp_function ?directive ~is_method ~return_unit ~async cxt f + pp_function ?directive ~is_method ~return_unit ~async ~fn_state:(No_name { single_arg = true }) - params body env + cxt f params body env | _ -> let el = match el with | [e] when e.expression_desc = Undefined {is_unit = true} -> @@ -941,9 +967,9 @@ and variable_declaration top cxt f (variable : J.variable_declaration) : cxt = | _ -> ( match e.expression_desc with | Fun { is_method; params; body; env; return_unit; async; directive } -> - pp_function ?directive ~is_method cxt f ~return_unit ~async + pp_function ?directive ~is_method ~return_unit ~async ~fn_state:(if top then Name_top name else Name_non_top name) - params body env + cxt f params body env | _ -> let cxt = pp_var_assign cxt f name in let cxt = expression ~level:1 cxt f e in @@ -1151,8 +1177,9 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt = match e.expression_desc with | Fun { is_method; params; body; env; return_unit; async; directive } -> let cxt = - pp_function ?directive ~return_unit ~is_method ~async cxt f ~fn_state:Is_return - params body env + pp_function ?directive ~return_unit ~is_method ~async + ~fn_state:Is_return + cxt f params body env in semi f; cxt diff --git a/jscomp/core/js_dump_lit.ml b/jscomp/core/js_dump_lit.ml index ee8b5bbe28..c341c7f1c6 100644 --- a/jscomp/core/js_dump_lit.ml +++ b/jscomp/core/js_dump_lit.ml @@ -22,12 +22,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - let await = "await" -let function_ = "function" +let function_ ~async ~arrow = + match (async, arrow) with + | (true, true) -> "async " + | (false, true) -> "" + | (true, false) -> "async function " + | (false, false) -> "function " -let function_async ~async = if async then "async function" else "function" +let arrow = "=>" let let_ = "let" diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index 229a99337b..ebbd80d281 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -207,7 +207,7 @@ let unit : t = { expression_desc = Undefined {is_unit = true}; comment = None } [Js_fun_env.empty] is a mutable state .. *) -let ocaml_fun ?comment ?immutable_mask ~return_unit ~async ~one_unit_arg ?directive params body : t = +let ocaml_fun ?comment ?immutable_mask ?directive ~return_unit ~async ~one_unit_arg params body : t = let params = if one_unit_arg then [] else params in let len = List.length params in { diff --git a/jscomp/core/js_exp_make.mli b/jscomp/core/js_exp_make.mli index 63b50a916d..2e1cd072bb 100644 --- a/jscomp/core/js_exp_make.mli +++ b/jscomp/core/js_exp_make.mli @@ -88,10 +88,10 @@ val str : ?delim: J.delim -> ?comment: string -> string -> t val ocaml_fun : ?comment:string -> ?immutable_mask:bool array -> + ?directive:string -> return_unit:bool -> async:bool -> one_unit_arg:bool -> - ?directive:string -> J.ident list -> J.block -> t diff --git a/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js b/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js index 447f327d1d..da238ff4d4 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js @@ -2,9 +2,7 @@ function Make($$Error) { - let notify = function (x) { - return $$Error.notification(x); - }; + let notify = x => $$Error.notification(x); return { notify: notify }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js index 48388edd95..1a0a3edf28 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js @@ -6,35 +6,25 @@ import * as ImportHookDefault from "./ImportHookDefault.res.js"; function Hooks(Props) { let vehicle = Props.vehicle; - let match = React.useState(function () { - return 0; - }); + let match = React.useState(() => 0); let setCount = match[1]; let count = match[0]; return React.createElement("div", undefined, React.createElement("p", undefined, "Hooks example " + (vehicle.name + (" clicked " + (String(count) + " times")))), React.createElement("button", { - onClick: (function (param) { - setCount(function (param) { - return count + 1 | 0; - }); - }) + onClick: param => setCount(param => count + 1 | 0) }, "Click me"), React.createElement(ImportHooks.make, { person: { name: "Mary", age: 71 }, children: null, - renderMe: (function (x) { - return x.randomString; - }) + renderMe: x => x.randomString }, "child1", "child2"), React.createElement(ImportHookDefault.make, { person: { name: "DefaultImport", age: 42 }, children: null, - renderMe: (function (x) { - return x.randomString; - }) + renderMe: x => x.randomString }, "child1", "child2")); } @@ -114,7 +104,7 @@ let WithRename = { }; function makeWithRef(vehicle) { - return function (ref) { + return ref => { if (ref == null) { return null; } else { @@ -133,15 +123,11 @@ let WithRef = { makeWithRef: Hooks$WithRef$makeWithRef }; -let testForwardRef = React.forwardRef(function (x, y) { - return makeWithRef(x.vehicle)(y); -}); +let testForwardRef = React.forwardRef((x, y) => makeWithRef(x.vehicle)(y)); -let input = React.forwardRef(function (r, ref) { - return React.createElement("div", { - ref: ref - }, r.x); -}); +let input = React.forwardRef((r, ref) => React.createElement("div", { + ref: ref +}, r.x)); let ForwardRef = { input: input diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js index 8f0f909427..d056c1477f 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js @@ -51,17 +51,13 @@ let rangeBy = Belt_Array.rangeBy; let makeByU = Belt_Array.makeByU; function makeBy(c, f) { - return Belt_Array.makeBy(c, (function (x) { - return f(x); - })); + return Belt_Array.makeBy(c, x => f(x)); } let makeByAndShuffleU = Belt_Array.makeByAndShuffleU; function makeByAndShuffle(c, f) { - return Belt_Array.makeByAndShuffle(c, (function (x) { - return f(x); - })); + return Belt_Array.makeByAndShuffle(c, x => f(x)); } let zip = Belt_Array.zip; @@ -69,9 +65,7 @@ let zip = Belt_Array.zip; let zipByU = Belt_Array.zipByU; function zipBy(a1, a2, f) { - return Belt_Array.zipBy(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.zipBy(a1, a2, (x, y) => f(x, y)); } let unzip = Belt_Array.unzip; @@ -91,129 +85,97 @@ function copy(a) { let forEachU = Belt_Array.forEachU; function forEach(a, f) { - Belt_Array.forEach(a, (function (x) { - f(x); - })); + Belt_Array.forEach(a, x => f(x)); } let mapU = Belt_Array.mapU; function map(a, f) { - return Belt_Array.map(a, (function (x) { - return f(x); - })); + return Belt_Array.map(a, x => f(x)); } let keepWithIndexU = Belt_Array.keepWithIndexU; function keepWithIndex(a, f) { - return Belt_Array.keepWithIndex(a, (function (x, y) { - return f(x, y); - })); + return Belt_Array.keepWithIndex(a, (x, y) => f(x, y)); } let keepMapU = Belt_Array.keepMapU; function keepMap(a, f) { - return Belt_Array.keepMap(a, (function (x) { - return f(x); - })); + return Belt_Array.keepMap(a, x => f(x)); } let forEachWithIndexU = Belt_Array.forEachWithIndexU; function forEachWithIndex(a, f) { - Belt_Array.forEachWithIndex(a, (function (x, y) { - f(x, y); - })); + Belt_Array.forEachWithIndex(a, (x, y) => f(x, y)); } let mapWithIndexU = Belt_Array.mapWithIndexU; function mapWithIndex(a, f) { - return Belt_Array.mapWithIndex(a, (function (x, y) { - return f(x, y); - })); + return Belt_Array.mapWithIndex(a, (x, y) => f(x, y)); } let partitionU = Belt_Array.partitionU; function partition(a, f) { - return Belt_Array.partition(a, (function (x) { - return f(x); - })); + return Belt_Array.partition(a, x => f(x)); } let reduceU = Belt_Array.reduceU; function reduce(a, b, f) { - return Belt_Array.reduce(a, b, (function (x, y) { - return f(x, y); - })); + return Belt_Array.reduce(a, b, (x, y) => f(x, y)); } let reduceReverseU = Belt_Array.reduceReverseU; function reduceReverse(a, b, f) { - return Belt_Array.reduceReverse(a, b, (function (x, y) { - return f(x, y); - })); + return Belt_Array.reduceReverse(a, b, (x, y) => f(x, y)); } let reduceReverse2U = Belt_Array.reduceReverse2U; function reduceReverse2(a1, a2, c, f) { - return Belt_Array.reduceReverse2(a1, a2, c, (function (x, y, z) { - return f(x, y, z); - })); + return Belt_Array.reduceReverse2(a1, a2, c, (x, y, z) => f(x, y, z)); } let someU = Belt_Array.someU; function some(a, f) { - return Belt_Array.some(a, (function (x) { - return f(x); - })); + return Belt_Array.some(a, x => f(x)); } let everyU = Belt_Array.everyU; function every(a, f) { - return Belt_Array.every(a, (function (x) { - return f(x); - })); + return Belt_Array.every(a, x => f(x)); } let every2U = Belt_Array.every2U; function every2(a1, a2, f) { - return Belt_Array.every2(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.every2(a1, a2, (x, y) => f(x, y)); } let some2U = Belt_Array.some2U; function some2(a1, a2, f) { - return Belt_Array.some2(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.some2(a1, a2, (x, y) => f(x, y)); } let cmpU = Belt_Array.cmpU; function cmp(a1, a2, f) { - return Belt_Array.cmp(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.cmp(a1, a2, (x, y) => f(x, y)); } let eqU = Belt_Array.eqU; function eq(a1, a2, f) { - return Belt_Array.eq(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.eq(a1, a2, (x, y) => f(x, y)); } let $$Array$1 = { diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js index 84f321dd72..6e617f004d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js @@ -51,9 +51,7 @@ function higherOrder(prim) { return ImportJsValueGen$1.higherOrder(prim); } -let returnedFromHigherOrder = ImportJsValueGen$1.higherOrder(function (prim0, prim1) { - return prim0 + prim1 | 0; -}); +let returnedFromHigherOrder = ImportJsValueGen$1.higherOrder((prim0, prim1) => prim0 + prim1 | 0); function convertVariant(prim) { return ImportJsValueGen$1.convertVariant(prim); diff --git a/jscomp/gentype_tests/typescript-react-example/src/Records.res.js b/jscomp/gentype_tests/typescript-react-example/src/Records.res.js index 36bff49322..8ad1df10ae 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Records.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Records.res.js @@ -6,9 +6,7 @@ import * as Belt_Option from "rescript/lib/es6/belt_Option.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; function computeArea(param) { - return Math.imul(Math.imul(param.x, param.y), Belt_Option.mapWithDefault(param.z, 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(param.x, param.y), Belt_Option.mapWithDefault(param.z, 1, n => n)); } function coord2d(x, y) { @@ -22,30 +20,20 @@ function coord2d(x, y) { let getOpt = Belt_Option.mapWithDefault; function findAddress(business) { - return Belt_Option.mapWithDefault(business.address, /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; + return Belt_Option.mapWithDefault(business.address, /* [] */0, a => ({ + hd: a, + tl: /* [] */0 })); } function findAllAddresses(businesses) { - return Belt_List.toArray(Belt_List.flatten(Belt_List.fromArray(Belt_Array.map(businesses, (function (business) { - return Belt_List.concat(Belt_Option.mapWithDefault(business.address, /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; - })), Belt_Option.mapWithDefault(business.owner, /* [] */0, (function (p) { - return Belt_Option.mapWithDefault(p.address, /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; - })); - }))); - }))))); + return Belt_List.toArray(Belt_List.flatten(Belt_List.fromArray(Belt_Array.map(businesses, business => Belt_List.concat(Belt_Option.mapWithDefault(business.address, /* [] */0, a => ({ + hd: a, + tl: /* [] */0 + })), Belt_Option.mapWithDefault(business.owner, /* [] */0, p => Belt_Option.mapWithDefault(p.address, /* [] */0, a => ({ + hd: a, + tl: /* [] */0 + })))))))); } function getPayload(param) { @@ -75,11 +63,9 @@ function getPayloadRecordPlusOne(param) { } function findAddress2(business) { - return Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(business.address2), /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; + return Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(business.address2), /* [] */0, a => ({ + hd: a, + tl: /* [] */0 })); } @@ -94,15 +80,11 @@ let someBusiness2 = { }; function computeArea3(o) { - return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(o.z), 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(o.z), 1, n => n)); } function computeArea4(o) { - return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(o.z, 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(o.z, 1, n => n)); } function testMyRec(x) { diff --git a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js index 7137896d8b..153c834adc 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js @@ -5,10 +5,8 @@ import * as Js_promise from "rescript/lib/es6/js_promise.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; function convert(p) { - return Js_promise.then_((function (param) { - return Promise.resolve({ - result: param.s - }); + return Js_promise.then_(param => Promise.resolve({ + result: param.s }), p); } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js index 8420bac6b1..e962e18f3d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js @@ -38,21 +38,21 @@ function sumU(n, m) { } function sumU2(n) { - return function (m) { + return m => { console.log("sumU2 2nd arg", m, "result", n + m | 0); }; } function sumCurried(n) { console.log("sumCurried 1st arg", n); - return function (m) { + return m => { console.log("sumCurried 2nd arg", m, "result", n + m | 0); }; } function sumLblCurried(s, n) { console.log(s, "sumLblCurried 1st arg", n); - return function (m) { + return m => { console.log("sumLblCurried 2nd arg", m, "result", n + m | 0); }; } diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js b/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js index 41de58327c..71b9cb5d02 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js @@ -7,15 +7,11 @@ function testTuple(param) { } function computeArea(param) { - return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, n => n)); } function computeAreaWithIdent(param) { - return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, n => n)); } function computeAreaNoConverters(param) { diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js index f11c6c55cc..11917c6506 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js @@ -57,9 +57,7 @@ function testInstantiateTypeParameter(x) { let currentTime = new Date(); -let optFunction = (function () { - return 3; -}); +let optFunction = () => 3; let ObjectId = {}; diff --git a/jscomp/test/Import.js b/jscomp/test/Import.js index b094a389db..56c5384054 100644 --- a/jscomp/test/Import.js +++ b/jscomp/test/Import.js @@ -3,17 +3,11 @@ async function eachIntAsync(list, f) { - return (await import("../../lib/js/belt_List.js").then(function (m) { - return m.forEach; - }))(list, f); + return (await import("../../lib/js/belt_List.js").then(m => m.forEach))(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 import("../../lib/js/belt_List.js").then(m => m.forEach).then(each => Promise.resolve(each(list, f))); } eachIntLazy({ @@ -25,9 +19,9 @@ eachIntLazy({ tl: /* [] */0 } } -}, (function (n) { +}, n => { console.log("lazy", n); -})); +}); eachIntAsync({ hd: 1, @@ -38,9 +32,9 @@ eachIntAsync({ tl: /* [] */0 } } -}, (function (n) { +}, n => { console.log("async", n); -})); +}); let beltAsModule = await import("../../lib/js/belt_List.js"); diff --git a/jscomp/test/PartialApplicationNoRuntimeCurry.js b/jscomp/test/PartialApplicationNoRuntimeCurry.js index 89cd1695ef..1a69368f5f 100644 --- a/jscomp/test/PartialApplicationNoRuntimeCurry.js +++ b/jscomp/test/PartialApplicationNoRuntimeCurry.js @@ -3,16 +3,12 @@ function add(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } function f(u) { let f$1 = add(u); - return function (extra) { - return f$1(1, extra); - }; + return extra => f$1(1, extra); } exports.add = add; diff --git a/jscomp/test/SafePromises.js b/jscomp/test/SafePromises.js index 73ff7b3c4e..91227a4005 100644 --- a/jscomp/test/SafePromises.js +++ b/jscomp/test/SafePromises.js @@ -5,16 +5,12 @@ let Js_promise2 = require("../../lib/js/js_promise2.js"); async function nestedPromise(xxx) { let xx = await xxx; - Js_promise2.then(xx, (function (x) { - return Promise.resolve((console.log("Promise2.then", x), undefined)); - })); - Js_promise2.$$catch(xx, (function (x) { + Js_promise2.then(xx, x => Promise.resolve((console.log("Promise2.then", x), undefined))); + Js_promise2.$$catch(xx, x => { console.log("Promise2.catch_", x); return Promise.resolve(0); - })); - xx.then(function (x) { - return Promise.resolve((console.log("Promise.then_", x), undefined)); }); + xx.then(x => Promise.resolve((console.log("Promise.then_", x), undefined))); } async function create(x) { diff --git a/jscomp/test/UncurriedAlways.js b/jscomp/test/UncurriedAlways.js index 4b284ff2ca..601d3bfe3a 100644 --- a/jscomp/test/UncurriedAlways.js +++ b/jscomp/test/UncurriedAlways.js @@ -20,9 +20,7 @@ let a = 7; console.log(a); -[1].map(function (x) { - return x + 1 | 0; -}); +[1].map(x => x + 1 | 0); function ptl(extra) { return 10 + extra | 0; diff --git a/jscomp/test/UncurriedExternals.js b/jscomp/test/UncurriedExternals.js index c6928253d2..5ec20d4073 100644 --- a/jscomp/test/UncurriedExternals.js +++ b/jscomp/test/UncurriedExternals.js @@ -14,9 +14,7 @@ function dd() { let h = sum(1.0, 2.0); let M = { - sum: (function (prim0, prim1) { - return sum(prim0, prim1); - }) + sum: (prim0, prim1) => sum(prim0, prim1) }; let hh = M.sum(1.0, 2.0); @@ -36,22 +34,20 @@ let te = { let tcr = {}; function tsiC(c) { - c.increment = (function (amount) { + c.increment = function (amount) { let me = this ; console.log(me); - }); + }; } function tsiU(c) { - c.increment = (function (amount) { + c.increment = function (amount) { let me = this ; console.log(me); - }); + }; } -let match = React.useState(function () { - return 3; -}); +let match = React.useState(() => 3); let StandardNotation_get = match[0]; @@ -75,9 +71,7 @@ let StandardNotation = { function methodWithAsync() { let $$this = this ; - return async function (arg) { - return $$this + arg | 0; - }; + return async arg => $$this + arg | 0; } exports.StandardNotation = StandardNotation; diff --git a/jscomp/test/UntaggedVariants.js b/jscomp/test/UntaggedVariants.js index dcb171e280..6dab75df61 100644 --- a/jscomp/test/UntaggedVariants.js +++ b/jscomp/test/UntaggedVariants.js @@ -367,9 +367,7 @@ function classify$9(v) { } } -let ff = (function (x) { - return x + 1 | 0; -}); +let ff = x => x + 1 | 0; let TestFunctionCase = { classify: classify$9, @@ -488,9 +486,7 @@ async function classify$10(a) { return; } else { if (Array.isArray(a)) { - console.log(Belt_Array.joinWith(a, "-", (function (x) { - return x; - }))); + console.log(Belt_Array.joinWith(a, "-", x => x)); return; } if (a instanceof Promise) { @@ -514,9 +510,7 @@ let Arr = { async function classifyAll(t) { if (Array.isArray(t)) { - console.log(Belt_Array.joinWith(t, "-", (function (x) { - return x; - }))); + console.log(Belt_Array.joinWith(t, "-", x => x)); return; } if (t instanceof Promise) { diff --git a/jscomp/test/a_filename_test.js b/jscomp/test/a_filename_test.js index 5fe5fd915f..1c8fda7a7e 100644 --- a/jscomp/test/a_filename_test.js +++ b/jscomp/test/a_filename_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/a_list_test.js b/jscomp/test/a_list_test.js index 824e4783a2..7bef3fdfe5 100644 --- a/jscomp/test/a_list_test.js +++ b/jscomp/test/a_list_test.js @@ -6,98 +6,92 @@ let Ext_list_test = require("./ext_list_test.js"); let suites_0 = [ "drop", - (function (param) { - return { - TAG: "Eq", - _0: Ext_list_test.drop(3, { - hd: 0, + param => ({ + TAG: "Eq", + _0: Ext_list_test.drop(3, { + hd: 0, + tl: { + hd: 1, tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } + hd: 2, + tl: /* [] */0 } - }), - _1: /* [] */0 - }; + } + }), + _1: /* [] */0 }) ]; let suites_1 = { hd: [ "drop1", - (function (param) { - return { - TAG: "Eq", - _0: Ext_list_test.drop(2, { - hd: 0, + param => ({ + TAG: "Eq", + _0: Ext_list_test.drop(2, { + hd: 0, + tl: { + hd: 1, tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } + hd: 2, + tl: /* [] */0 } - }), - _1: { - hd: 2, - tl: /* [] */0 } - }; + }), + _1: { + hd: 2, + tl: /* [] */0 + } }) ], tl: { hd: [ "flat_map", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: 0, + tl: { hd: 0, tl: { - hd: 0, + hd: 1, tl: { hd: 1, tl: { - hd: 1, - tl: { - hd: 0, - tl: /* [] */0 - } + hd: 0, + tl: /* [] */0 } } } - }, - _1: Ext_list_test.flat_map((function (x) { - if (x % 2 === 0) { - return { - hd: 0, - tl: /* [] */0 - }; - } else { - return { + } + }, + _1: Ext_list_test.flat_map(x => { + if (x % 2 === 0) { + return { + hd: 0, + tl: /* [] */0 + }; + } else { + return { + hd: 1, + tl: { hd: 1, - tl: { - hd: 1, - tl: /* [] */0 - } - }; - } - }), { + tl: /* [] */0 + } + }; + } + }, { + hd: 0, + tl: { hd: 0, tl: { - hd: 0, + hd: 3, tl: { - hd: 3, - tl: { - hd: 0, - tl: /* [] */0 - } + hd: 0, + tl: /* [] */0 } } - }) - }; + } + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/a_string_test.js b/jscomp/test/a_string_test.js index 881f69d6a4..904650af26 100644 --- a/jscomp/test/a_string_test.js +++ b/jscomp/test/a_string_test.js @@ -7,101 +7,89 @@ let Ext_string_test = require("./ext_string_test.js"); let suites_0 = [ "split", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(true, "hihi", /* 'i' */105), - _1: { + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(true, "hihi", /* 'i' */105), + _1: { + hd: "h", + tl: { hd: "h", tl: { - hd: "h", - tl: { - hd: "", - tl: /* [] */0 - } + hd: "", + tl: /* [] */0 } } - }; + } }) ]; let suites_1 = { hd: [ "split_non_empty", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(undefined, "hihi", /* 'i' */105), - _1: { + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(undefined, "hihi", /* 'i' */105), + _1: { + hd: "h", + tl: { hd: "h", - tl: { - hd: "h", - tl: /* [] */0 - } + tl: /* [] */0 } - }; + } }) ], tl: { hd: [ "split_empty", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(true, "", /* 'i' */105), - _1: /* [] */0 - }; + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(true, "", /* 'i' */105), + _1: /* [] */0 }) ], tl: { hd: [ "split_normal", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(true, "h i i", /* ' ' */32), - _1: { - hd: "h", + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(true, "h i i", /* ' ' */32), + _1: { + hd: "h", + tl: { + hd: "i", tl: { hd: "i", - tl: { - hd: "i", - tl: /* [] */0 - } + tl: /* [] */0 } } - }; + } }) ], tl: { hd: [ "split_by", - (function (param) { - return { - TAG: "Eq", - _0: List.filter((function (s) { - return s !== ""; - }), Ext_string_test.split_by(undefined, (function (x) { - if (x === /* ' ' */32) { - return true; - } else { - return x === /* '\t' */9; - } - }), "h hgso hgso \t hi")), - _1: { - hd: "h", + param => ({ + TAG: "Eq", + _0: List.filter(s => s !== "", Ext_string_test.split_by(undefined, x => { + if (x === /* ' ' */32) { + return true; + } else { + return x === /* '\t' */9; + } + }, "h hgso hgso \t hi")), + _1: { + hd: "h", + tl: { + hd: "hgso", tl: { hd: "hgso", tl: { - hd: "hgso", - tl: { - hd: "hi", - tl: /* [] */0 - } + hd: "hi", + tl: /* [] */0 } } } - }; + } }) ], tl: /* [] */0 diff --git a/jscomp/test/and_or_tailcall_test.js b/jscomp/test/and_or_tailcall_test.js index fad105c1a9..19a442c44f 100644 --- a/jscomp/test/and_or_tailcall_test.js +++ b/jscomp/test/and_or_tailcall_test.js @@ -33,24 +33,20 @@ function or_f(b, x, _n) { let suites_0 = [ "and_tail", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: f(true, 1, 0) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: f(true, 1, 0) }) ]; let suites_1 = { hd: [ "or_tail", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: or_f(false, 1, 0) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: or_f(false, 1, 0) }) ], tl: /* [] */0 diff --git a/jscomp/test/ari_regress_test.js b/jscomp/test/ari_regress_test.js index da79d0742c..20043923ee 100644 --- a/jscomp/test/ari_regress_test.js +++ b/jscomp/test/ari_regress_test.js @@ -12,9 +12,7 @@ let h = { function g1(x, y) { let u = x + y | 0; h.contents = h.contents + 1 | 0; - return function (xx, yy) { - return (xx + yy | 0) + u | 0; - }; + return (xx, yy) => (xx + yy | 0) + u | 0; } let u = 8; @@ -27,46 +25,38 @@ function v(__x) { let suites_0 = [ "curry", - (function (param) { - return { - TAG: "Eq", - _0: g, - _1: 7 - }; + param => ({ + TAG: "Eq", + _0: g, + _1: 7 }) ]; let suites_1 = { hd: [ "curry2", - (function (param) { - return { - TAG: "Eq", - _0: 14, - _1: (v(1), v(1)) - }; + param => ({ + TAG: "Eq", + _0: 14, + _1: (v(1), v(1)) }) ], tl: { hd: [ "curry3", - (function (param) { - return { - TAG: "Eq", - _0: x, - _1: 14 - }; + param => ({ + TAG: "Eq", + _0: x, + _1: 14 }) ], tl: { hd: [ "File \"ari_regress_test.res\", line 35, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: h.contents, - _1: 2 - }; + param => ({ + TAG: "Eq", + _0: h.contents, + _1: 2 }) ], tl: /* [] */0 diff --git a/jscomp/test/arith_parser.js b/jscomp/test/arith_parser.js index 4fb23e6ba0..7520e20b28 100644 --- a/jscomp/test/arith_parser.js +++ b/jscomp/test/arith_parser.js @@ -139,32 +139,30 @@ let yynames_block = "\ "; let yyact = [ - (function (param) { + param => { throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", _1: "parser" } }); - }), - (function (__caml_parser_env) { - return Parsing.peek_val(__caml_parser_env, 1); - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => Parsing.peek_val(__caml_parser_env, 1), + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 0); return { TAG: "Numeral", _0: _1 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 0); return { TAG: "Variable", _0: _1 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -172,8 +170,8 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -181,8 +179,8 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -190,8 +188,8 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -199,25 +197,23 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _2 = Parsing.peek_val(__caml_parser_env, 0); return { TAG: "Negate", _0: _2 }; - }), - (function (__caml_parser_env) { - return Parsing.peek_val(__caml_parser_env, 1); - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => Parsing.peek_val(__caml_parser_env, 1), + __caml_parser_env => { throw new Error(Parsing.YYexit, { cause: { RE_EXN_ID: Parsing.YYexit, _1: Parsing.peek_val(__caml_parser_env, 0) } }); - }) + } ]; let yytables = { diff --git a/jscomp/test/arity_deopt.js b/jscomp/test/arity_deopt.js index 72352a0e4b..c742f2512d 100644 --- a/jscomp/test/arity_deopt.js +++ b/jscomp/test/arity_deopt.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -33,21 +31,15 @@ function f0(x, y, z) { } function f1(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } function f2(x, y) { - return function (z) { - return (x + y | 0) + z | 0; - }; + return z => (x + y | 0) + z | 0; } function f3(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } eq("File \"arity_deopt.res\", line 47, characters 11-18", 6, 6); diff --git a/jscomp/test/arity_infer.js b/jscomp/test/arity_infer.js index 68084b77bd..18da9fe57b 100644 --- a/jscomp/test/arity_infer.js +++ b/jscomp/test/arity_infer.js @@ -5,9 +5,7 @@ function f0(x) { let tmp; if (x > 3) { - tmp = (function (x) { - return x + 1 | 0; - }); + tmp = x => x + 1 | 0; } else { throw new Error("Not_found", { cause: { @@ -31,24 +29,16 @@ function f3(x) { let tmp; switch (x) { case 0 : - tmp = (function (x) { - return x + 1 | 0; - }); + tmp = x => x + 1 | 0; break; case 1 : - tmp = (function (x) { - return x + 2 | 0; - }); + tmp = x => x + 2 | 0; break; case 2 : - tmp = (function (x) { - return x + 3 | 0; - }); + tmp = x => x + 3 | 0; break; case 3 : - tmp = (function (x) { - return x + 4 | 0; - }); + tmp = x => x + 4 | 0; break; default: throw new Error("Not_found", { diff --git a/jscomp/test/array_data_util.js b/jscomp/test/array_data_util.js index cc98eaa8a8..98acf7b5e8 100644 --- a/jscomp/test/array_data_util.js +++ b/jscomp/test/array_data_util.js @@ -4,15 +4,11 @@ let Belt_Array = require("../../lib/js/belt_Array.js"); function range(i, j) { - return Belt_Array.makeBy((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); + return Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); } function randomRange(i, j) { - let v = Belt_Array.makeBy((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); + let v = Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); Belt_Array.shuffleInPlace(v); return v; } diff --git a/jscomp/test/array_subtle_test.js b/jscomp/test/array_subtle_test.js index 20c655d7d5..4233f2ef8d 100644 --- a/jscomp/test/array_subtle_test.js +++ b/jscomp/test/array_subtle_test.js @@ -19,12 +19,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/array_test.js b/jscomp/test/array_test.js index 3045800bd1..f84793a3f5 100644 --- a/jscomp/test/array_test.js +++ b/jscomp/test/array_test.js @@ -58,38 +58,30 @@ function is_sorted(x) { let array_suites_0 = [ "init", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.init(5, (function (x) { - return x; - })), - _1: [ - 0, - 1, - 2, - 3, - 4 - ] - }; + param => ({ + TAG: "Eq", + _0: $$Array.init(5, x => x), + _1: [ + 0, + 1, + 2, + 3, + 4 + ] }) ]; let array_suites_1 = { hd: [ "toList", - (function (param) { - let aux = function (xs) { - return List.fold_left((function (acc, param) { - return { - hd: [ - $$Array.to_list(param[0]), - param[1] - ], - tl: acc - }; - }), /* [] */0, xs); - }; + param => { + let aux = xs => List.fold_left((acc, param) => ({ + hd: [ + $$Array.to_list(param[0]), + param[1] + ], + tl: acc + }), /* [] */0, xs); let match = List.split(aux({ hd: [ [], @@ -102,98 +94,86 @@ let array_suites_1 = { _0: match[0], _1: match[1] }; - }) + } ], tl: { hd: [ "concat", - (function (param) { - return { - TAG: "Eq", - _0: [ + param => ({ + TAG: "Eq", + _0: [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + _1: Caml_array.concat({ + hd: [ 0, 1, - 2, - 3, - 4, - 5 + 2 ], - _1: Caml_array.concat({ + tl: { hd: [ - 0, - 1, - 2 + 3, + 4 ], tl: { - hd: [ - 3, - 4 - ], + hd: [], tl: { - hd: [], - tl: { - hd: [5], - tl: /* [] */0 - } + hd: [5], + tl: /* [] */0 } } - }) - }; + } + }) }) ], tl: { hd: [ "make", - (function (param) { - return { - TAG: "Eq", - _0: [ - Caml_array.make(100, /* 'a' */97), - Caml_array.make_float(100) - ], - _1: [ - $$Array.init(100, (function (param) { - return /* 'a' */97; - })), - $$Array.init(100, (function (param) { - return 0; - })) - ] - }; + param => ({ + TAG: "Eq", + _0: [ + Caml_array.make(100, /* 'a' */97), + Caml_array.make_float(100) + ], + _1: [ + $$Array.init(100, param => /* 'a' */97), + $$Array.init(100, param => 0) + ] }) ], tl: { hd: [ "sub", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.sub([ - 0, - 1, - 2, - 3, - 4 - ], 2, 2), - _1: [ - 2, - 3 - ] - }; + param => ({ + TAG: "Eq", + _0: $$Array.sub([ + 0, + 1, + 2, + 3, + 4 + ], 2, 2), + _1: [ + 2, + 3 + ] }) ], tl: { hd: [ "blit", - (function (param) { + param => { let u = [ 100, 0, 0 ]; - let v = $$Array.init(3, (function (x) { - return (x << 1); - })); + let v = $$Array.init(3, x => (x << 1)); $$Array.blit(v, 1, u, 1, 2); return { TAG: "Eq", @@ -214,15 +194,13 @@ let array_suites_1 = { u ] }; - }) + } ], tl: { hd: [ "File \"array_test.res\", line 75, characters 8-15", - (function (param) { - let a0 = $$Array.init(100, (function (i) { - return (i << 0); - })); + param => { + let a0 = $$Array.init(100, i => (i << 0)); $$Array.blit(a0, 10, a0, 5, 20); return { TAG: "Eq", @@ -252,19 +230,15 @@ let array_suites_1 = { 26, 27, 28 - ], (function (prim0, prim1) { - return prim0 === prim1; - })) + ], (prim0, prim1) => prim0 === prim1) }; - }) + } ], tl: { hd: [ "File \"array_test.res\", line 118, characters 8-15", - (function (param) { - let a0 = $$Array.init(100, (function (i) { - return (i << 0); - })); + param => { + let a0 = $$Array.init(100, i => (i << 0)); $$Array.blit(a0, 5, a0, 10, 20); return { TAG: "Eq", @@ -296,30 +270,26 @@ let array_suites_1 = { 18, 19, 20 - ], (function (prim0, prim1) { - return prim0 === prim1; - })) + ], (prim0, prim1) => prim0 === prim1) }; - }) + } ], tl: { hd: [ "make", - (function (param) { - return { - TAG: "Eq", - _0: Caml_array.make(2, 1), - _1: [ - 1, - 1 - ] - }; + param => ({ + TAG: "Eq", + _0: Caml_array.make(2, 1), + _1: [ + 1, + 1 + ] }) ], tl: { hd: [ "sort", - (function (param) { + param => { let u = [ 3, 0, @@ -335,22 +305,20 @@ let array_suites_1 = { ], u), _1: true }; - }) + } ], tl: { hd: [ "sort_large", - (function (param) { - let v = $$Array.init(4, (function (i) { - return i % 17; - })); + param => { + let v = $$Array.init(4, i => i % 17); $$Array.sort(Caml.int_compare, v); return { TAG: "Eq", _0: true, _1: is_sorted(v) }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/ast_abstract_test.js b/jscomp/test/ast_abstract_test.js index 27d20ddd01..c8f1e54872 100644 --- a/jscomp/test/ast_abstract_test.js +++ b/jscomp/test/ast_abstract_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/async_await.js b/jscomp/test/async_await.js index ae29f57668..3bdca2ae5d 100644 --- a/jscomp/test/async_await.js +++ b/jscomp/test/async_await.js @@ -12,9 +12,7 @@ async function useNext() { } function Make(I) { - let get = async function (key) { - return await I.get(key); - }; + let get = async key => await I.get(key); return { get: get }; diff --git a/jscomp/test/async_inline.js b/jscomp/test/async_inline.js index e08f9e8df5..247e22bdff 100644 --- a/jscomp/test/async_inline.js +++ b/jscomp/test/async_inline.js @@ -10,17 +10,17 @@ async function willBeInlined() { let inlined = willBeInlined(); function wrapSomethingAsync() { - ((async function (param) { - let test = await Promise.resolve("Test"); - console.log(test); - })(777)); + (async param => { + let test = await Promise.resolve("Test"); + console.log(test); + })(777); } function wrapSomethingAsync2() { - ((async function () { - let test = await Promise.resolve("Test"); - console.log(test); - })()); + (async () => { + let test = await Promise.resolve("Test"); + console.log(test); + })(); } async function doSomethingAsync(someAsyncFunction) { @@ -64,21 +64,15 @@ let tui = 3; let tuia = uncurriedIdAsync(3); function nested1() { - return async function (y) { - return await y; - }; + return async y => await y; } async function nested2() { - return async function (y) { - return await y; - }; + return async y => await y; } function onSubmit() { - return React.useCallback(async function (b) { - return await b; - }); + return React.useCallback(async b => await b); } exports.willBeInlined = willBeInlined; diff --git a/jscomp/test/async_inside_loop.js b/jscomp/test/async_inside_loop.js index 0f1d7d0fe1..889065bf7e 100644 --- a/jscomp/test/async_inside_loop.js +++ b/jscomp/test/async_inside_loop.js @@ -4,7 +4,7 @@ async function topLevelAsyncFunction() { for (let innerScopeVal = 0; innerScopeVal <= 3; ++innerScopeVal) { - let asyncClosureAccessingScopedVal = async function () { + let asyncClosureAccessingScopedVal = async () => { console.log("Accessing scoped var inside loop", innerScopeVal); return await Promise.resolve(); }; diff --git a/jscomp/test/attr_test.js b/jscomp/test/attr_test.js index 2d54972a0b..646d4e7de1 100644 --- a/jscomp/test/attr_test.js +++ b/jscomp/test/attr_test.js @@ -15,9 +15,9 @@ function max2(x, y) { let hh = 1 + 2; function f(x) { - des(x, (function () { + des(x, () => { console.log("hei"); - })); + }); } exports.u = u; diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index f408c2c3d7..a7b4f929b5 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -58,7 +58,7 @@ function resize(newSize) { let arr = htab.contents; let newSz_1 = newSize - 1 | 0; let newArr = Caml_array.make(newSize, /* [] */0); - let copyBucket = function (_bucket) { + let copyBucket = _bucket => { while (true) { let bucket = _bucket; if (!bucket) { @@ -334,14 +334,14 @@ function xor(n1, n2) { } function hwb(n) { - let h = function (i, j) { + let h = (i, j) => { if (i === j) { return mkNode("Zero", i, "One"); } else { 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) { + let g = (i, j) => { if (i === j) { return mkNode("Zero", i, "One"); } else { diff --git a/jscomp/test/belt_float_ntest.js b/jscomp/test/belt_float_ntest.js index 5513ffad54..701b894b4c 100644 --- a/jscomp/test/belt_float_ntest.js +++ b/jscomp/test/belt_float_ntest.js @@ -9,20 +9,20 @@ function eq(loc, a, b) { Nodeassert.strictEqual(a, b, loc); } -Nodetest.describe("Belt.Float", (function () { - Nodetest.test("fromInt", (function () { +Nodetest.describe("Belt.Float", () => { + Nodetest.test("fromInt", () => { eq("File \"belt_float_ntest.res\", line 9, characters 7-14", 1, 1.0); eq("File \"belt_float_ntest.res\", line 10, characters 7-14", -1, -1.0); - })); - Nodetest.test("toInt", (function () { + }); + Nodetest.test("toInt", () => { eq("File \"belt_float_ntest.res\", line 14, characters 7-14", 1, 1); eq("File \"belt_float_ntest.res\", line 15, characters 7-14", 1, 1); eq("File \"belt_float_ntest.res\", line 16, characters 7-14", 1, 1); eq("File \"belt_float_ntest.res\", line 17, characters 7-14", -1, -1); eq("File \"belt_float_ntest.res\", line 18, characters 7-14", -1, -1); eq("File \"belt_float_ntest.res\", line 19, characters 7-14", -1, -1); - })); - Nodetest.test("fromString", (function () { + }); + Nodetest.test("fromString", () => { eq("File \"belt_float_ntest.res\", line 23, characters 7-14", Belt_Float.fromString("1"), 1.0); eq("File \"belt_float_ntest.res\", line 24, characters 7-14", Belt_Float.fromString("-1"), -1.0); eq("File \"belt_float_ntest.res\", line 25, characters 7-14", Belt_Float.fromString("1.7"), 1.7); @@ -30,19 +30,19 @@ Nodetest.describe("Belt.Float", (function () { eq("File \"belt_float_ntest.res\", line 27, characters 7-14", Belt_Float.fromString("-1.5"), -1.5); eq("File \"belt_float_ntest.res\", line 28, characters 7-14", Belt_Float.fromString("-1.7"), -1.7); eq("File \"belt_float_ntest.res\", line 29, characters 7-14", Belt_Float.fromString("not a float"), undefined); - })); - Nodetest.test("toString", (function () { + }); + Nodetest.test("toString", () => { eq("File \"belt_float_ntest.res\", line 33, characters 7-14", String(1.0), "1"); eq("File \"belt_float_ntest.res\", line 34, characters 7-14", String(-1.0), "-1"); eq("File \"belt_float_ntest.res\", line 35, characters 7-14", String(-1.5), "-1.5"); - })); - Nodetest.test("operators", (function () { + }); + Nodetest.test("operators", () => { eq("File \"belt_float_ntest.res\", line 40, characters 7-14", 2.0 + 3.0, 5.0); eq("File \"belt_float_ntest.res\", line 41, characters 7-14", 2.0 - 3.0, -1.0); eq("File \"belt_float_ntest.res\", line 42, characters 7-14", 2.0 * 3.0, 6.0); eq("File \"belt_float_ntest.res\", line 43, characters 7-14", 3.0 / 2.0, 1.5); - })); -})); + }); +}); let F; diff --git a/jscomp/test/belt_int_ntest.js b/jscomp/test/belt_int_ntest.js index 664dfa5947..823f399f5a 100644 --- a/jscomp/test/belt_int_ntest.js +++ b/jscomp/test/belt_int_ntest.js @@ -9,20 +9,20 @@ function eq(loc, a, b) { Nodeassert.strictEqual(a, b, loc); } -Nodetest.describe("Belt.Int", (function () { - Nodetest.test("toFloat", (function () { +Nodetest.describe("Belt.Int", () => { + Nodetest.test("toFloat", () => { eq("File \"belt_int_ntest.res\", line 9, characters 7-14", 1, 1.0); eq("File \"belt_int_ntest.res\", line 10, characters 7-14", -1, -1.0); - })); - Nodetest.test("fromFloat", (function () { + }); + Nodetest.test("fromFloat", () => { eq("File \"belt_int_ntest.res\", line 14, characters 7-14", 1, 1); eq("File \"belt_int_ntest.res\", line 15, characters 7-14", 1, 1); eq("File \"belt_int_ntest.res\", line 16, characters 7-14", 1, 1); eq("File \"belt_int_ntest.res\", line 17, characters 7-14", -1, -1); eq("File \"belt_int_ntest.res\", line 18, characters 7-14", -1, -1); eq("File \"belt_int_ntest.res\", line 19, characters 7-14", -1, -1); - })); - Nodetest.test("fromString", (function () { + }); + Nodetest.test("fromString", () => { eq("File \"belt_int_ntest.res\", line 23, characters 7-14", Belt_Int.fromString("1"), 1); eq("File \"belt_int_ntest.res\", line 24, characters 7-14", Belt_Int.fromString("-1"), -1); eq("File \"belt_int_ntest.res\", line 25, characters 7-14", Belt_Int.fromString("1.7"), 1); @@ -30,18 +30,18 @@ Nodetest.describe("Belt.Int", (function () { eq("File \"belt_int_ntest.res\", line 27, characters 7-14", Belt_Int.fromString("-1.5"), -1); eq("File \"belt_int_ntest.res\", line 28, characters 7-14", Belt_Int.fromString("-1.7"), -1); eq("File \"belt_int_ntest.res\", line 29, characters 7-14", Belt_Int.fromString("not an int"), undefined); - })); - Nodetest.test("toString", (function () { + }); + Nodetest.test("toString", () => { eq("File \"belt_int_ntest.res\", line 33, characters 7-14", String(1), "1"); eq("File \"belt_int_ntest.res\", line 34, characters 7-14", String(-1), "-1"); - })); - Nodetest.test("operators", (function () { + }); + Nodetest.test("operators", () => { eq("File \"belt_int_ntest.res\", line 40, characters 7-14", 5, 5); eq("File \"belt_int_ntest.res\", line 41, characters 7-14", -1, -1); eq("File \"belt_int_ntest.res\", line 42, characters 7-14", 6, 6); eq("File \"belt_int_ntest.res\", line 43, characters 7-14", 0, 0); - })); -})); + }); +}); let I; diff --git a/jscomp/test/belt_mapint_ntest.js b/jscomp/test/belt_mapint_ntest.js index f5402de1f1..eac12a4e46 100644 --- a/jscomp/test/belt_mapint_ntest.js +++ b/jscomp/test/belt_mapint_ntest.js @@ -9,8 +9,8 @@ function ok(loc, a) { Nodeassert.ok(a, loc); } -Nodetest.describe("Belt.Map.Int", (function () { - Nodetest.test("set", (function () { +Nodetest.describe("Belt.Map.Int", () => { + Nodetest.test("set", () => { let m; for (let i = 0; i <= 999999; ++i) { m = Belt_MapInt.set(m, i, i); @@ -22,8 +22,8 @@ Nodetest.describe("Belt.Map.Int", (function () { m = Belt_MapInt.remove(m, i$2); } ok("File \"belt_mapint_ntest.res\", line 24, characters 7-14", Belt_MapInt.isEmpty(m)); - })); -})); + }); +}); let M; diff --git a/jscomp/test/belt_result_alias_test.js b/jscomp/test/belt_result_alias_test.js index 8cc5b93095..b857620b87 100644 --- a/jscomp/test/belt_result_alias_test.js +++ b/jscomp/test/belt_result_alias_test.js @@ -6,15 +6,11 @@ let Belt_Result = require("../../lib/js/belt_Result.js"); Belt_Result.map({ TAG: "Ok", _0: "Test" -}, (function (r) { - return "Value: " + r; -})); +}, r => "Value: " + r); Belt_Result.getWithDefault(Belt_Result.map({ TAG: "Error", _0: "error" -}, (function (r) { - return "Value: " + r; -})), "success"); +}, r => "Value: " + r), "success"); /* Not a pure module */ diff --git a/jscomp/test/bench.js b/jscomp/test/bench.js index d1403d2e36..8223ef2471 100644 --- a/jscomp/test/bench.js +++ b/jscomp/test/bench.js @@ -5,9 +5,7 @@ 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 = x => f(x); let l = a.length; if (l === 0) { return []; @@ -20,9 +18,7 @@ function map(f, a) { } function init(l, f) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = x => f(x); if (l === 0) { return []; } @@ -42,9 +38,7 @@ function init(l, f) { } function fold_left(f, x, a) { - let f$1 = function (x, y) { - return f(x, y); - }; + let f$1 = (x, y) => f(x, y); let r = x; for (let i = 0, i_finish = a.length; i < i_finish; ++i) { r = f$1(r, a[i]); @@ -53,15 +47,9 @@ function fold_left(f, x, a) { } function f2() { - let arr = init(3000000, (function (i) { - return i; - })); - let b = map((function (i) { - return i + i - 1; - }), arr); - let v = fold_left((function (prim0, prim1) { - return prim0 + prim1; - }), 0, b); + let arr = init(3000000, i => i); + let b = map(i => i + i - 1, arr); + let v = fold_left((prim0, prim1) => prim0 + prim1, 0, b); console.log(Pervasives.string_of_float(v)); } diff --git a/jscomp/test/bs_abstract_test.js b/jscomp/test/bs_abstract_test.js index 650119951d..9ce29796a9 100644 --- a/jscomp/test/bs_abstract_test.js +++ b/jscomp/test/bs_abstract_test.js @@ -10,9 +10,7 @@ let v = { v.tl = v; let f = { - k: (function (x, y) { - return x === y; - }), + k: (x, y) => x === y, y: "x" }; @@ -21,9 +19,7 @@ function uf(u) { } function uf1(u) { - return function (extra) { - return u.y1(1, extra); - }; + return extra => u.y1(1, extra); } function uf2(u) { diff --git a/jscomp/test/bs_array_test.js b/jscomp/test/bs_array_test.js index 00f3f1dda6..610ef1fa8b 100644 --- a/jscomp/test/bs_array_test.js +++ b/jscomp/test/bs_array_test.js @@ -32,12 +32,10 @@ function neq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Neq", - _0: x, - _1: y - }; + () => ({ + TAG: "Neq", + _0: x, + _1: y }) ], tl: suites.contents @@ -53,13 +51,7 @@ console.log([ 2, 3, 4 -].filter(function (x) { - return x > 2; -}).map(function (x, i) { - return x + i | 0; -}).reduce((function (x, y) { - return x + y | 0; -}), 0)); +].filter(x => x > 2).map((x, i) => x + i | 0).reduce((x, y) => x + y | 0, 0)); let v = [ 1, @@ -80,19 +72,19 @@ eq("File \"bs_array_test.res\", line 31, characters 4-11", [ undefined ]); -$$throw("File \"bs_array_test.res\", line 35, characters 8-15", (function () { +$$throw("File \"bs_array_test.res\", line 35, characters 8-15", () => { Belt_Array.getExn([ 0, 1 ], -1); -})); +}); -$$throw("File \"bs_array_test.res\", line 36, characters 8-15", (function () { +$$throw("File \"bs_array_test.res\", line 36, characters 8-15", () => { Belt_Array.getExn([ 0, 1 ], 2); -})); +}); function f(extra) { return Belt_Array.getExn([ @@ -109,19 +101,15 @@ b("File \"bs_array_test.res\", line 38, characters 4-11", Caml_obj.equal([ 1 ])); -$$throw("File \"bs_array_test.res\", line 44, characters 8-15", (function () { - Belt_Array.setExn([ - 0, - 1 - ], -1, 0); -})); +$$throw("File \"bs_array_test.res\", line 44, characters 8-15", () => Belt_Array.setExn([ + 0, + 1 +], -1, 0)); -$$throw("File \"bs_array_test.res\", line 45, characters 8-15", (function () { - Belt_Array.setExn([ - 0, - 1 - ], 2, 0); -})); +$$throw("File \"bs_array_test.res\", line 45, characters 8-15", () => Belt_Array.setExn([ + 0, + 1 +], 2, 0)); b("File \"bs_array_test.res\", line 46, characters 4-11", !Belt_Array.set([ 1, @@ -186,9 +174,7 @@ function add(x, y) { return x + y | 0; } -let v$5 = Belt_Array.makeBy(3000, (function (i) { - return i; -})); +let v$5 = Belt_Array.makeBy(3000, i => i); let u = Belt_Array.shuffle(v$5); @@ -232,34 +218,26 @@ b("File \"bs_array_test.res\", line 101, characters 4-11", Caml_obj.equal(Belt_A b("File \"bs_array_test.res\", line 102, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(3, 3, 1), [3])); -eq("File \"bs_array_test.res\", line 106, characters 5-12", Belt_Array.reduceReverse([], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), 100); +eq("File \"bs_array_test.res\", line 106, characters 5-12", Belt_Array.reduceReverse([], 100, (prim0, prim1) => prim0 - prim1 | 0), 100); eq("File \"bs_array_test.res\", line 107, characters 5-12", Belt_Array.reduceReverse([ 1, 2 -], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), 97); +], 100, (prim0, prim1) => prim0 - prim1 | 0), 97); eq("File \"bs_array_test.res\", line 108, characters 5-12", Belt_Array.reduceReverse([ 1, 2, 3, 4 -], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), 90); +], 100, (prim0, prim1) => prim0 - prim1 | 0), 90); eq("File \"bs_array_test.res\", line 109, characters 5-12", Belt_Array.reduceWithIndex([ 1, 2, 3, 4 -], 0, (function (acc, x, i) { - return (acc + x | 0) + i | 0; -})), 16); +], 0, (acc, x, i) => (acc + x | 0) + i | 0), 16); b("File \"bs_array_test.res\", line 110, characters 4-11", Belt_Array.reduceReverse2([ 1, @@ -268,9 +246,7 @@ b("File \"bs_array_test.res\", line 110, characters 4-11", Belt_Array.reduceReve ], [ 1, 2 -], 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})) === 6); +], 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); function addone(x) { return x + 1 | 0; @@ -300,13 +276,9 @@ function makeMatrixExn(sx, sy, init) { return res; } -eq("File \"bs_array_test.res\", line 129, characters 5-12", Belt_Array.makeBy(0, (function (param) { - return 1; -})), []); +eq("File \"bs_array_test.res\", line 129, characters 5-12", Belt_Array.makeBy(0, param => 1), []); -eq("File \"bs_array_test.res\", line 130, characters 5-12", Belt_Array.makeBy(3, (function (i) { - return i; -})), [ +eq("File \"bs_array_test.res\", line 130, characters 5-12", Belt_Array.makeBy(3, i => i), [ 0, 1, 2 @@ -345,9 +317,7 @@ eq("File \"bs_array_test.res\", line 134, characters 5-12", makeMatrixExn(1, 1, eq("File \"bs_array_test.res\", line 135, characters 5-12", [].slice(0), []); -eq("File \"bs_array_test.res\", line 136, characters 5-12", Belt_Array.map([], (function (prim) { - return prim + 1 | 0; -})), []); +eq("File \"bs_array_test.res\", line 136, characters 5-12", Belt_Array.map([], prim => prim + 1 | 0), []); eq("File \"bs_array_test.res\", line 137, characters 5-12", Belt_Array.mapWithIndex([], add), []); @@ -387,9 +357,7 @@ eq("File \"bs_array_test.res\", line 142, characters 5-12", Belt_Array.map([ 1, 2, 3 -], (function (prim) { - return prim + 1 | 0; -})), [ +], prim => prim + 1 | 0), [ 2, 3, 4 @@ -428,24 +396,18 @@ eq("File \"bs_array_test.res\", line 146, characters 5-12", Belt_List.toArray({ 3 ]); -let v$6 = Belt_Array.makeBy(10, (function (i) { - return i; -})); +let v$6 = Belt_Array.makeBy(10, i => i); -let v0 = Belt_Array.keep(v$6, (function (x) { - return x % 2 === 0; -})); +let v0 = Belt_Array.keep(v$6, x => x % 2 === 0); -let v1 = Belt_Array.keep(v$6, (function (x) { - return x % 3 === 0; -})); +let v1 = Belt_Array.keep(v$6, x => x % 3 === 0); -let v2 = Belt_Array.keepMap(v$6, (function (x) { +let v2 = Belt_Array.keepMap(v$6, x => { if (x % 2 === 0) { return x + 1 | 0; } -})); +}); eq("File \"bs_array_test.res\", line 160, characters 5-12", v0, [ 0, @@ -478,9 +440,7 @@ let a = [ 5 ]; -let match = Belt_Array.partition(a, (function (x) { - return x % 2 === 0; -})); +let match = Belt_Array.partition(a, x => x % 2 === 0); eq("File \"bs_array_test.res\", line 168, characters 5-12", match[0], [ 2, @@ -493,9 +453,7 @@ eq("File \"bs_array_test.res\", line 169, characters 5-12", match[1], [ 5 ]); -let match$1 = Belt_Array.partition(a, (function (x) { - return x === 2; -})); +let match$1 = Belt_Array.partition(a, x => x === 2); eq("File \"bs_array_test.res\", line 171, characters 5-12", match$1[0], [2]); @@ -506,9 +464,7 @@ eq("File \"bs_array_test.res\", line 172, characters 5-12", match$1[1], [ 5 ]); -let match$2 = Belt_Array.partition([], (function (x) { - return false; -})); +let match$2 = Belt_Array.partition([], x => false); eq("File \"bs_array_test.res\", line 174, characters 5-12", match$2[0], []); @@ -633,9 +589,7 @@ eq("File \"bs_array_test.res\", line 205, characters 5-12", Belt_Array.sliceToEn eq("File \"bs_array_test.res\", line 206, characters 5-12", Belt_Array.sliceToEnd(a$2, 6), []); -let a$3 = Belt_Array.makeBy(10, (function (x) { - return x; -})); +let a$3 = Belt_Array.makeBy(10, x => x); Belt_Array.fill(a$3, 0, 3, 0); @@ -802,9 +756,7 @@ eq("File \"bs_array_test.res\", line 236, characters 5-12", b$1, [ 3 ]); -let a0 = Belt_Array.makeBy(10, (function (x) { - return x; -})); +let a0 = Belt_Array.makeBy(10, x => x); let b0 = Belt_Array.make(10, 3); @@ -876,9 +828,7 @@ Belt_Array.blit(a0, -11, b0, -11, 2); eq("File \"bs_array_test.res\", line 253, characters 5-12", b0.slice(0), a0); -let aa = Belt_Array.makeBy(10, (function (x) { - return x; -})); +let aa = Belt_Array.makeBy(10, x => x); Belt_Array.blit(aa, -1, aa, 1, 2); @@ -1015,9 +965,7 @@ eq("File \"bs_array_test.res\", line 273, characters 5-12", Belt_Array.zipBy([ 1, 2, 3 -], (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), [ +], (prim0, prim1) => prim0 - prim1 | 0), [ 1, 1, 1 @@ -1032,15 +980,11 @@ eq("File \"bs_array_test.res\", line 274, characters 5-12", Belt_Array.zipBy([ 3, 4, 1 -], (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), Belt_Array.map([ +], (prim0, prim1) => prim0 - prim1 | 0), Belt_Array.map([ 1, 1, 1 -], (function (x) { - return -x | 0; -}))); +], x => -x | 0)); eq("File \"bs_array_test.res\", line 275, characters 5-12", Belt_Array.unzip([ [ @@ -1072,9 +1016,9 @@ function sumUsingForEach(xs) { let v = { contents: 0 }; - Belt_Array.forEach(xs, (function (x) { + Belt_Array.forEach(xs, x => { v.contents = v.contents + x | 0; - })); + }); return v.contents; } @@ -1092,33 +1036,25 @@ b("File \"bs_array_test.res\", line 288, characters 4-11", !Belt_Array.every([ 2, 3, 4 -], (function (x) { - return x > 2; -}))); +], x => x > 2)); b("File \"bs_array_test.res\", line 289, characters 4-11", Belt_Array.some([ 1, 3, 7, 8 -], (function (x) { - return x % 2 === 0; -}))); +], x => x % 2 === 0)); b("File \"bs_array_test.res\", line 290, characters 4-11", !Belt_Array.some([ 1, 3, 7 -], (function (x) { - return x % 2 === 0; -}))); +], x => x % 2 === 0)); b("File \"bs_array_test.res\", line 291, characters 4-11", !Belt_Array.eq([ 0, 1 -], [1], (function (prim0, prim1) { - return prim0 === prim1; -}))); +], [1], (prim0, prim1) => prim0 === prim1)); let c$1 = { contents: 0 @@ -1128,9 +1064,9 @@ b("File \"bs_array_test.res\", line 293, characters 4-11", (Belt_Array.forEachWi 1, 1, 1 -], (function (i, v) { +], (i, v) => { c$1.contents = (c$1.contents + i | 0) + v | 0; -})), c$1.contents === 6)); +}), c$1.contents === 6)); function id(loc, x) { let u = x.slice(0); @@ -1170,9 +1106,7 @@ function some2(xs, ys, x) { eq("File \"bs_array_test.res\", line 326, characters 5-12", every2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 327, characters 5-12", every2({ hd: 2, @@ -1183,9 +1117,7 @@ eq("File \"bs_array_test.res\", line 327, characters 5-12", every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 328, characters 5-12", every2({ hd: 2, @@ -1193,9 +1125,7 @@ eq("File \"bs_array_test.res\", line 328, characters 5-12", every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 329, characters 5-12", every2({ hd: 2, @@ -1209,9 +1139,7 @@ eq("File \"bs_array_test.res\", line 329, characters 5-12", every2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_array_test.res\", line 330, characters 5-12", every2({ hd: 2, @@ -1225,16 +1153,12 @@ eq("File \"bs_array_test.res\", line 330, characters 5-12", every2({ hd: 0, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 331, characters 5-12", some2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_array_test.res\", line 332, characters 5-12", some2({ hd: 2, @@ -1245,9 +1169,7 @@ eq("File \"bs_array_test.res\", line 332, characters 5-12", some2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 333, characters 5-12", some2({ hd: 2, @@ -1261,9 +1183,7 @@ eq("File \"bs_array_test.res\", line 333, characters 5-12", some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 334, characters 5-12", some2({ hd: 0, @@ -1277,9 +1197,7 @@ eq("File \"bs_array_test.res\", line 334, characters 5-12", some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_array_test.res\", line 335, characters 5-12", some2({ hd: 0, @@ -1293,9 +1211,7 @@ eq("File \"bs_array_test.res\", line 335, characters 5-12", some2({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 339, characters 5-12", Belt_Array.concat([], [ 1, @@ -1446,33 +1362,25 @@ eq("File \"bs_array_test.res\", line 357, characters 5-12", Belt_Array.getBy([ 1, 2, 3 -], (function (x) { - return x > 1; -})), 2); +], x => x > 1), 2); eq("File \"bs_array_test.res\", line 358, characters 5-12", Belt_Array.getBy([ 1, 2, 3 -], (function (x) { - return x > 3; -})), undefined); +], x => x > 3), undefined); eq("File \"bs_array_test.res\", line 362, characters 5-12", Belt_Array.getIndexBy([ 1, 2, 3 -], (function (x) { - return x > 1; -})), 1); +], x => x > 1), 1); eq("File \"bs_array_test.res\", line 363, characters 5-12", Belt_Array.getIndexBy([ 1, 2, 3 -], (function (x) { - return x > 3; -})), undefined); +], x => x > 3), undefined); let arr = []; diff --git a/jscomp/test/bs_auto_uncurry.js b/jscomp/test/bs_auto_uncurry.js index 3ea45355c0..1b0f3d0dd9 100644 --- a/jscomp/test/bs_auto_uncurry.js +++ b/jscomp/test/bs_auto_uncurry.js @@ -12,9 +12,7 @@ let xbs = Array.prototype.map.call([ 2, 3, 5 -], (function (x) { - return x + 1 | 0; -})); +], x => x + 1 | 0); function f(cb) { return Array.prototype.map.call([ @@ -38,18 +36,14 @@ let xs = Array.prototype.map.call([ 2, 1 ] -], (function (param) { - return (param[1] + param[0] | 0) + 1 | 0; -})); +], param => (param[1] + param[0] | 0) + 1 | 0); function f_0() { - return hi(function () { - - }); + return hi(() => {}); } function f_01() { - return hi(function (x) { + return hi(x => { if (x === undefined) { console.log("x"); return; @@ -59,7 +53,7 @@ function f_01() { } function f_02(xs) { - return hi(function (x) { + return hi(x => { xs.contents = x; console.log("x"); }); @@ -78,33 +72,23 @@ function h1(x, y, u, z) { } function add3(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } function h2(x) { - return ff(x, (function (prim0, prim1) { - return prim0 + prim1 | 0; - })); + return ff(x, (prim0, prim1) => prim0 + prim1 | 0); } function h3(x) { - return ff(x, (function (y, z) { - return (1 + y | 0) + z | 0; - })); + return ff(x, (y, z) => (1 + y | 0) + z | 0); } function h4(x) { - return ff1(x, 3, (function (y, z) { - return (1 + y | 0) + z | 0; - })); + return ff1(x, 3, (y, z) => (1 + y | 0) + z | 0); } function h5(x) { - return ff2(x, "3", (function (y, z) { - return (2 + y | 0) + z | 0; - })); + return ff2(x, "3", (y, z) => (2 + y | 0) + z | 0); } function add(x, y) { diff --git a/jscomp/test/bs_auto_uncurry_test.js b/jscomp/test/bs_auto_uncurry_test.js index 0e218a1999..c44c98800e 100644 --- a/jscomp/test/bs_auto_uncurry_test.js +++ b/jscomp/test/bs_auto_uncurry_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -38,14 +36,14 @@ let xs = { contents: /* [] */0 }; -hi(function (x) { +hi(x => { xs.contents = { hd: x, tl: xs.contents }; }); -hi(function (x) { +hi(x => { xs.contents = { hd: x, tl: xs.contents @@ -64,9 +62,7 @@ eq("File \"bs_auto_uncurry_test.res\", line 28, characters 5-12", [ 1, 2, 3 -].map(function (x) { - return x + 1 | 0; -}), [ +].map(x => x + 1 | 0), [ 2, 3, 4 @@ -76,9 +72,7 @@ eq("File \"bs_auto_uncurry_test.res\", line 29, characters 5-12", [ 1, 2, 3 -].map(function (x) { - return x + 1 | 0; -}), [ +].map(x => x + 1 | 0), [ 2, 3, 4 @@ -88,33 +82,25 @@ eq("File \"bs_auto_uncurry_test.res\", line 31, characters 5-12", [ 1, 2, 3 -].reduce((function (prim0, prim1) { - return prim0 + prim1 | 0; -}), 0), 6); +].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), 6); eq("File \"bs_auto_uncurry_test.res\", line 33, characters 5-12", [ 1, 2, 3 -].reduce((function (x, y, i) { - return (x + y | 0) + i | 0; -}), 0), 9); +].reduce((x, y, i) => (x + y | 0) + i | 0, 0), 9); eq("File \"bs_auto_uncurry_test.res\", line 35, characters 5-12", [ 1, 2, 3 -].some(function (x) { - return x < 1; -}), false); +].some(x => x < 1), false); eq("File \"bs_auto_uncurry_test.res\", line 37, characters 5-12", [ 1, 2, 3 -].every(function (x) { - return x > 0; -}), true); +].every(x => x > 0), true); Mt.from_pair_suites("Bs_auto_uncurry_test", suites.contents); diff --git a/jscomp/test/bs_hashmap_test.js b/jscomp/test/bs_hashmap_test.js index 8dc9d9d08f..62e1d947f6 100644 --- a/jscomp/test/bs_hashmap_test.js +++ b/jscomp/test/bs_hashmap_test.js @@ -98,9 +98,7 @@ for (let i$1 = 0; i$1 <= 2000; ++i$1) { eqx("File \"bs_hashmap_test.res\", line 57, characters 6-13", v$1.size, 98000); -b("File \"bs_hashmap_test.res\", line 58, characters 4-11", Belt_Array.every(Array_data_util.range(2001, 100000), (function (x) { - return Belt_HashMap.has(v$1, x); -}))); +b("File \"bs_hashmap_test.res\", line 58, characters 4-11", Belt_Array.every(Array_data_util.range(2001, 100000), x => Belt_HashMap.has(v$1, x))); Mt.from_pair_suites("Bs_hashmap_test", suites.contents); diff --git a/jscomp/test/bs_hashset_int_test.js b/jscomp/test/bs_hashset_int_test.js index 36dbe3366d..cb3339dcec 100644 --- a/jscomp/test/bs_hashset_int_test.js +++ b/jscomp/test/bs_hashset_int_test.js @@ -33,9 +33,9 @@ function sum2(h) { let v = { contents: 0 }; - Belt_HashSetInt.forEach(h, (function (x) { + Belt_HashSetInt.forEach(h, x => { v.contents = v.contents + x | 0; - })); + }); return v.contents; } diff --git a/jscomp/test/bs_ignore_effect.js b/jscomp/test/bs_ignore_effect.js index 9aebbaf3a1..d432098c6b 100644 --- a/jscomp/test/bs_ignore_effect.js +++ b/jscomp/test/bs_ignore_effect.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/bs_list_test.js b/jscomp/test/bs_list_test.js index ab3f5d2f58..f5a308dd12 100644 --- a/jscomp/test/bs_list_test.js +++ b/jscomp/test/bs_list_test.js @@ -31,9 +31,9 @@ function sum(xs) { let v = { contents: 0 }; - Belt_List.forEach(xs, (function (x) { + Belt_List.forEach(xs, x => { v.contents = v.contents + x | 0; - })); + }); return v.contents; } @@ -41,15 +41,13 @@ function sum2(xs, ys) { let v = { contents: 0 }; - Belt_List.forEach2(xs, ys, (function (x, y) { + Belt_List.forEach2(xs, ys, (x, y) => { v.contents = (v.contents + x | 0) + y | 0; - })); + }); return v.contents; } -let u = Belt_List.makeBy(5, (function (i) { - return Math.imul(i, i); -})); +let u = Belt_List.makeBy(5, i => Math.imul(i, i)); function f(i) { eq("File \"bs_list_test.res\", line 27, characters 18-25", Belt_List.getExn(u, i), Math.imul(i, i)); @@ -59,9 +57,7 @@ for (let i = 0; i <= 4; ++i) { f(i); } -eq("File \"bs_list_test.res\", line 31, characters 5-12", Belt_List.map(u, (function (i) { - return i + 1 | 0; -})), { +eq("File \"bs_list_test.res\", line 31, characters 5-12", Belt_List.map(u, i => i + 1 | 0), { hd: 1, tl: { hd: 2, @@ -90,9 +86,7 @@ eq("File \"bs_list_test.res\", line 32, characters 5-12", Belt_List.getBy({ } } } -}, (function (x) { - return x % 2 === 0; -})), 4); +}, x => x % 2 === 0), 4); eq("File \"bs_list_test.res\", line 33, characters 5-12", Belt_List.getBy({ hd: 1, @@ -106,9 +100,7 @@ eq("File \"bs_list_test.res\", line 33, characters 5-12", Belt_List.getBy({ } } } -}, (function (x) { - return x % 5 === 0; -})), undefined); +}, x => x % 5 === 0), undefined); eq("FLATTEN", Belt_List.flatten({ hd: { @@ -128,9 +120,7 @@ eq("FLATTEN", Belt_List.flatten({ tl: { hd: /* [] */0, tl: { - hd: Belt_List.makeBy(4, (function (i) { - return i; - })), + hd: Belt_List.makeBy(4, i => i), tl: /* [] */0 } } @@ -213,9 +203,7 @@ eq("CONCATMANY", Belt_List.concatMany([ tl: /* [] */0 }, /* [] */0, - Belt_List.makeBy(4, (function (i) { - return i; - })) + Belt_List.makeBy(4, i => i) ]), { hd: 1, tl: { @@ -321,15 +309,7 @@ eq("CONCATMANY", Belt_List.concatMany([{ } }); -eq("File \"bs_list_test.res\", line 66, characters 2-9", Belt_List.toArray(Belt_List.concat(Belt_List.makeBy(100, (function (i) { - return i; -})), Belt_List.makeBy(100, (function (i) { - return i; -})))), Belt_Array.concat(Belt_Array.makeBy(100, (function (i) { - return i; -})), Belt_Array.makeBy(100, (function (i) { - return i; -})))); +eq("File \"bs_list_test.res\", line 66, characters 2-9", Belt_List.toArray(Belt_List.concat(Belt_List.makeBy(100, i => i), Belt_List.makeBy(100, i => i))), Belt_Array.concat(Belt_Array.makeBy(100, i => i), Belt_Array.makeBy(100, i => i))); eq("APPEND", Belt_List.concat({ hd: 1, @@ -522,9 +502,7 @@ eq("PARTITION", Belt_List.partition({ } } } -}, (function (x) { - return !mod2(x); -})), [ +}, x => !mod2(x)), [ /* [] */0, { hd: 2, @@ -726,9 +704,7 @@ function id(x) { return x; } -eq("MAP", Belt_List.map(Belt_List.makeBy(5, id), (function (x) { - return (x << 1); -})), { +eq("MAP", Belt_List.map(Belt_List.makeBy(5, id), x => (x << 1)), { hd: 0, tl: { hd: 2, @@ -750,9 +726,7 @@ eq("MAP", Belt_List.map(/* [] */0, id), /* [] */0); eq("MAP", Belt_List.map({ hd: 1, tl: /* [] */0 -}, (function (x) { - return -x | 0; -})), { +}, x => -x | 0), { hd: -1, tl: /* [] */0 }); @@ -765,9 +739,7 @@ let length_10_id = Belt_List.makeBy(10, id); let length_8_id = Belt_List.makeBy(8, id); -let d = Belt_List.makeBy(10, (function (x) { - return (x << 1); -})); +let d = Belt_List.makeBy(10, x => (x << 1)); eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), d); @@ -783,9 +755,7 @@ eq("MAP2", Belt_List.zipBy({ eq("MAP2", Belt_List.zipBy(/* [] */0, /* [] */0, add), /* [] */0); -eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, (function (x) { - return (x << 1); -})), { +eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, x => (x << 1)), { hd: 16, tl: { hd: 18, @@ -793,13 +763,9 @@ eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Be } })); -eq("MAP2", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (function (i, x) { - return i + x | 0; -}))); +eq("MAP2", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (i, x) => i + x | 0)); -eq("MAP2", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, (function (x) { - return (x << 1); -}))); +eq("MAP2", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, x => (x << 1))); let xs = Belt_List.reverse(Belt_List.mapReverse2(length_8_id, length_10_id, add)); @@ -822,9 +788,7 @@ eq("MAP2", Belt_List.mapReverse2({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x + y | 0; -})), { +}, (x, y) => x + y | 0), { hd: 4, tl: { hd: 2, @@ -1017,9 +981,7 @@ b("File \"bs_list_test.res\", line 205, characters 4-11", Belt_List.hasAssoc({ tl: /* [] */0 } } -}, 2, (function (prim0, prim1) { - return prim0 === prim1; -}))); +}, 2, (prim0, prim1) => prim0 === prim1)); b("File \"bs_list_test.res\", line 206, characters 4-11", !Belt_List.hasAssoc({ hd: [ @@ -1039,9 +1001,7 @@ b("File \"bs_list_test.res\", line 206, characters 4-11", !Belt_List.hasAssoc({ tl: /* [] */0 } } -}, 4, (function (prim0, prim1) { - return prim0 === prim1; -}))); +}, 4, (prim0, prim1) => prim0 === prim1)); b("File \"bs_list_test.res\", line 207, characters 4-11", Belt_List.hasAssoc({ hd: [ @@ -1061,9 +1021,7 @@ b("File \"bs_list_test.res\", line 207, characters 4-11", Belt_List.hasAssoc({ tl: /* [] */0 } } -}, 4, (function (x, y) { - return (x + 1 | 0) === y; -}))); +}, 4, (x, y) => (x + 1 | 0) === y)); eq("REMOVEASSOQ", Belt_List.removeAssoc({ hd: [ @@ -1083,9 +1041,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 3, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 3, (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1117,9 +1073,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 1, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 1, (prim0, prim1) => prim0 === prim1), { hd: [ 2, "2" @@ -1151,9 +1105,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 2, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 2, (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1185,9 +1137,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 0, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 0, (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1329,9 +1279,7 @@ let ll0 = Belt_List.removeAssoc(ll, 0, eqx); b("File \"bs_list_test.res\", line 222, characters 4-11", ll === ll0); -let ll1 = Belt_List.setAssoc(ll, 2, "22", (function (prim0, prim1) { - return prim0 === prim1; -})); +let ll1 = Belt_List.setAssoc(ll, 2, "22", (prim0, prim1) => prim0 === prim1); eq("File \"bs_list_test.res\", line 224, characters 5-12", ll1, { hd: [ @@ -1353,9 +1301,7 @@ eq("File \"bs_list_test.res\", line 224, characters 5-12", ll1, { } }); -let ll2 = Belt_List.setAssoc(ll1, 22, "2", (function (prim0, prim1) { - return prim0 === prim1; -})); +let ll2 = Belt_List.setAssoc(ll1, 22, "2", (prim0, prim1) => prim0 === prim1); b("File \"bs_list_test.res\", line 226, characters 4-11", Caml_obj.equal(ll2, { hd: [ @@ -1385,9 +1331,7 @@ b("File \"bs_list_test.res\", line 229, characters 4-11", Caml_obj.equal(Belt_Li tl: /* [] */0 } } -}, 2, "x", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 2, "x", (prim0, prim1) => prim0 === prim1), { hd: [ 1, "a" @@ -1419,9 +1363,7 @@ b("File \"bs_list_test.res\", line 234, characters 4-11", Caml_obj.equal(Belt_Li ], tl: /* [] */0 } -}, 2, "2", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 2, "2", (prim0, prim1) => prim0 === prim1), { hd: [ 2, "2" @@ -1441,9 +1383,7 @@ b("File \"bs_list_test.res\", line 234, characters 4-11", Caml_obj.equal(Belt_Li } })); -eq("File \"bs_list_test.res\", line 237, characters 5-12", Belt_List.setAssoc(/* [] */0, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; -})), { +eq("File \"bs_list_test.res\", line 237, characters 5-12", Belt_List.setAssoc(/* [] */0, 1, "1", (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1459,9 +1399,7 @@ eq("File \"bs_list_test.res\", line 239, characters 5-12", Belt_List.setAssoc({ "2" ], tl: /* [] */0 -}, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 1, "1", (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1481,9 +1419,7 @@ eq("File \"bs_list_test.res\", line 241, characters 5-12", Belt_List.setAssoc({ ], tl: /* [] */0 } -}, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 1, "1", (prim0, prim1) => prim0 === prim1), { hd: [ 0, "0" @@ -1515,9 +1451,7 @@ b("File \"bs_list_test.res\", line 242, characters 4-11", Caml_obj.equal(Belt_Li tl: /* [] */0 } } -}, 2, (function (prim0, prim1) { - return prim0 === prim1; -})), "b")); +}, 2, (prim0, prim1) => prim0 === prim1), "b")); b("File \"bs_list_test.res\", line 243, characters 4-11", Belt_List.getAssoc({ hd: [ @@ -1537,9 +1471,7 @@ b("File \"bs_list_test.res\", line 243, characters 4-11", Belt_List.getAssoc({ tl: /* [] */0 } } -}, 4, (function (prim0, prim1) { - return prim0 === prim1; -})) === undefined); +}, 4, (prim0, prim1) => prim0 === prim1) === undefined); eq("File \"bs_list_test.res\", line 248, characters 4-11", [ Belt_List.head(length_10_id), @@ -1551,15 +1483,13 @@ eq("File \"bs_list_test.res\", line 248, characters 4-11", [ eq("File \"bs_list_test.res\", line 255, characters 5-12", Belt_List.head(/* [] */0), undefined); -$$throw("File \"bs_list_test.res\", line 256, characters 8-15", (function () { - Belt_List.headExn(/* [] */0); -})); +$$throw("File \"bs_list_test.res\", line 256, characters 8-15", () => Belt_List.headExn(/* [] */0)); -$$throw("File \"bs_list_test.res\", line 257, characters 8-15", (function () { +$$throw("File \"bs_list_test.res\", line 257, characters 8-15", () => { Belt_List.tailExn(/* [] */0); -})); +}); -$$throw("File \"bs_list_test.res\", line 258, characters 8-15", (function () { +$$throw("File \"bs_list_test.res\", line 258, characters 8-15", () => { Belt_List.getExn({ hd: 0, tl: { @@ -1567,9 +1497,9 @@ $$throw("File \"bs_list_test.res\", line 258, characters 8-15", (function () { tl: /* [] */0 } }, -1); -})); +}); -$$throw("File \"bs_list_test.res\", line 259, characters 8-15", (function () { +$$throw("File \"bs_list_test.res\", line 259, characters 8-15", () => { Belt_List.getExn({ hd: 0, tl: { @@ -1577,7 +1507,7 @@ $$throw("File \"bs_list_test.res\", line 259, characters 8-15", (function () { tl: /* [] */0 } }, 2); -})); +}); eq("File \"bs_list_test.res\", line 260, characters 5-12", Belt_List.map({ hd: 0, @@ -1585,15 +1515,13 @@ eq("File \"bs_list_test.res\", line 260, characters 5-12", Belt_List.map({ hd: 1, tl: /* [] */0 } -}, (function (i) { - return Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, i); -})), { +}, i => Belt_List.getExn({ + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } +}, i)), { hd: 0, tl: { hd: 1, @@ -1611,17 +1539,13 @@ eq("File \"bs_list_test.res\", line 262, characters 5-12", Belt_List.tailExn({ tl: /* [] */0 }), /* [] */0); -Belt_List.forEachWithIndex(length_10_id, (function (i, x) { - eq("File \"bs_list_test.res\", line 263, characters 48-55", Belt_List.get(length_10_id, i), x); -})); +Belt_List.forEachWithIndex(length_10_id, (i, x) => eq("File \"bs_list_test.res\", line 263, characters 48-55", Belt_List.get(length_10_id, i), x)); eq("File \"bs_list_test.res\", line 264, characters 5-12", Belt_List.tail(/* [] */0), undefined); eq("File \"bs_list_test.res\", line 265, characters 5-12", Belt_List.drop(/* [] */0, 3), undefined); -eq("File \"bs_list_test.res\", line 266, characters 5-12", Belt_List.mapWithIndex(/* [] */0, (function (i, x) { - return i + x | 0; -})), /* [] */0); +eq("File \"bs_list_test.res\", line 266, characters 5-12", Belt_List.mapWithIndex(/* [] */0, (i, x) => i + x | 0), /* [] */0); eq("File \"bs_list_test.res\", line 267, characters 5-12", Belt_List.get(length_10_id, -1), undefined); @@ -1645,11 +1569,7 @@ eq("File \"bs_list_test.res\", line 290, characters 5-12", Belt_List.reduce(leng eq("File \"bs_list_test.res\", line 291, characters 5-12", Belt_List.reduceReverse(length_10_id, 0, add), 45); -eq("File \"bs_list_test.res\", line 292, characters 5-12", Belt_List.reduceReverse(Belt_List.makeBy(10000, (function (i) { - return i; -})), 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -})), 49995000); +eq("File \"bs_list_test.res\", line 292, characters 5-12", Belt_List.reduceReverse(Belt_List.makeBy(10000, i => i), 0, (prim0, prim1) => prim0 + prim1 | 0), 49995000); eq("File \"bs_list_test.res\", line 295, characters 5-12", sum2(length_10_id, length_10_id), 90); @@ -1657,9 +1577,7 @@ eq("File \"bs_list_test.res\", line 296, characters 5-12", sum2(length_8_id, len eq("File \"bs_list_test.res\", line 297, characters 5-12", sum2(length_10_id, length_8_id), 56); -eq("File \"bs_list_test.res\", line 298, characters 5-12", Belt_List.reduce2(length_10_id, length_8_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 56); +eq("File \"bs_list_test.res\", line 298, characters 5-12", Belt_List.reduce2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); eq("File \"bs_list_test.res\", line 299, characters 5-12", Belt_List.reduce2({ hd: 1, @@ -1679,17 +1597,11 @@ eq("File \"bs_list_test.res\", line 299, characters 5-12", Belt_List.reduce2({ tl: /* [] */0 } } -}, 0, (function (a, b, c) { - return (a + b | 0) + c | 0; -})), 18); +}, 0, (a, b, c) => (a + b | 0) + c | 0), 18); -eq("File \"bs_list_test.res\", line 300, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_8_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 56); +eq("File \"bs_list_test.res\", line 300, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); -eq("File \"bs_list_test.res\", line 301, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_10_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 90); +eq("File \"bs_list_test.res\", line 301, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_10_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 90); eq("File \"bs_list_test.res\", line 302, characters 5-12", Belt_List.reduceReverse2({ hd: 1, @@ -1706,9 +1618,7 @@ eq("File \"bs_list_test.res\", line 302, characters 5-12", Belt_List.reduceRever hd: 2, tl: /* [] */0 } -}, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 6); +}, 0, (acc, x, y) => (acc + x | 0) + y | 0), 6); eq("File \"bs_list_test.res\", line 303, characters 5-12", Belt_List.every({ hd: 2, @@ -1761,9 +1671,7 @@ eq("File \"bs_list_test.res\", line 309, characters 5-12", Belt_List.has({ tl: /* [] */0 } } -}, "2", (function (x, s) { - return String(x) === s; -})), true); +}, "2", (x, s) => String(x) === s), true); eq("File \"bs_list_test.res\", line 310, characters 5-12", Belt_List.has({ hd: 1, @@ -1774,9 +1682,7 @@ eq("File \"bs_list_test.res\", line 310, characters 5-12", Belt_List.has({ tl: /* [] */0 } } -}, "0", (function (x, s) { - return String(x) === s; -})), false); +}, "0", (x, s) => String(x) === s), false); b("File \"bs_list_test.res\", line 312, characters 4-11", Belt_List.reduceReverse({ hd: 1, @@ -1790,9 +1696,7 @@ b("File \"bs_list_test.res\", line 312, characters 4-11", Belt_List.reduceRevers } } } -}, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -})) === 10); +}, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); b("File \"bs_list_test.res\", line 313, characters 4-11", Belt_List.reduceReverse({ hd: 1, @@ -1806,9 +1710,7 @@ b("File \"bs_list_test.res\", line 313, characters 4-11", Belt_List.reduceRevers } } } -}, 10, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})) === 0); +}, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); b("File \"bs_list_test.res\", line 314, characters 4-11", Caml_obj.equal(Belt_List.reduceReverse({ hd: 1, @@ -1848,9 +1750,7 @@ b("File \"bs_list_test.res\", line 315, characters 4-11", Belt_List.reduce({ } } } -}, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -})) === 10); +}, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); b("File \"bs_list_test.res\", line 316, characters 4-11", Belt_List.reduce({ hd: 1, @@ -1864,9 +1764,7 @@ b("File \"bs_list_test.res\", line 316, characters 4-11", Belt_List.reduce({ } } } -}, 10, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})) === 0); +}, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); b("File \"bs_list_test.res\", line 317, characters 4-11", Caml_obj.equal(Belt_List.reduce({ hd: 1, @@ -1906,9 +1804,7 @@ b("File \"bs_list_test.res\", line 318, characters 4-11", Belt_List.reduceWithIn } } } -}, 0, (function (acc, x, i) { - return (acc + x | 0) + i | 0; -})) === 16); +}, 0, (acc, x, i) => (acc + x | 0) + i | 0) === 16); b("File \"bs_list_test.res\", line 319, characters 4-11", Belt_List.reduceReverse2({ hd: 1, @@ -1925,27 +1821,19 @@ b("File \"bs_list_test.res\", line 319, characters 4-11", Belt_List.reduceRevers hd: 2, tl: /* [] */0 } -}, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})) === 6); +}, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); -let a$1 = Belt_List.makeBy(10000, (function (i) { - return i; -})); +let a$1 = Belt_List.makeBy(10000, i => i); b("File \"bs_list_test.res\", line 322, characters 4-11", Belt_List.reduceReverse2(a$1, { hd: 0, tl: a$1 -}, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})) === 99980001); +}, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 99980001); eq("File \"bs_list_test.res\", line 328, characters 5-12", Belt_List.every2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 329, characters 5-12", Belt_List.every2({ hd: 2, @@ -1956,9 +1844,7 @@ eq("File \"bs_list_test.res\", line 329, characters 5-12", Belt_List.every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 330, characters 5-12", Belt_List.every2({ hd: 2, @@ -1966,9 +1852,7 @@ eq("File \"bs_list_test.res\", line 330, characters 5-12", Belt_List.every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 331, characters 5-12", Belt_List.every2({ hd: 2, @@ -1982,9 +1866,7 @@ eq("File \"bs_list_test.res\", line 331, characters 5-12", Belt_List.every2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_list_test.res\", line 332, characters 5-12", Belt_List.every2({ hd: 2, @@ -1998,16 +1880,12 @@ eq("File \"bs_list_test.res\", line 332, characters 5-12", Belt_List.every2({ hd: 0, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 333, characters 5-12", Belt_List.some2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_list_test.res\", line 334, characters 5-12", Belt_List.some2({ hd: 2, @@ -2018,9 +1896,7 @@ eq("File \"bs_list_test.res\", line 334, characters 5-12", Belt_List.some2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 335, characters 5-12", Belt_List.some2({ hd: 2, @@ -2034,9 +1910,7 @@ eq("File \"bs_list_test.res\", line 335, characters 5-12", Belt_List.some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 336, characters 5-12", Belt_List.some2({ hd: 0, @@ -2050,9 +1924,7 @@ eq("File \"bs_list_test.res\", line 336, characters 5-12", Belt_List.some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_list_test.res\", line 337, characters 5-12", Belt_List.some2({ hd: 0, @@ -2066,9 +1938,7 @@ eq("File \"bs_list_test.res\", line 337, characters 5-12", Belt_List.some2({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 338, characters 5-12", Belt_List.some2({ hd: 1, @@ -2085,14 +1955,10 @@ eq("File \"bs_list_test.res\", line 338, characters 5-12", Belt_List.some2({ hd: -2, tl: /* [] */0 } -}, (function (x, y) { - return x === y; -})), false); +}, (x, y) => x === y), false); function makeTest(n) { - eq("File \"bs_list_test.res\", line 341, characters 23-30", Belt_List.make(n, 3), Belt_List.makeBy(n, (function (param) { - return 3; - }))); + eq("File \"bs_list_test.res\", line 341, characters 23-30", Belt_List.make(n, 3), Belt_List.makeBy(n, param => 3)); } eq("File \"bs_list_test.res\", line 343, characters 12-19", { @@ -2371,9 +2237,7 @@ b("File \"bs_list_test.res\", line 374, characters 4-11", !Belt_List.eq({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x === y; -}))); +}, (x, y) => x === y)); b("File \"bs_list_test.res\", line 375, characters 4-11", Belt_List.eq({ hd: 1, @@ -2393,9 +2257,7 @@ b("File \"bs_list_test.res\", line 375, characters 4-11", Belt_List.eq({ tl: /* [] */0 } } -}, (function (x, y) { - return x === y; -}))); +}, (x, y) => x === y)); b("File \"bs_list_test.res\", line 376, characters 4-11", !Belt_List.eq({ hd: 1, @@ -2415,9 +2277,7 @@ b("File \"bs_list_test.res\", line 376, characters 4-11", !Belt_List.eq({ tl: /* [] */0 } } -}, (function (x, y) { - return x === y; -}))); +}, (x, y) => x === y)); b("File \"bs_list_test.res\", line 377, characters 4-11", !Belt_List.eq({ hd: 1, @@ -2440,20 +2300,16 @@ b("File \"bs_list_test.res\", line 377, characters 4-11", !Belt_List.eq({ } } } -}, (function (prim0, prim1) { - return prim0 === prim1; -}))); +}, (prim0, prim1) => prim0 === prim1)); -let u0 = Belt_List.makeBy(20, (function (x) { - return x; -})); +let u0 = Belt_List.makeBy(20, x => x); -let u1 = Belt_List.keepMap(u0, (function (x) { +let u1 = Belt_List.keepMap(u0, x => { if (x % 7 === 0) { return x + 1 | 0; } -})); +}); eq("File \"bs_list_test.res\", line 388, characters 5-12", u1, { hd: 1, @@ -2478,12 +2334,12 @@ b("File \"bs_list_test.res\", line 390, characters 4-11", Caml_obj.equal(Belt_Li } } } -}, (function (x) { +}, x => { if (x % 2 === 0) { return -x | 0; } -})), { +}), { hd: -2, tl: { hd: -4, @@ -2503,12 +2359,12 @@ b("File \"bs_list_test.res\", line 404, characters 4-11", Belt_List.keepMap({ } } } -}, (function (x) { +}, x => { if (x % 5 === 0) { return x; } -})) === /* [] */0); +}) === /* [] */0); Mt.from_pair_suites("Bs_list_test", suites.contents); diff --git a/jscomp/test/bs_map_set_dict_test.js b/jscomp/test/bs_map_set_dict_test.js index a032c6e69e..5cc84fab8d 100644 --- a/jscomp/test/bs_map_set_dict_test.js +++ b/jscomp/test/bs_map_set_dict_test.js @@ -53,9 +53,7 @@ let m00 = { }; let I2 = { - cmp: (function (x, y) { - return Caml.int_compare(y, x); - }) + cmp: (x, y) => Caml.int_compare(y, x) }; let m_cmp = Icmp2.cmp; @@ -114,63 +112,51 @@ function f(none) { } function $eq$tilde(a, b) { - return function (extra) { - return Belt_Map.eq(a, b, extra); - }; + return extra => Belt_Map.eq(a, b, extra); } -let u0 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 39), (function (x) { - return [ - x, - x - ]; -})), Icmp); +let u0 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 39), x => [ + x, + x +]), Icmp); let u1 = Belt_Map.set(u0, 39, 120); -b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.every2(Belt_MapDict.toArray(u0.data), Belt_Array.map(Array_data_util.range(0, 39), (function (x) { - return [ - x, - x - ]; -})), (function (param, param$1) { +b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.every2(Belt_MapDict.toArray(u0.data), Belt_Array.map(Array_data_util.range(0, 39), x => [ + x, + x +]), (param, param$1) => { if (param[0] === param$1[0]) { return param[1] === param$1[1]; } else { return false; } -}))); - -b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_MapDict.toList(u0.data), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), (function (x) { - return [ - x, - x - ]; -}))), (function (param, param$1) { +})); + +b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_MapDict.toList(u0.data), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), x => [ + x, + x +])), (param, param$1) => { if (param[0] === param$1[0]) { return param[1] === param$1[1]; } else { return false; } -}))); +})); eq("File \"bs_map_set_dict_test.res\", line 84, characters 5-12", Belt_Map.get(u0, 39), 39); eq("File \"bs_map_set_dict_test.res\", line 85, characters 5-12", Belt_Map.get(u1, 39), 120); -let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, (function (x) { - return [ - x, - x - ]; -})), Icmp); - -eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, (function (x) { - return [ - x, - x - ]; -})), Belt_MapDict.toArray(u.data)); +let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, x => [ + x, + x +]), Icmp); + +eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, x => [ + x, + x +]), Belt_MapDict.toArray(u.data)); Mt.from_pair_suites("Bs_map_set_dict_test", suites.contents); diff --git a/jscomp/test/bs_map_test.js b/jscomp/test/bs_map_test.js index 689645a29f..585b8956f4 100644 --- a/jscomp/test/bs_map_test.js +++ b/jscomp/test/bs_map_test.js @@ -19,12 +19,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -36,11 +34,9 @@ function b(loc, v) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Ok", - _0: v - }; + () => ({ + TAG: "Ok", + _0: v }) ], tl: suites.contents @@ -55,12 +51,10 @@ function emptyMap() { } -let v = Belt_Array.makeByAndShuffle(1000000, (function (i) { - return [ - i, - i - ]; -})); +let v = Belt_Array.makeByAndShuffle(1000000, i => [ + i, + i +]); let u = Belt_MapInt.fromArray(v); @@ -68,9 +62,7 @@ Belt_MapInt.checkInvariantInternal(u); let firstHalf = Belt_Array.slice(v, 0, 2000); -let xx = Belt_Array.reduce(firstHalf, u, (function (acc, param) { - return Belt_MapInt.remove(acc, param[0]); -})); +let xx = Belt_Array.reduce(firstHalf, u, (acc, param) => Belt_MapInt.remove(acc, param[0])); Belt_MapInt.checkInvariantInternal(u); diff --git a/jscomp/test/bs_mutable_set_test.js b/jscomp/test/bs_mutable_set_test.js index 484e86f318..8c17ab5ba9 100644 --- a/jscomp/test/bs_mutable_set_test.js +++ b/jscomp/test/bs_mutable_set_test.js @@ -113,33 +113,29 @@ let v = { data: Belt_internalSetInt.fromArray(xs$1) }; -let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), (function (x) { - return Belt_MutableSetInt.removeCheck(v, x); -})); +let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSetInt.removeCheck(v, x)); -let indeedRemoved = Belt_Array.reduce(bs, 0, (function (acc, x) { +let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_mutable_set_test.res\", line 72, characters 9-16", indeedRemoved, 500); eq("File \"bs_mutable_set_test.res\", line 73, characters 9-16", Belt_internalAVLset.size(v.data), 501); -let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), (function (x) { - return Belt_MutableSetInt.addCheck(v, x); -})); +let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSetInt.addCheck(v, x)); -let indeedAded = Belt_Array.reduce(cs, 0, (function (acc, x) { +let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_mutable_set_test.res\", line 82, characters 9-16", indeedAded, 1000); @@ -157,15 +153,9 @@ eq("File \"bs_mutable_set_test.res\", line 87, characters 9-16", Belt_internalAV eq("File \"bs_mutable_set_test.res\", line 88, characters 9-16", Belt_internalAVLset.maxUndefined(v.data), 2000); -eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (function (x, y) { - return x + y | 0; -})), 1876250); +eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (x, y) => x + y | 0), 1876250); -b("File \"bs_mutable_set_test.res\", line 90, characters 8-15", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, (function (i) { - return i + 500 | 0; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_mutable_set_test.res\", line 90, characters 8-15", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); eq("File \"bs_mutable_set_test.res\", line 91, characters 9-16", Belt_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); @@ -185,13 +175,9 @@ let aa = match$1[0]; b("File \"bs_mutable_set_test.res\", line 96, characters 8-15", match[1]); -b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (function (x, y) { - return x === y; -}))); +b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (x, y) => x === y)); -b("File \"bs_mutable_set_test.res\", line 98, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_mutable_set_test.res\", line 98, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_mutable_set_test.res\", line 99, characters 8-15", Belt_MutableSetInt.subset(aa, v)); @@ -213,13 +199,9 @@ let aa$1 = match$3[0]; b("File \"bs_mutable_set_test.res\", line 105, characters 8-15", !match$2[1]); -b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_mutable_set_test.res\", line 107, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_mutable_set_test.res\", line 107, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_mutable_set_test.res\", line 108, characters 8-15", Belt_MutableSetInt.subset(aa$1, v)); @@ -378,17 +360,11 @@ let a0 = { data: Belt_internalSetInt.fromArray(xs$24) }; -let a1 = Belt_MutableSetInt.keep(a0, (function (x) { - return x % 2 === 0; -})); +let a1 = Belt_MutableSetInt.keep(a0, x => x % 2 === 0); -let a2 = Belt_MutableSetInt.keep(a0, (function (x) { - return x % 2 !== 0; -})); +let a2 = Belt_MutableSetInt.keep(a0, x => x % 2 !== 0); -let match$4 = Belt_MutableSetInt.partition(a0, (function (x) { - return x % 2 === 0; -})); +let match$4 = Belt_MutableSetInt.partition(a0, x => x % 2 === 0); let a4 = match$4[1]; @@ -413,9 +389,7 @@ Belt_List.forEach({ } } } -}, (function (x) { - Belt_internalAVLset.checkInvariantInternal(x.data); -})); +}, x => Belt_internalAVLset.checkInvariantInternal(x.data)); let v$1 = { data: undefined @@ -427,9 +401,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_internalSetInt.has(v$1.data, i); -}))); +b("File \"bs_mutable_set_test.res\", line 188, characters 10-17", Belt_Range.every(0, 100000, i => 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); @@ -471,9 +443,7 @@ eq("File \"bs_mutable_set_test.res\", line 216, characters 5-12", Belt_internalA 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; -})); +let xs$25 = Belt_Array.makeBy(30, i => i); let v$4 = { data: Belt_internalSetInt.fromArray(xs$25) @@ -504,9 +474,7 @@ function id(loc, x) { data: Belt_internalAVLset.fromSortedArrayUnsafe(x) }; Belt_internalAVLset.checkInvariantInternal(u.data); - b(loc, Belt_Array.every2(Belt_internalAVLset.toArray(u.data), x, (function (prim0, prim1) { - return prim0 === prim1; - }))); + b(loc, Belt_Array.every2(Belt_internalAVLset.toArray(u.data), x, (prim0, prim1) => prim0 === prim1)); } id("File \"bs_mutable_set_test.res\", line 242, characters 5-12", []); @@ -598,17 +566,11 @@ let v$5 = { data: Belt_internalSetInt.fromArray(xs$26) }; -let copyV = Belt_MutableSetInt.keep(v$5, (function (x) { - return x % 8 === 0; -})); +let copyV = Belt_MutableSetInt.keep(v$5, x => x % 8 === 0); -let match$5 = Belt_MutableSetInt.partition(v$5, (function (x) { - return x % 8 === 0; -})); +let match$5 = Belt_MutableSetInt.partition(v$5, x => x % 8 === 0); -let cc$1 = Belt_MutableSetInt.keep(v$5, (function (x) { - return x % 8 !== 0; -})); +let cc$1 = Belt_MutableSetInt.keep(v$5, x => x % 8 !== 0); for (let i$6 = 0; i$6 <= 200; ++i$6) { Belt_MutableSetInt.remove(v$5, i$6); @@ -616,9 +578,7 @@ for (let i$6 = 0; i$6 <= 200; ++i$6) { eq("File \"bs_mutable_set_test.res\", line 264, characters 5-12", Belt_internalAVLset.size(copyV.data), 126); -eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_internalAVLset.toArray(copyV.data), Belt_Array.makeBy(126, (function (i) { - return (i << 3); -}))); +eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_internalAVLset.toArray(copyV.data), Belt_Array.makeBy(126, i => (i << 3))); eq("File \"bs_mutable_set_test.res\", line 266, characters 5-12", Belt_internalAVLset.size(v$5.data), 800); @@ -648,9 +608,7 @@ b("File \"bs_mutable_set_test.res\", line 275, characters 4-11", Belt_MutableSet data: Belt_internalSetInt.fromArray(xs$29) })); -let xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), (function (x) { - return (x << 1); -})); +let xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), x => (x << 1)); let d = { data: Belt_internalSetInt.fromArray(xs$30) @@ -660,17 +618,13 @@ let match$8 = Belt_MutableSetInt.split(d, 1001); let match$9 = match$8[0]; -let xs$31 = Belt_Array.makeBy(501, (function (x) { - return (x << 1); -})); +let xs$31 = Belt_Array.makeBy(501, x => (x << 1)); b("File \"bs_mutable_set_test.res\", line 278, characters 4-11", Belt_MutableSetInt.eq(match$9[0], { data: Belt_internalSetInt.fromArray(xs$31) })); -let xs$32 = Belt_Array.makeBy(500, (function (x) { - return 1002 + (x << 1) | 0; -})); +let xs$32 = Belt_Array.makeBy(500, x => 1002 + (x << 1) | 0); b("File \"bs_mutable_set_test.res\", line 279, characters 4-11", Belt_MutableSetInt.eq(match$9[1], { data: Belt_internalSetInt.fromArray(xs$32) diff --git a/jscomp/test/bs_poly_map_test.js b/jscomp/test/bs_poly_map_test.js index aa8030e6e3..b1d01724bb 100644 --- a/jscomp/test/bs_poly_map_test.js +++ b/jscomp/test/bs_poly_map_test.js @@ -46,42 +46,40 @@ function emptyMap() { } function mergeInter(s1, s2) { - let m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { + let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { if (v1 !== undefined && v2 !== undefined) { return Caml_option.some(undefined); } - })); + }); return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function mergeUnion(s1, s2) { - let m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { + let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { if (v1 !== undefined || v2 !== undefined) { return Caml_option.some(undefined); } - })); + }); return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function mergeDiff(s1, s2) { - let m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { + let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { if (v1 !== undefined && v2 === undefined) { return Caml_option.some(undefined); } - })); + }); return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), (function (x) { - return [ - x, - x - ]; - })); + return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ + x, + x + ]); } let u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); @@ -102,20 +100,20 @@ let a1 = Belt_Map.set(a0, 3, 33); let a2 = Belt_Map.remove(a1, 3); -let a3 = Belt_Map.update(a2, 3, (function (k) { +let a3 = Belt_Map.update(a2, 3, k => { if (k !== undefined) { return k + 1 | 0; } else { return 11; } -})); +}); -let a4 = Belt_Map.update(a2, 3, (function (k) { +let a4 = Belt_Map.update(a2, 3, k => { if (k !== undefined) { return k + 1 | 0; } -})); +}); let a5 = Belt_Map.remove(a0, 3); @@ -169,14 +167,12 @@ eq("File \"bs_poly_map_test.res\", line 108, characters 5-12", Belt_Map.get(u1$1 eq("File \"bs_poly_map_test.res\", line 109, characters 5-12", Belt_Map.get(u0$1, 3), 3); function acc(m, is) { - return Belt_Array.reduce(is, m, (function (a, i) { - return Belt_Map.update(a, i, (function (n) { - if (n !== undefined) { - return n + 1 | 0; - } else { - return 1; - } - })); + return Belt_Array.reduce(is, m, (a, i) => Belt_Map.update(a, i, n => { + if (n !== undefined) { + return n + 1 | 0; + } else { + return 1; + } })); } @@ -189,14 +185,10 @@ let m = { let m1 = acc(m, Belt_Array.concat(Array_data_util.randomRange(0, 20), Array_data_util.randomRange(10, 30))); -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 - ]; -})), Icmp), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_map_test.res\", line 126, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, i => [ + i, + i >= 10 && i <= 20 ? 2 : 1 +]), Icmp), (x, y) => x === y)); let v0_cmp = Icmp.cmp; @@ -205,23 +197,17 @@ let v0 = { data: undefined }; -let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { - return [ - x, - x - ]; -}))); +let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ + x, + x +])); -let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { - return [ - x, - x - ]; -})), Icmp); +let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ + x, + x +]), Icmp); -b("File \"bs_poly_map_test.res\", line 150, characters 4-11", Belt_Map.eq(v1, v2, (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_map_test.res\", line 150, characters 4-11", Belt_Map.eq(v1, v2, (x, y) => x === y)); function inc(x) { if (x !== undefined) { @@ -269,17 +255,9 @@ b("File \"bs_poly_map_test.res\", line 182, characters 4-11", Belt_MapDict.isEmp b("File \"bs_poly_map_test.res\", line 184, characters 4-11", pres !== undefined ? pres === 5000 : false); -b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[0].data), Belt_Array.makeBy(5000, (function (i) { - return i; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_poly_map_test.res\", line 191, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[1].data), Belt_Array.makeBy(5000, (function (i) { - return 5001 + i | 0; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_map_test.res\", line 191, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); let v7 = Belt_Map.remove(v3, 5000); @@ -289,17 +267,9 @@ let match$6 = match$5[0]; b("File \"bs_poly_map_test.res\", line 196, characters 4-11", match$5[1] === undefined); -b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[0].data), Belt_Array.makeBy(5000, (function (i) { - return i; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); - -b("File \"bs_poly_map_test.res\", line 203, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[1].data), Belt_Array.makeBy(5000, (function (i) { - return 5001 + i | 0; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_map_test.res\", line 203, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); Mt.from_pair_suites("Bs_poly_map_test", suites.contents); diff --git a/jscomp/test/bs_poly_mutable_map_test.js b/jscomp/test/bs_poly_mutable_map_test.js index 85020d2aca..5d8d490da6 100644 --- a/jscomp/test/bs_poly_mutable_map_test.js +++ b/jscomp/test/bs_poly_mutable_map_test.js @@ -38,12 +38,10 @@ function ff(x) { } function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), (function (x) { - return [ - x, - x - ]; - })); + return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ + x, + x + ]); } let a0 = Belt_MutableMap.fromArray(randomRange(0, 10), Icmp); @@ -79,13 +77,9 @@ let a0$1 = Belt_MutableMap.fromArray(randomRange(0, 10000), Icmp); Belt_MutableMap.set(a0$1, 2000, 33); -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), (function (prim) { - return prim[0]; -}))); +Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), prim => prim[0])); -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(2002, 11000), (function (prim) { - return prim[0]; -}))); +Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(2002, 11000), prim => prim[0])); eq("File \"bs_poly_mutable_map_test.res\", line 39, characters 5-12", Belt_internalAVLtree.toArray(a0$1.data), [ [ diff --git a/jscomp/test/bs_poly_mutable_set_test.js b/jscomp/test/bs_poly_mutable_set_test.js index 26d94fd88b..02a95bc8e5 100644 --- a/jscomp/test/bs_poly_mutable_set_test.js +++ b/jscomp/test/bs_poly_mutable_set_test.js @@ -118,33 +118,29 @@ b("File \"bs_poly_mutable_set_test.res\", line 54, characters 4-11", Belt_Mutabl let v = Belt_MutableSet.fromArray(Array_data_util.randomRange(1000, 2000), IntCmp); -let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), (function (x) { - return Belt_MutableSet.removeCheck(v, x); -})); +let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSet.removeCheck(v, x)); -let indeedRemoved = Belt_Array.reduce(bs, 0, (function (acc, x) { +let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_poly_mutable_set_test.res\", line 67, characters 5-12", indeedRemoved, 500); eq("File \"bs_poly_mutable_set_test.res\", line 68, characters 5-12", Belt_internalAVLset.size(v.data), 501); -let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), (function (x) { - return Belt_MutableSet.addCheck(v, x); -})); +let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSet.addCheck(v, x)); -let indeedAded = Belt_Array.reduce(cs, 0, (function (acc, x) { +let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_poly_mutable_set_test.res\", line 77, characters 5-12", indeedAded, 1000); @@ -163,15 +159,9 @@ eq("File \"bs_poly_mutable_set_test.res\", line 82, characters 5-12", Belt_inter eq("File \"bs_poly_mutable_set_test.res\", line 83, characters 5-12", Belt_internalAVLset.maxUndefined(v.data), 2000); -eq("File \"bs_poly_mutable_set_test.res\", line 84, characters 5-12", Belt_MutableSet.reduce(v, 0, (function (x, y) { - return x + y | 0; -})), 1876250); +eq("File \"bs_poly_mutable_set_test.res\", line 84, characters 5-12", Belt_MutableSet.reduce(v, 0, (x, y) => x + y | 0), 1876250); -b("File \"bs_poly_mutable_set_test.res\", line 85, characters 4-11", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, (function (i) { - return i + 500 | 0; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 85, characters 4-11", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); eq("File \"bs_poly_mutable_set_test.res\", line 86, characters 5-12", Belt_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); @@ -191,13 +181,9 @@ let aa = match$1[0]; b("File \"bs_poly_mutable_set_test.res\", line 91, characters 4-11", match[1]); -b("File \"bs_poly_mutable_set_test.res\", line 92, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 92, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_poly_mutable_set_test.res\", line 93, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 93, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_poly_mutable_set_test.res\", line 94, characters 4-11", Belt_MutableSet.subset(aa, v)); @@ -219,13 +205,9 @@ let aa$1 = match$3[0]; b("File \"bs_poly_mutable_set_test.res\", line 100, characters 4-11", !match$2[1]); -b("File \"bs_poly_mutable_set_test.res\", line 101, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 101, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_poly_mutable_set_test.res\", line 102, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 102, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_poly_mutable_set_test.res\", line 103, characters 4-11", Belt_MutableSet.subset(aa$1, v)); @@ -288,17 +270,11 @@ b("File \"bs_poly_mutable_set_test.res\", line 150, characters 4-11", Belt_Mutab let a0 = Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); -let a1 = Belt_MutableSet.keep(a0, (function (x) { - return x % 2 === 0; -})); +let a1 = Belt_MutableSet.keep(a0, x => x % 2 === 0); -let a2 = Belt_MutableSet.keep(a0, (function (x) { - return x % 2 !== 0; -})); +let a2 = Belt_MutableSet.keep(a0, x => x % 2 !== 0); -let match$4 = Belt_MutableSet.partition(a0, (function (x) { - return x % 2 === 0; -})); +let match$4 = Belt_MutableSet.partition(a0, x => x % 2 === 0); let a4 = match$4[1]; @@ -323,9 +299,7 @@ Belt_List.forEach({ } } } -}, (function (x) { - Belt_internalAVLset.checkInvariantInternal(x.data); -})); +}, x => Belt_internalAVLset.checkInvariantInternal(x.data)); Mt.from_pair_suites("Bs_poly_mutable_set_test", suites.contents); diff --git a/jscomp/test/bs_poly_set_test.js b/jscomp/test/bs_poly_set_test.js index 186f46caff..1645d3d1bd 100644 --- a/jscomp/test/bs_poly_set_test.js +++ b/jscomp/test/bs_poly_set_test.js @@ -146,9 +146,7 @@ let u26 = Belt_Set.add({ data: undefined }, 3); -let ss = Belt_Array.makeByAndShuffle(100, (function (i) { - return (i << 1); -})); +let ss = Belt_Array.makeByAndShuffle(100, i => (i << 1)); let u27 = Belt_Set.fromArray(ss, IntCmp); @@ -200,12 +198,12 @@ function testIterToList(xs) { let v = { contents: /* [] */0 }; - Belt_SetDict.forEach(xs.data, (function (x) { + Belt_SetDict.forEach(xs.data, x => { v.contents = { hd: x, tl: v.contents }; - })); + }); return Belt_List.reverse(v.contents); } @@ -213,12 +211,12 @@ function testIterToList2(xs) { let v = { contents: /* [] */0 }; - Belt_SetDict.forEach(xs.data, (function (x) { + Belt_SetDict.forEach(xs.data, x => { v.contents = { hd: x, tl: v.contents }; - })); + }); return Belt_List.reverse(v.contents); } @@ -228,21 +226,11 @@ let u1$1 = Belt_Set.remove(u0$1, 17); let u2$1 = Belt_Set.add(u1$1, 33); -b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_List.makeBy(21, (function (i) { - return i; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); -b("File \"bs_poly_set_test.res\", line 111, characters 4-11", Belt_List.every2(testIterToList2(u0$1), Belt_List.makeBy(21, (function (i) { - return i; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_set_test.res\", line 111, characters 4-11", Belt_List.every2(testIterToList2(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); -b("File \"bs_poly_set_test.res\", line 112, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_SetDict.toList(u0$1.data), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_set_test.res\", line 112, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_SetDict.toList(u0$1.data), (x, y) => x === y)); function f(x) { return x === 17; @@ -262,9 +250,7 @@ function f$2(x) { b("File \"bs_poly_set_test.res\", line 115, characters 4-11", Belt_SetDict.every(u0$1.data, f$2)); -b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(u0$1.data, (function (x) { - return x < 24; -}))); +b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(u0$1.data, x => x < 24)); function f$3(x) { return x < 24; @@ -290,17 +276,11 @@ b("File \"bs_poly_set_test.res\", line 120, characters 4-11", Belt_Set.cmp(u0$1, let a0 = Belt_Set.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); -let a1 = Belt_Set.keep(a0, (function (x) { - return x % 2 === 0; -})); +let a1 = Belt_Set.keep(a0, x => x % 2 === 0); -let a2 = Belt_Set.keep(a0, (function (x) { - return x % 2 !== 0; -})); +let a2 = Belt_Set.keep(a0, x => x % 2 !== 0); -let match = Belt_Set.partition(a0, (function (x) { - return x % 2 === 0; -})); +let match = Belt_Set.partition(a0, x => x % 2 === 0); let a4 = match[1]; @@ -314,13 +294,13 @@ eq("File \"bs_poly_set_test.res\", line 129, characters 5-12", Belt_Set.getExn(a eq("File \"bs_poly_set_test.res\", line 130, characters 5-12", Belt_Set.getExn(a0, 4), 4); -t("File \"bs_poly_set_test.res\", line 131, characters 4-11", (function () { +t("File \"bs_poly_set_test.res\", line 131, characters 4-11", () => { Belt_Set.getExn(a0, 1002); -})); +}); -t("File \"bs_poly_set_test.res\", line 132, characters 4-11", (function () { +t("File \"bs_poly_set_test.res\", line 132, characters 4-11", () => { Belt_Set.getExn(a0, -1); -})); +}); eq("File \"bs_poly_set_test.res\", line 133, characters 5-12", Belt_SetDict.size(a0.data), 1001); @@ -332,13 +312,9 @@ let match$2 = match$1[0]; b("File \"bs_poly_set_test.res\", line 136, characters 4-11", match$1[1]); -eq("File \"bs_poly_set_test.res\", line 137, characters 5-12", Belt_SetDict.toArray(match$2[0].data), Belt_Array.makeBy(200, (function (i) { - return i; -}))); +eq("File \"bs_poly_set_test.res\", line 137, characters 5-12", Belt_SetDict.toArray(match$2[0].data), Belt_Array.makeBy(200, i => i)); -eq("File \"bs_poly_set_test.res\", line 138, characters 5-12", Belt_SetDict.toList(match$2[1].data), Belt_List.makeBy(800, (function (i) { - return i + 201 | 0; -}))); +eq("File \"bs_poly_set_test.res\", line 138, characters 5-12", Belt_SetDict.toList(match$2[1].data), Belt_List.makeBy(800, i => i + 201 | 0)); let a7 = Belt_Set.remove(a0, 200); @@ -352,13 +328,9 @@ let a8 = match$4[0]; b("File \"bs_poly_set_test.res\", line 141, characters 4-11", !match$3[1]); -eq("File \"bs_poly_set_test.res\", line 142, characters 5-12", Belt_SetDict.toArray(a8.data), Belt_Array.makeBy(200, (function (i) { - return i; -}))); +eq("File \"bs_poly_set_test.res\", line 142, characters 5-12", Belt_SetDict.toArray(a8.data), Belt_Array.makeBy(200, i => i)); -eq("File \"bs_poly_set_test.res\", line 143, characters 5-12", Belt_SetDict.toList(a9.data), Belt_List.makeBy(800, (function (i) { - return i + 201 | 0; -}))); +eq("File \"bs_poly_set_test.res\", line 143, characters 5-12", Belt_SetDict.toList(a9.data), Belt_List.makeBy(800, i => i + 201 | 0)); eq("File \"bs_poly_set_test.res\", line 144, characters 5-12", Belt_SetDict.minimum(a8.data), 0); @@ -379,15 +351,11 @@ Belt_List.forEach({ } } } -}, (function (x) { - Belt_SetDict.checkInvariantInternal(x.data); -})); +}, x => Belt_SetDict.checkInvariantInternal(x.data)); let a = Belt_Set.fromArray([], IntCmp); -let m$1 = Belt_Set.keep(a, (function (x) { - return x % 2 === 0; -})); +let m$1 = Belt_Set.keep(a, x => x % 2 === 0); b("File \"bs_poly_set_test.res\", line 151, characters 4-11", Belt_SetDict.isEmpty(m$1.data)); diff --git a/jscomp/test/bs_queue_test.js b/jscomp/test/bs_queue_test.js index cb4358d47e..23b344361b 100644 --- a/jscomp/test/bs_queue_test.js +++ b/jscomp/test/bs_queue_test.js @@ -767,7 +767,7 @@ let i$7 = { contents: 1 }; -Belt_MutableQueue.forEach(q$5, (function (j) { +Belt_MutableQueue.forEach(q$5, j => { if (i$7.contents !== j) { throw new Error("Assert_failure", { cause: { @@ -781,7 +781,7 @@ Belt_MutableQueue.forEach(q$5, (function (j) { }); } i$7.contents = i$7.contents + 1 | 0; -})); +}); let q1$1 = { length: 0, @@ -1312,11 +1312,7 @@ if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$4), v)) { }); } -if (Belt_MutableQueue.reduce(q2$4, 0, (function (x, y) { - return x - y | 0; - })) !== Belt_Array.reduce(v, 0, (function (x, y) { - return x - y | 0; - }))) { +if (Belt_MutableQueue.reduce(q2$4, 0, (x, y) => x - y | 0) !== Belt_Array.reduce(v, 0, (x, y) => x - y | 0)) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -1338,9 +1334,7 @@ let q$6 = Belt_MutableQueue.fromArray([ 4 ]); -let q1$5 = Belt_MutableQueue.map(q$6, (function (x) { - return x - 1 | 0; -})); +let q1$5 = Belt_MutableQueue.map(q$6, x => x - 1 | 0); eq("File \"bs_queue_test.res\", line 197, characters 5-12", Belt_MutableQueue.toArray(q1$5), [ 0, @@ -1353,9 +1347,7 @@ let q$7 = Belt_MutableQueue.fromArray([]); b("File \"bs_queue_test.res\", line 198, characters 4-11", q$7.length === 0); -let q$8 = Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), (function (x) { - return x + 1 | 0; -})); +let q$8 = Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), x => x + 1 | 0); b("File \"bs_queue_test.res\", line 199, characters 4-11", q$8.length === 0); diff --git a/jscomp/test/bs_set_int_test.js b/jscomp/test/bs_set_int_test.js index b3eb0f0a2a..7cf08f608f 100644 --- a/jscomp/test/bs_set_int_test.js +++ b/jscomp/test/bs_set_int_test.js @@ -55,15 +55,11 @@ let u = Belt_SetInt.intersect(Belt_SetInt.fromArray([ 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) { - return k + i | 0; - })); + return $$Array.init((j - i | 0) + 1 | 0, k => k + i | 0); } function revRange(i, j) { - return $$Array.of_list(List.rev($$Array.to_list($$Array.init((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - }))))); + return $$Array.of_list(List.rev($$Array.to_list($$Array.init((j - i | 0) + 1 | 0, k => k + i | 0)))); } let v = Belt_SetInt.fromArray($$Array.append(range(100, 1000), revRange(400, 1500))); @@ -72,9 +68,7 @@ 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; -})); +let match = Belt_SetInt.partition(v, x => x % 3 === 0); let l; @@ -162,11 +156,7 @@ function approx(loc, x, y) { b(loc, x === y); } -eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (function (x, y) { - return x + y | 0; -})), Belt_Array.reduce(ss, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -}))); +eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (x, y) => x + y | 0), Belt_Array.reduce(ss, 0, (prim0, prim1) => prim0 + prim1 | 0)); approx("File \"bs_set_int_test.res\", line 126, characters 9-16", -1, minv); @@ -216,9 +206,7 @@ let v$10 = Belt_SetInt.remove(v$9, 1); b("File \"bs_set_int_test.res\", line 146, characters 4-11", Belt_SetInt.isEmpty(v$10)); -let v$11 = Belt_Array.makeByAndShuffle(1000000, (function (i) { - return i; -})); +let v$11 = Belt_Array.makeByAndShuffle(1000000, i => i); let u$1 = Belt_SetInt.fromArray(v$11); @@ -341,17 +329,15 @@ let v3 = Belt_SetInt.removeMany(v2, [ 2001 ]); -let us = Belt_Array.map(Array_data_util.randomRange(1000, 3000), (function (x) { - return Belt_SetInt.has(v$12, x); -})); +let us = Belt_Array.map(Array_data_util.randomRange(1000, 3000), x => Belt_SetInt.has(v$12, x)); -let counted = Belt_Array.reduce(us, 0, (function (acc, x) { +let counted = Belt_Array.reduce(us, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_set_int_test.res\", line 235, characters 5-12", counted, 1001); diff --git a/jscomp/test/bs_sort_test.js b/jscomp/test/bs_sort_test.js index e52e8cfe62..a3c9b0a5f8 100644 --- a/jscomp/test/bs_sort_test.js +++ b/jscomp/test/bs_sort_test.js @@ -92,17 +92,17 @@ eq("File \"bs_sort_test.res\", line 52, characters 5-12", diffs(Array_data_util. 2 ]); -b("File \"bs_sort_test.res\", line 56, characters 4-11", Belt_Range.every(0, 200, (function (i) { +b("File \"bs_sort_test.res\", line 56, characters 4-11", Belt_Range.every(0, 200, i => { let v = Array_data_util.randomRange(0, i); Belt_SortArray.stableSortInPlaceBy(v, cmp); return Belt_SortArray.isSorted(v, cmp); -}))); +})); -b("File \"bs_sort_test.res\", line 64, characters 4-11", Belt_Range.every(0, 200, (function (i) { +b("File \"bs_sort_test.res\", line 64, characters 4-11", Belt_Range.every(0, 200, i => { let v = Array_data_util.randomRange(0, i); Belt_SortArray.stableSortInPlaceBy(v, cmp); return Belt_SortArray.isSorted(v, cmp); -}))); +})); b("File \"bs_sort_test.res\", line 71, characters 4-11", Belt_SortArray.isSorted([], cmp)); @@ -151,9 +151,7 @@ let u$1 = [ ] ]; -eq("File \"bs_sort_test.res\", line 95, characters 5-12", Belt_SortArray.stableSortBy(u$1, (function (param, param$1) { - return param[0] - param$1[0] | 0; -})), [ +eq("File \"bs_sort_test.res\", line 95, characters 5-12", Belt_SortArray.stableSortBy(u$1, (param, param$1) => param[0] - param$1[0] | 0), [ [ 1, "a" @@ -187,9 +185,7 @@ let u$2 = [ ] ]; -eq("File \"bs_sort_test.res\", line 98, characters 4-11", Belt_SortArray.stableSortBy(u$2, (function (param, param$1) { - return param[0] - param$1[0] | 0; -})), [ +eq("File \"bs_sort_test.res\", line 98, characters 4-11", Belt_SortArray.stableSortBy(u$2, (param, param$1) => param[0] - param$1[0] | 0), [ [ 1, "b" @@ -235,9 +231,7 @@ let u$3 = [ ] ]; -eq("File \"bs_sort_test.res\", line 104, characters 4-11", Belt_SortArray.stableSortBy(u$3, (function (param, param$1) { - return param[0] - param$1[0] | 0; -})), [ +eq("File \"bs_sort_test.res\", line 104, characters 4-11", Belt_SortArray.stableSortBy(u$3, (param, param$1) => param[0] - param$1[0] | 0), [ [ 1, "c" @@ -323,13 +317,9 @@ eq("File \"bs_sort_test.res\", line 116, characters 5-12", Belt_SortArray.binary let aa = Array_data_util.range(0, 1000); -b("File \"bs_sort_test.res\", line 118, characters 4-11", Belt_Range.every(0, 1000, (function (i) { - return Belt_SortArray.binarySearchBy(aa, i, cmp) === i; -}))); +b("File \"bs_sort_test.res\", line 118, characters 4-11", Belt_Range.every(0, 1000, i => Belt_SortArray.binarySearchBy(aa, i, cmp) === i)); -let cc = Belt_Array.map(Array_data_util.range(0, 2000), (function (x) { - return (x << 1); -})); +let cc = Belt_Array.map(Array_data_util.range(0, 2000), x => (x << 1)); eq("File \"bs_sort_test.res\", line 121, characters 5-12", Belt_SortArray.binarySearchBy(cc, 5000, cmp) ^ -1, 2001); @@ -339,9 +329,7 @@ eq("File \"bs_sort_test.res\", line 123, characters 5-12", Belt_SortArray.binary eq("File \"bs_sort_test.res\", line 125, characters 5-12", Belt_SortArray.binarySearchBy(cc, 1, cmp) ^ -1, 1); -b("File \"bs_sort_test.res\", line 126, characters 6-13", Belt_Range.every(0, 1999, (function (i) { - return (Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp) ^ -1) === (i + 1 | 0); -}))); +b("File \"bs_sort_test.res\", line 126, characters 6-13", Belt_Range.every(0, 1999, i => (Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp) ^ -1) === (i + 1 | 0))); function lt(x, y) { return x < y; diff --git a/jscomp/test/bs_stack_test.js b/jscomp/test/bs_stack_test.js index 793432b9f3..f30fee5221 100644 --- a/jscomp/test/bs_stack_test.js +++ b/jscomp/test/bs_stack_test.js @@ -63,7 +63,7 @@ function inOrder3(v) { Belt_MutableStack.push(s, v$1); current = v$1.left; }; - Belt_MutableStack.dynamicPopIter(s, (function (popped) { + Belt_MutableStack.dynamicPopIter(s, popped => { Belt_MutableQueue.add(q, popped.value); let current = popped.right; while (current !== undefined) { @@ -71,7 +71,7 @@ function inOrder3(v) { Belt_MutableStack.push(s, v); current = v.left; }; - })); + }); return Belt_MutableQueue.toArray(q); } diff --git a/jscomp/test/bs_string_test.js b/jscomp/test/bs_string_test.js index 7570541190..3dc70613f0 100644 --- a/jscomp/test/bs_string_test.js +++ b/jscomp/test/bs_string_test.js @@ -16,21 +16,17 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents }; } -eq("File \"bs_string_test.res\", line 10, characters 2-9", "ghso ghso g".split(" ").reduce((function (x, y) { - return x + ("-" + y); -}), ""), "-ghso-ghso-g"); +eq("File \"bs_string_test.res\", line 10, characters 2-9", "ghso ghso g".split(" ").reduce((x, y) => x + ("-" + y), ""), "-ghso-ghso-g"); Mt.from_pair_suites("Bs_string_test", suites.contents); diff --git a/jscomp/test/buffer_test.js b/jscomp/test/buffer_test.js index 8c5c3c9701..b67e35703a 100644 --- a/jscomp/test/buffer_test.js +++ b/jscomp/test/buffer_test.js @@ -11,25 +11,23 @@ let v = "gso"; let suites_0 = [ "equal", - (function (param) { - return { - TAG: "Eq", - _0: [ - Caml_bytes.get(Bytes.make(3, /* 'a' */97), 0), - Bytes.make(3, /* 'a' */97)[0] - ], - _1: [ - /* 'a' */97, - /* 'a' */97 - ] - }; + param => ({ + TAG: "Eq", + _0: [ + Caml_bytes.get(Bytes.make(3, /* 'a' */97), 0), + Bytes.make(3, /* 'a' */97)[0] + ], + _1: [ + /* 'a' */97, + /* 'a' */97 + ] }) ]; let suites_1 = { hd: [ "equal2", - (function (param) { + param => { let u = Bytes.make(3, /* 'a' */97); u[0] = /* 'b' */98; return { @@ -43,12 +41,12 @@ let suites_1 = { /* 'g' */103 ] }; - }) + } ], tl: { hd: [ "buffer", - (function (param) { + param => { let v = Buffer.create(30); for (let i = 0; i <= 10; ++i) { Buffer.add_string(v, String(i)); @@ -58,7 +56,7 @@ let suites_1 = { _0: Buffer.contents(v), _1: "012345678910" }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/bytes_split_gpr_743_test.js b/jscomp/test/bytes_split_gpr_743_test.js index 476a31379c..7ab680613a 100644 --- a/jscomp/test/bytes_split_gpr_743_test.js +++ b/jscomp/test/bytes_split_gpr_743_test.js @@ -20,12 +20,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/caml_compare_bigint_test.js b/jscomp/test/caml_compare_bigint_test.js index 1427f44a73..7d451210b5 100644 --- a/jscomp/test/caml_compare_bigint_test.js +++ b/jscomp/test/caml_compare_bigint_test.js @@ -9,199 +9,163 @@ function isLessThan(title, small, big) { return { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.compare(big, small) > 0 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.compare(big, small) > 0 }) ], tl: { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.compare(small, big) < 0 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.compare(small, big) < 0 }) ], tl: { hd: [ "< operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(small, big) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(small, big) }) ], tl: { hd: [ "<= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessequal(small, big) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessequal(small, big) }) ], tl: { hd: [ "> operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan(big, small) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan(big, small) }) ], tl: { hd: [ ">= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterequal(big, small) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterequal(big, small) }) ], tl: { hd: [ "min: " + title, - (function (param) { - return { - TAG: "Eq", - _0: small, - _1: Caml_obj.min(big, small) - }; + param => ({ + TAG: "Eq", + _0: small, + _1: Caml_obj.min(big, small) }) ], tl: { hd: [ "min: " + title, - (function (param) { - return { - TAG: "Eq", - _0: small, - _1: Caml_obj.min(small, big) - }; + param => ({ + TAG: "Eq", + _0: small, + _1: Caml_obj.min(small, big) }) ], tl: { hd: [ "max: " + title, - (function (param) { - return { - TAG: "Eq", - _0: big, - _1: Caml_obj.max(big, small) - }; + param => ({ + TAG: "Eq", + _0: big, + _1: Caml_obj.max(big, small) }) ], tl: { hd: [ "max: " + title, - (function (param) { - return { - TAG: "Eq", - _0: big, - _1: Caml_obj.max(small, big) - }; + param => ({ + TAG: "Eq", + _0: big, + _1: Caml_obj.max(small, big) }) ], tl: { hd: [ "!== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: big !== small - }; + param => ({ + TAG: "Eq", + _0: true, + _1: big !== small }) ], tl: { hd: [ "!== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: small !== big - }; + param => ({ + TAG: "Eq", + _0: true, + _1: small !== big }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.notequal(big, small) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.notequal(big, small) }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.notequal(small, big) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.notequal(small, big) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal(big, small) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal(big, small) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal(small, big) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal(small, big) }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: big === small - }; + param => ({ + TAG: "Eq", + _0: false, + _1: big === small }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: small === big - }; + param => ({ + TAG: "Eq", + _0: false, + _1: small === big }) ], tl: /* [] */0 @@ -229,177 +193,145 @@ function isEqual(title, num1, num2) { return { hd: [ "< operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.lessthan(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.lessthan(num2, num1) }) ], tl: { hd: [ "<= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessequal(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessequal(num2, num1) }) ], tl: { hd: [ "> operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.greaterthan(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.greaterthan(num1, num2) }) ], tl: { hd: [ ">= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterequal(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterequal(num1, num2) }) ], tl: { hd: [ "min: " + title, - (function (param) { - return { - TAG: "Eq", - _0: num1, - _1: Caml_obj.min(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: num1, + _1: Caml_obj.min(num1, num2) }) ], tl: { hd: [ "max: " + title, - (function (param) { - return { - TAG: "Eq", - _0: num1, - _1: Caml_obj.max(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: num1, + _1: Caml_obj.max(num1, num2) }) ], tl: { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Caml_obj.compare(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Caml_obj.compare(num1, num2) }) ], tl: { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Caml_obj.compare(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Caml_obj.compare(num2, num1) }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: num1 !== num2 - }; + param => ({ + TAG: "Eq", + _0: false, + _1: num1 !== num2 }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: num2 !== num1 - }; + param => ({ + TAG: "Eq", + _0: false, + _1: num2 !== num1 }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.notequal(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.notequal(num1, num2) }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.notequal(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.notequal(num2, num1) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.equal(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.equal(num1, num2) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.equal(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.equal(num2, num1) }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: num1 === num2 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: num1 === num2 }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: num2 === num1 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: num2 === num1 }) ], tl: /* [] */0 diff --git a/jscomp/test/caml_compare_test.js b/jscomp/test/caml_compare_test.js index 2df1c2ab5b..2ecd05a679 100644 --- a/jscomp/test/caml_compare_test.js +++ b/jscomp/test/caml_compare_test.js @@ -8,11 +8,7 @@ let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); let function_equal_test; try { - function_equal_test = Caml_obj.equal((function (x) { - return x + 1 | 0; - }), (function (x) { - return x + 2 | 0; - })); + function_equal_test = Caml_obj.equal(x => x + 1 | 0, x => x + 2 | 0); } catch (raw_exn) { let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); function_equal_test = exn.RE_EXN_ID === "Invalid_argument" && exn._1 === "equal: functional value" ? true : false; @@ -22,47 +18,67 @@ let suites = { contents: { hd: [ "File \"caml_compare_test.res\", line 12, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(undefined, 1) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(undefined, 1) }) ], tl: { hd: [ "option2", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(1, 2) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(1, 2) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 14, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan({ - hd: 1, - tl: /* [] */0 - }, /* [] */0) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan({ + hd: 1, + tl: /* [] */0 + }, /* [] */0) }) ], tl: { hd: [ "listeq", - (function () { - return { + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.equal({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }) + }) + ], + tl: { + hd: [ + "listneq", + () => ({ TAG: "Eq", _0: true, - _1: Caml_obj.equal({ + _1: Caml_obj.greaterthan({ hd: 1, tl: { hd: 2, @@ -76,51 +92,57 @@ let suites = { tl: { hd: 2, tl: { - hd: 3, + hd: 2, tl: /* [] */0 } } }) - }; - }) - ], - tl: { - hd: [ - "listneq", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }) - }; }) ], tl: { hd: [ "custom_u", - (function () { - return { + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan([ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 1 + } + ], [ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 0 + } + ]) + }) + ], + tl: { + hd: [ + "custom_u2", + () => ({ TAG: "Eq", _0: true, - _1: Caml_obj.greaterthan([ + _1: Caml_obj.equal([ { TAG: "A", _0: 3 @@ -146,128 +168,78 @@ let suites = { }, { TAG: "C", - _0: 0 + _0: 1 } ]) - }; - }) - ], - tl: { - hd: [ - "custom_u2", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.equal([ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 1 - } - ], [ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 1 - } - ]) - }; }) ], tl: { hd: [ "function", - (function () { - return { - TAG: "Eq", - _0: true, - _1: function_equal_test - }; + () => ({ + TAG: "Eq", + _0: true, + _1: function_equal_test }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 20, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(undefined, 1) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(undefined, 1) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 21, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(undefined, [ - 1, - 30 - ]) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(undefined, [ + 1, + 30 + ]) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 22, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan([ - 1, - 30 - ], undefined) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan([ + 1, + 30 + ], undefined) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 24, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan({ - hd: 2, + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -275,28 +247,28 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -305,73 +277,67 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 27, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan({ - hd: 1, + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan({ + hd: 1, + tl: /* [] */0 + }, { + hd: 1, + tl: { + hd: 409, tl: /* [] */0 - }, { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 28, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(/* [] */0, { - hd: 409, - tl: /* [] */0 - }) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(/* [] */0, { + hd: 409, + tl: /* [] */0 + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 30, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan({ - hd: 2, + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -380,26 +346,26 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -407,59 +373,53 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 33, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: false, - _1: false - }; + () => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 34, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: false, - _1: false - }; + () => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 36, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal({ - hd: 2, + () => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -467,28 +427,28 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -497,39 +457,37 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 40, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal({ - hd: 2, + () => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -538,26 +496,26 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -565,351 +523,325 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "cmp_id", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1, - y: 2 - }, { - x: 1, - y: 2 - }), - _1: 0 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1, + y: 2 + }, { + x: 1, + y: 2 + }), + _1: 0 }) ], tl: { hd: [ "cmp_val", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1 - }, { - x: 2 - }), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1 + }, { + x: 2 + }), + _1: -1 }) ], tl: { hd: [ "cmp_val2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 2 - }, { - x: 1 - }), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 2 + }, { + x: 1 + }), + _1: 1 }) ], tl: { hd: [ "cmp_empty", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({}, {}), - _1: 0 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({}, {}), + _1: 0 }) ], tl: { hd: [ "cmp_empty2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({}, {x:1}), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({}, {x:1}), + _1: -1 }) ], tl: { hd: [ "cmp_swap", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1, - y: 2 - }, { - y: 2, - x: 1 - }), - _1: 0 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1, + y: 2 + }, { + y: 2, + x: 1 + }), + _1: 0 }) ], tl: { hd: [ "cmp_size", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({x:1}, {x:1, y:2}), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({x:1}, {x:1, y:2}), + _1: -1 }) ], tl: { hd: [ "cmp_size2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({x:1, y:2}, {x:1}), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({x:1, y:2}, {x:1}), + _1: 1 }) ], tl: { hd: [ "cmp_order", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 0, - y: 1 - }, { - x: 1, - y: 0 - }), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 0, + y: 1 + }, { + x: 1, + y: 0 + }), + _1: -1 }) ], tl: { hd: [ "cmp_order2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1, - y: 0 - }, { - x: 0, - y: 1 - }), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1, + y: 0 + }, { + x: 0, + y: 1 + }), + _1: 1 }) ], tl: { hd: [ "cmp_in_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + hd: { + x: 1 + }, + tl: /* [] */0 + }, { + hd: { + x: 2 + }, + tl: /* [] */0 + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_in_list2", + () => ({ TAG: "Eq", _0: Caml_obj.compare({ hd: { - x: 1 + x: 2 }, tl: /* [] */0 }, { hd: { - x: 2 + x: 1 }, tl: /* [] */0 }), - _1: -1 - }; - }) - ], - tl: { - hd: [ - "cmp_in_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - hd: { - x: 2 - }, - tl: /* [] */0 - }, { - hd: { - x: 1 - }, - tl: /* [] */0 - }), - _1: 1 - }; + _1: 1 }) ], tl: { hd: [ "cmp_with_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: { + hd: 0, + tl: /* [] */0 + } + }, { + x: { + hd: 1, + tl: /* [] */0 + } + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_with_list2", + () => ({ TAG: "Eq", _0: Caml_obj.compare({ x: { - hd: 0, + hd: 1, tl: /* [] */0 } }, { x: { - hd: 1, + hd: 0, tl: /* [] */0 } }), - _1: -1 - }; - }) - ], - tl: { - hd: [ - "cmp_with_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: { - hd: 1, - tl: /* [] */0 - } - }, { - x: { - hd: 0, - tl: /* [] */0 - } - }), - _1: 1 - }; + _1: 1 }) ], tl: { hd: [ "eq_id", - (function () { - return { - TAG: "Ok", - _0: Caml_obj.equal({ - x: 1, - y: 2 - }, { - x: 1, - y: 2 - }) - }; + () => ({ + TAG: "Ok", + _0: Caml_obj.equal({ + x: 1, + y: 2 + }, { + x: 1, + y: 2 + }) }) ], tl: { hd: [ "eq_val", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - x: 1 - }, { - x: 2 - }), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + x: 1 + }, { + x: 2 + }), + _1: false }) ], tl: { hd: [ "eq_val2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - x: 2 - }, { - x: 1 - }), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + x: 2 + }, { + x: 1 + }), + _1: false }) ], tl: { hd: [ "eq_empty", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({}, {}), - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({}, {}), + _1: true }) ], tl: { hd: [ "eq_empty2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({}, {x:1}), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({}, {x:1}), + _1: false }) ], tl: { hd: [ "eq_swap", - (function () { - return { - TAG: "Ok", - _0: Caml_obj.equal({ - x: 1, - y: 2 - }, { - y: 2, - x: 1 - }) - }; + () => ({ + TAG: "Ok", + _0: Caml_obj.equal({ + x: 1, + y: 2 + }, { + y: 2, + x: 1 + }) }) ], tl: { hd: [ "eq_size", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({x:1}, {x:1, y:2}), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({x:1}, {x:1, y:2}), + _1: false }) ], tl: { hd: [ "eq_size2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({x:1, y:2}, {x:1}), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({x:1, y:2}, {x:1}), + _1: false }) ], tl: { hd: [ "eq_in_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + hd: { + x: 1 + }, + tl: /* [] */0 + }, { + hd: { + x: 2 + }, + tl: /* [] */0 + }), + _1: false + }) + ], + tl: { + hd: [ + "eq_in_list2", + () => ({ TAG: "Eq", _0: Caml_obj.equal({ hd: { - x: 1 + x: 2 }, tl: /* [] */0 }, { @@ -918,36 +850,32 @@ let suites = { }, tl: /* [] */0 }), - _1: false - }; - }) - ], - tl: { - hd: [ - "eq_in_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - hd: { - x: 2 - }, - tl: /* [] */0 - }, { - hd: { - x: 2 - }, - tl: /* [] */0 - }), - _1: true - }; + _1: true }) ], tl: { hd: [ "eq_with_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + x: { + hd: 0, + tl: /* [] */0 + } + }, { + x: { + hd: 0, + tl: /* [] */0 + } + }), + _1: true + }) + ], + tl: { + hd: [ + "eq_with_list2", + () => ({ TAG: "Eq", _0: Caml_obj.equal({ x: { @@ -956,116 +884,80 @@ let suites = { } }, { x: { - hd: 0, + hd: 1, tl: /* [] */0 } }), - _1: true - }; - }) - ], - tl: { - hd: [ - "eq_with_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - x: { - hd: 0, - tl: /* [] */0 - } - }, { - x: { - hd: 1, - tl: /* [] */0 - } - }), - _1: false - }; + _1: false }) ], tl: { hd: [ "eq_no_prototype", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({x:1}, ((function(){let o = Object.create(null);o.x = 1;return o;})())), - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({x:1}, ((function(){let o = Object.create(null);o.x = 1;return o;})())), + _1: true }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 76, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(null, { - hd: 3, - tl: /* [] */0 - }), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(null, { + hd: 3, + tl: /* [] */0 + }), + _1: -1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 77, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - hd: 3, - tl: /* [] */0 - }, null), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + hd: 3, + tl: /* [] */0 + }, null), + _1: 1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 78, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(null, 0), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(null, 0), + _1: -1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 79, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(0, null), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(0, null), + _1: 1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 80, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(undefined, 0), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(undefined, 0), + _1: -1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 81, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(0, undefined), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(0, undefined), + _1: 1 }) ], tl: /* [] */0 diff --git a/jscomp/test/caml_format_test.js b/jscomp/test/caml_format_test.js index f184d33bb2..cd25cfec4b 100644 --- a/jscomp/test/caml_format_test.js +++ b/jscomp/test/caml_format_test.js @@ -79,26 +79,22 @@ let of_string = [ ]; function from_float_of_string(xs) { - return $$Array.mapi((function (i, param) { - return Pervasives.string_of_float; - }), xs); + return $$Array.mapi((i, param) => Pervasives.string_of_float, xs); } function from_of_string(xs) { - return $$Array.to_list($$Array.mapi((function (i, param) { + return $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "of_string " + String(i), - (function (param) { - return { - TAG: "Eq", - _0: Caml_format.int_of_string(b), - _1: a - }; + param => ({ + TAG: "Eq", + _0: Caml_format.int_of_string(b), + _1: a }) ]; - }), of_string)); + }, of_string)); } let to_str = Caml_format.int_of_string; @@ -144,67 +140,57 @@ let pairs$1 = [ let suites = Pervasives.$at(from_of_string(of_string), Pervasives.$at({ hd: [ "isnan_of_string", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Pervasives.classify_float(Caml_format.float_of_string("nan")) === "FP_nan" - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Pervasives.classify_float(Caml_format.float_of_string("nan")) === "FP_nan" }) ], tl: /* [] */0 -}, Pervasives.$at($$Array.to_list($$Array.mapi((function (i, param) { +}, Pervasives.$at($$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "infinity_of_string " + String(i), - (function () { - return { - TAG: "Eq", - _0: a, - _1: Pervasives.classify_float(Caml_format.float_of_string(b)) - }; + () => ({ + TAG: "Eq", + _0: a, + _1: Pervasives.classify_float(Caml_format.float_of_string(b)) }) ]; -}), pairs)), Pervasives.$at({ +}, pairs)), Pervasives.$at({ hd: [ "throw", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_format.float_of_string(""); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_format.float_of_string(""); + } }) ], tl: { hd: [ "format_int", - (function () { - return { - TAG: "Eq", - _0: " 33", - _1: Caml_format.format_int("%32d", 33) - }; + () => ({ + TAG: "Eq", + _0: " 33", + _1: Caml_format.format_int("%32d", 33) }) ], tl: /* [] */0 } -}, $$Array.to_list($$Array.mapi((function (i, param) { +}, $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "normal_float_of_string " + String(i), - (function () { - return { - TAG: "Eq", - _0: a, - _1: Caml_format.float_of_string(b) - }; + () => ({ + TAG: "Eq", + _0: a, + _1: Caml_format.float_of_string(b) }) ]; -}), pairs$1)))))); +}, pairs$1)))))); function ff(extra) { return Caml_format.format_int("%32d", extra); @@ -320,41 +306,35 @@ let float_data = [ let int64_suites_0 = [ "i64_simple7", - (function (param) { - return { - TAG: "Eq", - _0: Caml_int64.to_string([ - 0, - 3333 - ]), - _1: "3333" - }; + param => ({ + TAG: "Eq", + _0: Caml_int64.to_string([ + 0, + 3333 + ]), + _1: "3333" }) ]; let int64_suites_1 = { hd: [ "i64_simple15", - (function (param) { - return { - TAG: "Eq", - _0: Caml_int64.to_string(Caml_int64.neg_one), - _1: "-1" - }; + param => ({ + TAG: "Eq", + _0: Caml_int64.to_string(Caml_int64.neg_one), + _1: "-1" }) ], tl: { hd: [ "i64_simple16", - (function (param) { - return { - TAG: "Eq", - _0: Caml_int64.to_string([ - -1, - 4294956185 - ]), - _1: "-11111" - }; + param => ({ + TAG: "Eq", + _0: Caml_int64.to_string([ + -1, + 4294956185 + ]), + _1: "-11111" }) ], tl: /* [] */0 @@ -423,34 +403,30 @@ let of_string_data = [ ] ]; -Mt.from_pair_suites("Caml_format_test", Pervasives.$at(suites, Pervasives.$at($$Array.to_list($$Array.mapi((function (i, param) { +Mt.from_pair_suites("Caml_format_test", Pervasives.$at(suites, Pervasives.$at($$Array.to_list($$Array.mapi((i, param) => { let str_result = param[2]; let f = param[1]; let fmt = param[0]; return [ "loat_format " + String(i), - (function () { - return { - TAG: "Eq", - _0: Caml_format.format_float(fmt, f), - _1: str_result - }; + () => ({ + TAG: "Eq", + _0: Caml_format.format_float(fmt, f), + _1: str_result }) ]; -}), float_data)), Pervasives.$at(int64_suites, $$Array.to_list($$Array.mapi((function (i, param) { +}, float_data)), Pervasives.$at(int64_suites, $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "int64_of_string " + String(i) + " ", - (function () { - return { - TAG: "Eq", - _0: Caml_format.int64_of_string(b), - _1: a - }; + () => ({ + TAG: "Eq", + _0: Caml_format.int64_of_string(b), + _1: a }) ]; -}), of_string_data)))))); +}, of_string_data)))))); let float_suites = { hd: "float_nan", diff --git a/jscomp/test/chain_code_test.js b/jscomp/test/chain_code_test.js index a290de375a..74d651ce60 100644 --- a/jscomp/test/chain_code_test.js +++ b/jscomp/test/chain_code_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/chn_test.js b/jscomp/test/chn_test.js index a3f98dfeb4..306622fec7 100644 --- a/jscomp/test/chn_test.js +++ b/jscomp/test/chn_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -35,7 +33,7 @@ console.log("你好,\n世界"); console.log("\x3f\u003f\b\t\n\v\f\r\0\"'"); function convert(s) { - return $$Array.to_list(Array.from(s, (function (x) { + return $$Array.to_list(Array.from(s, x => { let x$1 = x.codePointAt(0); if (x$1 !== undefined) { return x$1; @@ -50,7 +48,7 @@ function convert(s) { ] } }); - }))); + })); } eq("File \"chn_test.res\", line 24, characters 4-11", "你好,\n世界", "你好,\n世界"); diff --git a/jscomp/test/class_type_ffi_test.js b/jscomp/test/class_type_ffi_test.js index b38f435362..ad02e32fbc 100644 --- a/jscomp/test/class_type_ffi_test.js +++ b/jscomp/test/class_type_ffi_test.js @@ -19,9 +19,7 @@ function off2(o, 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 (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); } exports.test_set = test_set; diff --git a/jscomp/test/coercion_module_alias_test.js b/jscomp/test/coercion_module_alias_test.js index 996ebb34db..5d8e7c4612 100644 --- a/jscomp/test/coercion_module_alias_test.js +++ b/jscomp/test/coercion_module_alias_test.js @@ -27,9 +27,7 @@ console.log(prim$2); let f = List.length; function g(x) { - return List.length(List.map((function (prim) { - return prim + 1 | 0; - }), x)); + return List.length(List.map(prim => prim + 1 | 0, x)); } function F(X) { diff --git a/jscomp/test/complex_if_test.js b/jscomp/test/complex_if_test.js index cdd266d2cb..15a13ed2bc 100644 --- a/jscomp/test/complex_if_test.js +++ b/jscomp/test/complex_if_test.js @@ -122,12 +122,10 @@ function string_escaped(s) { let suites_0 = [ "complete_escape", - (function (param) { - return { - TAG: "Eq", - _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" - }; + param => ({ + TAG: "Eq", + _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/complex_test.js b/jscomp/test/complex_test.js index 042a16c82b..e822054260 100644 --- a/jscomp/test/complex_test.js +++ b/jscomp/test/complex_test.js @@ -6,15 +6,13 @@ let Complex = require("../../lib/js/complex.js"); let suites_0 = [ "basic_add", - (function (param) { - return { - TAG: "Eq", - _0: { - re: 2, - im: 2 - }, - _1: Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i) - }; + param => ({ + TAG: "Eq", + _0: { + re: 2, + im: 2 + }, + _1: Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i) }) ]; diff --git a/jscomp/test/complex_while_loop.js b/jscomp/test/complex_while_loop.js index 89e5f7a681..74fe66fea8 100644 --- a/jscomp/test/complex_while_loop.js +++ b/jscomp/test/complex_while_loop.js @@ -4,8 +4,8 @@ function f() { let n = 0; - while ((function () { - let fib = function (x) { + while ((() => { + let fib = x => { if (x === 0 || x === 1) { return 1; } else { @@ -20,7 +20,7 @@ function f() { } function ff() { - while ((function () { + while ((() => { let b = 9; return (3 + b | 0) > 10; })()) { diff --git a/jscomp/test/condition_compilation_test.js b/jscomp/test/condition_compilation_test.js index 74f9d79ea3..da2f401b42 100644 --- a/jscomp/test/condition_compilation_test.js +++ b/jscomp/test/condition_compilation_test.js @@ -24,12 +24,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/const_block_test.js b/jscomp/test/const_block_test.js index e436304834..bbe5d66ae1 100644 --- a/jscomp/test/const_block_test.js +++ b/jscomp/test/const_block_test.js @@ -57,7 +57,7 @@ let suites_0 = [ let suites_1 = { hd: [ "avoid_mutable_inline_test", - (function () { + () => { Caml_array.set(c, 0, 3); Caml_array.set(c, 1, 4); return { @@ -72,7 +72,7 @@ let suites_1 = { ], _1: c }; - }) + } ], tl: /* [] */0 }; diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 31fe97de7a..89b9d6eb94 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -9,24 +9,22 @@ function test() { let v = { contents: 0 }; - let f = function (_n, _acc) { + let f = (_n, _acc) => { while (true) { let acc = _acc; let n = _n; if (n === 0) { return acc(); } - _acc = (function () { + _acc = () => { v.contents = v.contents + n | 0; return acc(); - }); + }; _n = n - 1 | 0; continue; }; }; - f(10, (function () { - - })); + f(10, () => {}); return v.contents; } @@ -34,17 +32,13 @@ function test_closure() { let v = { contents: 0 }; - let arr = Caml_array.make(6, (function (x) { - return x; - })); + let arr = Caml_array.make(6, x => x); for (let i = 0; i <= 5; ++i) { - Caml_array.set(arr, i, (function (param) { - return i; - })); + Caml_array.set(arr, i, param => i); } - $$Array.iter((function (i) { + $$Array.iter(i => { v.contents = v.contents + i(0) | 0; - }), arr); + }, arr); return v.contents; } @@ -52,52 +46,42 @@ function test_closure2() { let v = { contents: 0 }; - let arr = Caml_array.make(6, (function (x) { - return x; - })); + let arr = Caml_array.make(6, x => x); for (let i = 0; i <= 5; ++i) { let j = i + i | 0; - Caml_array.set(arr, i, (function (param) { - return j; - })); + Caml_array.set(arr, i, param => j); } - $$Array.iter((function (i) { + $$Array.iter(i => { v.contents = v.contents + i(0) | 0; - }), arr); + }, arr); return v.contents; } Mt.from_pair_suites("Cps_test", { hd: [ "cps_test_sum", - (function () { - return { - TAG: "Eq", - _0: 55, - _1: test() - }; + () => ({ + TAG: "Eq", + _0: 55, + _1: test() }) ], tl: { hd: [ "cps_test_closure", - (function () { - return { - TAG: "Eq", - _0: 15, - _1: test_closure() - }; + () => ({ + TAG: "Eq", + _0: 15, + _1: test_closure() }) ], tl: { hd: [ "cps_test_closure2", - (function () { - return { - TAG: "Eq", - _0: 30, - _1: test_closure2() - }; + () => ({ + TAG: "Eq", + _0: 30, + _1: test_closure2() }) ], tl: /* [] */0 diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index 2148270da4..f506133343 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -41,11 +41,9 @@ function f(extra) { } ReactDom.render(React.createClass({ - render: (function () { - return React.DOM.div({ - alt: "pic" - }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!")); - }) + render: () => React.DOM.div({ + alt: "pic" + }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!")) }), document.getElementById("hi")); exports.fib = fib; diff --git a/jscomp/test/demo_pipe.js b/jscomp/test/demo_pipe.js index 2a83141fe6..ade4eaf5be 100644 --- a/jscomp/test/demo_pipe.js +++ b/jscomp/test/demo_pipe.js @@ -3,11 +3,11 @@ function register(rl) { - return rl.on("line", (function (x) { + return rl.on("line", x => { console.log(x); - })).on("close", (function () { + }).on("close", () => { console.log("finished"); - })); + }); } exports.register = register; diff --git a/jscomp/test/digest_test.js b/jscomp/test/digest_test.js index f6f053b4cc..732af43acb 100644 --- a/jscomp/test/digest_test.js +++ b/jscomp/test/digest_test.js @@ -148,67 +148,55 @@ let ref = [ Mt.from_pair_suites("Digest_test", Pervasives.$at({ hd: [ "File \"digest_test.res\", line 9, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("value")), - _1: "2063c1608d6e0baf80249c42e2be5804" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("value")), + _1: "2063c1608d6e0baf80249c42e2be5804" }) ], tl: { hd: [ "File \"digest_test.res\", line 11, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog")), - _1: "9e107d9d372bb6826bd81d3542a419d6" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog")), + _1: "9e107d9d372bb6826bd81d3542a419d6" }) ], tl: { hd: [ "File \"digest_test.res\", line 18, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.")), - _1: "e4d909c290d0fb1ca068ffaddf22cbd0" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.")), + _1: "e4d909c290d0fb1ca068ffaddf22cbd0" }) ], tl: { hd: [ "File \"digest_test.res\", line 24, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("")), - _1: "d41d8cd98f00b204e9800998ecf8427e" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("")), + _1: "d41d8cd98f00b204e9800998ecf8427e" }) ], tl: { hd: [ "File \"digest_test.res\", line 26, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), - _1: "7065cc36bba1d155fb09f9d02f22e8bf" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), + _1: "7065cc36bba1d155fb09f9d02f22e8bf" }) ], tl: { hd: [ "File \"digest_test.res\", line 45, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), - _1: "b9193d1df4b7a8f0a25ffdd1005c5b2b" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), + _1: "b9193d1df4b7a8f0a25ffdd1005c5b2b" }) ], tl: /* [] */0 @@ -217,18 +205,14 @@ Mt.from_pair_suites("Digest_test", Pervasives.$at({ } } } -}, $$Array.to_list($$Array.map((function (i) { - return [ - String(i), - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("a".repeat(i))), - _1: Caml_array.get(ref, i) - }; - }) - ]; -}), Ext_array_test.range(0, 129))))); +}, $$Array.to_list($$Array.map(i => [ + String(i), + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("a".repeat(i))), + _1: Caml_array.get(ref, i) + }) +], Ext_array_test.range(0, 129))))); exports.f = f; /* Not a pure module */ diff --git a/jscomp/test/div_by_zero_test.js b/jscomp/test/div_by_zero_test.js index 6d14eeef6c..3ef3a489e5 100644 --- a/jscomp/test/div_by_zero_test.js +++ b/jscomp/test/div_by_zero_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -39,79 +37,67 @@ function add(suite) { add([ "File \"div_by_zero_test.res\", line 11, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.div(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.div(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 12, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.mod_(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.mod_(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 13, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.div(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.div(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 14, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.mod_(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.mod_(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 15, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int64.div([ - 0, - 3 - ], Caml_int64.zero); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int64.div([ + 0, + 3 + ], Caml_int64.zero); + } }) ]); add([ "File \"div_by_zero_test.res\", line 16, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int64.mod_([ - 0, - 3 - ], Caml_int64.zero); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int64.mod_([ + 0, + 3 + ], Caml_int64.zero); + } }) ]); diff --git a/jscomp/test/dollar_escape_test.js b/jscomp/test/dollar_escape_test.js index 820c31b7eb..4e8146f941 100644 --- a/jscomp/test/dollar_escape_test.js +++ b/jscomp/test/dollar_escape_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/earger_curry_test.js b/jscomp/test/earger_curry_test.js index be5e5b3cb0..8e6d741bff 100644 --- a/jscomp/test/earger_curry_test.js +++ b/jscomp/test/earger_curry_test.js @@ -6,9 +6,7 @@ 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 = x => f(x); let l = a.length; if (l === 0) { return []; @@ -21,9 +19,7 @@ function map(f, a) { } function init(l, f) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = x => f(x); if (l === 0) { return []; } @@ -43,9 +39,7 @@ function init(l, f) { } function fold_left(f, x, a) { - let f$1 = function (x, y) { - return f(x, y); - }; + let f$1 = (x, y) => f(x, y); let r = x; for (let i = 0, i_finish = a.length; i < i_finish; ++i) { r = f$1(r, a[i]); @@ -54,15 +48,9 @@ function fold_left(f, x, a) { } function f2() { - let arr = init(30000000, (function (i) { - return i; - })); - let b = map((function (i) { - return i + i - 1; - }), arr); - let v = fold_left((function (prim0, prim1) { - return prim0 + prim1; - }), 0, b); + let arr = init(30000000, i => i); + let b = map(i => i + i - 1, arr); + let v = fold_left((prim0, prim1) => prim0 + prim1, 0, b); console.log(Pervasives.string_of_float(v)); } @@ -81,12 +69,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -117,15 +103,11 @@ function add5(a0, a1, a2, a3, a4) { } function f(x) { - return function (extra, extra$1) { - return add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), extra, extra$1); - }; + return (extra, extra$1) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), extra, extra$1); } function g(x) { - let u = function (a, b) { - return add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), a, b); - }; + let u = (a, b) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), a, b); all_v.contents = { hd: v.contents, tl: all_v.contents diff --git a/jscomp/test/epsilon_test.js b/jscomp/test/epsilon_test.js index 07c8ae1e65..58cfd7092c 100644 --- a/jscomp/test/epsilon_test.js +++ b/jscomp/test/epsilon_test.js @@ -8,24 +8,20 @@ let v = (Number.EPSILON?Number.EPSILON:2.220446049250313e-16); let suites_0 = [ "epsilon", - (function (param) { - return { - TAG: "Eq", - _0: Pervasives.epsilon_float, - _1: v - }; + param => ({ + TAG: "Eq", + _0: Pervasives.epsilon_float, + _1: v }) ]; let suites_1 = { hd: [ "raw_epsilon", - (function (param) { - return { - TAG: "Eq", - _0: 2.220446049250313e-16, - _1: v - }; + param => ({ + TAG: "Eq", + _0: 2.220446049250313e-16, + _1: v }) ], tl: /* [] */0 diff --git a/jscomp/test/es6_module_test.js b/jscomp/test/es6_module_test.js index b990ee9ecb..63507f8917 100644 --- a/jscomp/test/es6_module_test.js +++ b/jscomp/test/es6_module_test.js @@ -11,29 +11,25 @@ function length(param) { Mt.from_pair_suites("Es6_module_test", { hd: [ "list_length", - (function () { - return { - TAG: "Eq", - _0: List.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }), - _1: 2 - }; + () => ({ + TAG: "Eq", + _0: List.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }), + _1: 2 }) ], tl: { hd: [ "length", - (function () { - return { - TAG: "Eq", - _0: 3, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: 3, + _1: 3 }) ], tl: /* [] */0 diff --git a/jscomp/test/event_ffi.js b/jscomp/test/event_ffi.js index d4144f53a3..55421f3adb 100644 --- a/jscomp/test/event_ffi.js +++ b/jscomp/test/event_ffi.js @@ -20,9 +20,7 @@ function h10(x) { } function h30(x) { - return function (a) { - return x(3, 3, a); - }; + return a => x(3, 3, a); } function h33(x) { @@ -42,9 +40,7 @@ function a0() { } function a1() { - return function (x) { - return x; - }; + return x => x; } function a2(x, y) { @@ -56,7 +52,7 @@ function a3(x, y, z) { } function xx() { - return function (param) { + return param => { console.log(3); }; } diff --git a/jscomp/test/exception_raise_test.js b/jscomp/test/exception_raise_test.js index 70c918c055..e847b09f39 100644 --- a/jscomp/test/exception_raise_test.js +++ b/jscomp/test/exception_raise_test.js @@ -127,28 +127,26 @@ let suites = { contents: { hd: [ "File \"exception_raise_test.res\", line 120, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: [ - f, - ff, - fff, - a0 - ], - _1: [ - 2, - 2, - 2, - 2 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + f, + ff, + fff, + a0 + ], + _1: [ + 2, + 2, + 2, + 2 + ] }) ], tl: { hd: [ "File \"exception_raise_test.res\", line 123, characters 6-13", - (function () { + () => { if (a1.RE_EXN_ID === Js_exn.$$Error) { return { TAG: "Eq", @@ -166,7 +164,7 @@ let suites = { ] } }); - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/exception_rebound_err_test.js b/jscomp/test/exception_rebound_err_test.js index 403e7a2b7f..e795fde624 100644 --- a/jscomp/test/exception_rebound_err_test.js +++ b/jscomp/test/exception_rebound_err_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/ext_array_test.js b/jscomp/test/ext_array_test.js index d3793e0f0c..7c824a62e7 100644 --- a/jscomp/test/ext_array_test.js +++ b/jscomp/test/ext_array_test.js @@ -112,9 +112,7 @@ function range(from, to_) { } }); } - return $$Array.init((to_ - from | 0) + 1 | 0, (function (i) { - return i + from | 0; - })); + return $$Array.init((to_ - from | 0) + 1 | 0, i => i + from | 0); } function map2i(f, a, b) { @@ -127,9 +125,7 @@ function map2i(f, a, b) { } }); } - return $$Array.mapi((function (i, a) { - return f(i, a, b[i]); - }), a); + return $$Array.mapi((i, a) => f(i, a, b[i]), a); } function tolist_aux(a, f, _i, _res) { diff --git a/jscomp/test/ext_bytes_test.js b/jscomp/test/ext_bytes_test.js index d011a861d0..3a7ad98c91 100644 --- a/jscomp/test/ext_bytes_test.js +++ b/jscomp/test/ext_bytes_test.js @@ -170,17 +170,13 @@ 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; -})); +let b = Bytes.init(100, i => /* '\000' */0); Bytes.blit_string(a$2, 10, b, 5, 10); eq("File \"ext_bytes_test.res\", line 141, characters 4-11", b, Bytes.of_string("\x00\x00\x00\x00\x00\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")); -let s = Bytes.init(50000, (function (i) { - return Char.chr(i % 137); -})); +let s = Bytes.init(50000, i => Char.chr(i % 137)); let s1 = Bytes.to_string(s); diff --git a/jscomp/test/ext_filename_test.js b/jscomp/test/ext_filename_test.js index e443d10358..7628c95abe 100644 --- a/jscomp/test/ext_filename_test.js +++ b/jscomp/test/ext_filename_test.js @@ -19,9 +19,7 @@ let node_parent = ".."; let node_current = "."; -let cwd = CamlinternalLazy.from_fun(function () { - return Caml_sys.sys_getcwd(); -}); +let cwd = CamlinternalLazy.from_fun(() => Caml_sys.sys_getcwd()); function path_as_directory(x) { if (x === "" || Ext_string_test.ends_with(x, Filename.dir_sep)) { @@ -33,7 +31,7 @@ function path_as_directory(x) { function absolute_path(s) { let s$1 = Filename.is_relative(s) ? Filename.concat(CamlinternalLazy.force(cwd), s) : s; - let aux = function (_s) { + let aux = _s => { while (true) { let s = _s; let base = Filename.basename(s); @@ -97,7 +95,7 @@ function relative_path(file_or_dir_1, file_or_dir_2) { let relevant_dir2 = file_or_dir_2.NAME === "File" ? 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) { + let go = (_dir1, _dir2) => { while (true) { let dir2 = _dir2; let dir1 = _dir1; @@ -106,9 +104,7 @@ function relative_path(file_or_dir_1, file_or_dir_2) { _dir1 = dir1.tl; continue; } - return Pervasives.$at(List.map((function (param) { - return node_parent; - }), dir2), dir1); + return Pervasives.$at(List.map(param => node_parent, dir2), dir1); }; }; let ys = go(dir1, dir2); @@ -141,7 +137,7 @@ function node_relative_path(node_modules_shorten, file1, dep_file) { VAL: absolute_path(file1.VAL) })) + (node_sep + Filename.basename(file2)); } - let skip = function (_i) { + let skip = _i => { while (true) { let i = _i; if (i >= len) { @@ -189,7 +185,7 @@ function find_package_json_dir(cwd) { return find_root_filename(cwd, Test_literals.bsconfig_json); } -let package_dir = CamlinternalLazy.from_fun(function () { +let package_dir = CamlinternalLazy.from_fun(() => { let cwd$1 = CamlinternalLazy.force(cwd); return find_root_filename(cwd$1, Test_literals.bsconfig_json); }); @@ -264,31 +260,27 @@ function rel_normalized_absolute_path(from, to_) { } let xs = xss.tl; if (!yss) { - return 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((acc, param) => Filename.concat(acc, Ext_string_test.parent_dir_lit), Ext_string_test.parent_dir_lit, xs); } if (xss.hd === yss.hd) { _yss = yss.tl; _xss = xs; continue; } - 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); + let start = List.fold_left((acc, param) => Filename.concat(acc, Ext_string_test.parent_dir_lit), Ext_string_test.parent_dir_lit, xs); return List.fold_left(Filename.concat, start, yss); }; } function normalize_absolute_path(x) { - let drop_if_exist = function (xs) { + let drop_if_exist = xs => { if (xs) { return xs.tl; } else { return /* [] */0; } }; - let normalize_list = function (_acc, _paths) { + let normalize_list = (_acc, _paths) => { while (true) { let paths = _paths; let acc = _acc; @@ -347,9 +339,7 @@ function get_extension(x) { let simple_convert_node_path_to_os_path; if (Sys.unix) { - simple_convert_node_path_to_os_path = (function (x) { - return x; - }); + simple_convert_node_path_to_os_path = x => x; } else if (Sys.win32 || false) { simple_convert_node_path_to_os_path = Ext_string_test.replace_slash_backward; } else { diff --git a/jscomp/test/ext_list_test.js b/jscomp/test/ext_list_test.js index 34f7d88f78..5c17bb62a0 100644 --- a/jscomp/test/ext_list_test.js +++ b/jscomp/test/ext_list_test.js @@ -29,7 +29,7 @@ function excludes(p, l) { let excluded = { contents: false }; - let aux = function (_accu, _x) { + let aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -69,7 +69,7 @@ function exclude_with_fact(p, l) { let excluded = { contents: undefined }; - let aux = function (_accu, _x) { + let aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -105,7 +105,7 @@ function exclude_with_fact2(p1, p2, l) { let excluded2 = { contents: undefined }; - let aux = function (_accu, _x) { + let aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -161,7 +161,7 @@ function same_length(_xs, _ys) { } function filter_mapi(f, xs) { - let aux = function (_i, _xs) { + let aux = (_i, _xs) => { while (true) { let xs = _xs; let i = _i; @@ -223,7 +223,7 @@ function filter_map2(f, _xs, _ys) { } function filter_map2i(f, xs, ys) { - let aux = function (_i, _xs, _ys) { + let aux = (_i, _xs, _ys) => { while (true) { let ys = _ys; let xs = _xs; @@ -648,9 +648,7 @@ function for_all_opt(p, _x) { } function fold(f, l, init) { - return List.fold_left((function (acc, i) { - return f(i, init); - }), init, l); + return List.fold_left((acc, i) => f(i, init), init, l); } function rev_map_acc(acc, f, l) { @@ -774,9 +772,7 @@ function split_map(f, xs) { function reduce_from_right(fn, lst) { let match = List.rev(lst); if (match) { - return List.fold_left((function (x, y) { - return fn(y, x); - }), match.hd, match.tl); + return List.fold_left((x, y) => fn(y, x), match.hd, match.tl); } throw new Error("Invalid_argument", { cause: { diff --git a/jscomp/test/ext_string_test.js b/jscomp/test/ext_string_test.js index c73d6f37a0..69409ccddf 100644 --- a/jscomp/test/ext_string_test.js +++ b/jscomp/test/ext_string_test.js @@ -54,7 +54,7 @@ function split_by(keep_emptyOpt, is_delim, str) { function trim(s) { let i = 0; let j = s.length; - while ((function () { + while ((() => { let tmp = false; if (i < j) { let u = s.codePointAt(i); @@ -65,7 +65,7 @@ function trim(s) { i = i + 1 | 0; }; let k = j - 1 | 0; - while ((function () { + while ((() => { let tmp = false; if (k >= i) { let u = s.codePointAt(k); @@ -82,20 +82,18 @@ function split(keep_empty, str, on) { if (str === "") { return /* [] */0; } else { - return split_by(keep_empty, (function (x) { - return x === on; - }), str); + return split_by(keep_empty, x => x === on, str); } } function quick_split_by_ws(str) { - return split_by(false, (function (x) { + return split_by(false, x => { if (x === /* '\t' */9 || x === /* '\n' */10) { return true; } else { return x === /* ' ' */32; } - }), str); + }, str); } function starts_with(s, beg) { @@ -147,9 +145,7 @@ function ends_with_then_chop(s, beg) { } function check_any_suffix_case(s, suffixes) { - return List.exists((function (x) { - return ends_with(s, x); - }), suffixes); + return List.exists(x => ends_with(s, x), suffixes); } function check_any_suffix_case_then_chop(s, suffixes) { @@ -169,7 +165,7 @@ function check_any_suffix_case_then_chop(s, suffixes) { } function escaped(s) { - let needs_escape = function (_i) { + let needs_escape = _i => { while (true) { let i = _i; if (i >= s.length) { @@ -449,7 +445,7 @@ function is_valid_module_file(s) { } else if (match < 65) { return false; } - return unsafe_for_all_range(s, 1, len - 1 | 0, (function (x) { + return unsafe_for_all_range(s, 1, len - 1 | 0, x => { if (x >= 65) { if (x > 96 || x < 91) { return x < 123; @@ -461,7 +457,7 @@ function is_valid_module_file(s) { } else { return x === 39; } - })); + }); } function is_valid_npm_package_name(s) { @@ -481,7 +477,7 @@ function is_valid_npm_package_name(s) { } else if (match !== 64) { return false; } - return unsafe_for_all_range(s, 1, len - 1 | 0, (function (x) { + return unsafe_for_all_range(s, 1, len - 1 | 0, x => { if (x >= 58) { if (x >= 97) { return x < 123; @@ -493,7 +489,7 @@ function is_valid_npm_package_name(s) { } else { return true; } - })); + }); } function is_valid_source_name(name) { @@ -575,13 +571,13 @@ function replace_slash_backward(x) { if (unsafe_no_char(x, /* '/' */47, 0, len - 1 | 0)) { return x; } else { - return $$String.map((function (x) { + return $$String.map(x => { if (x !== 47) { return x; } else { return /* '\\' */92; } - }), x); + }, x); } } @@ -590,13 +586,13 @@ function replace_backward_slash(x) { if (unsafe_no_char(x, /* '\\' */92, 0, len - 1 | 0)) { return x; } else { - return $$String.map((function (x) { + return $$String.map(x => { if (x !== 92) { return x; } else { return /* '/' */47; } - }), x); + }, x); } } diff --git a/jscomp/test/extensible_variant_test.js b/jscomp/test/extensible_variant_test.js index dbebc62d58..cfadcd2dde 100644 --- a/jscomp/test/extensible_variant_test.js +++ b/jscomp/test/extensible_variant_test.js @@ -38,46 +38,40 @@ function to_int(x) { let suites_0 = [ "test_int", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: to_int({ - RE_EXN_ID: Int, - _1: 3, - _2: 0 - }) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: to_int({ + RE_EXN_ID: Int, + _1: 3, + _2: 0 + }) }) ]; let suites_1 = { hd: [ "test_int2", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: to_int({ - RE_EXN_ID: Int$1, - _1: 3, - _2: 0 - }) - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: to_int({ + RE_EXN_ID: Int$1, + _1: 3, + _2: 0 + }) }) ], tl: { hd: [ "test_string", - (function (param) { - return { - TAG: "Eq", - _0: -1, - _1: to_int({ - RE_EXN_ID: Str, - _1: "x" - }) - }; + param => ({ + TAG: "Eq", + _0: -1, + _1: to_int({ + RE_EXN_ID: Str, + _1: "x" + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/ffi_arity_test.js b/jscomp/test/ffi_arity_test.js index eb3eb30760..ad382cb1b0 100644 --- a/jscomp/test/ffi_arity_test.js +++ b/jscomp/test/ffi_arity_test.js @@ -5,13 +5,9 @@ let Mt = require("./mt.js"); function f(v) { if (v % 2 === 0) { - return function (v) { - return Math.imul(v, v); - }; + return v => Math.imul(v, v); } else { - return function (v) { - return v + v | 0; - }; + return v => v + v | 0; } } @@ -19,25 +15,19 @@ let v = [ 1, 2, 3 -].map(function (a, b) { - return f(a)(b); -}); +].map((a, b) => f(a)(b)); let vv = [ 1, 2, 3 -].map(function (a, b) { - return a + b | 0; -}); +].map((a, b) => a + b | 0); let hh = [ "1", "2", "3" -].map(function (x) { - return parseInt(x); -}); +].map(x => parseInt(x)); function u() { return 3; @@ -70,46 +60,40 @@ fff(); Mt.from_pair_suites("Ffi_arity_test", { hd: [ "File \"ffi_arity_test.res\", line 51, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: v, - _1: [ - 0, - 1, - 4 - ] - }; + () => ({ + TAG: "Eq", + _0: v, + _1: [ + 0, + 1, + 4 + ] }) ], tl: { hd: [ "File \"ffi_arity_test.res\", line 52, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: vv, - _1: [ - 1, - 3, - 5 - ] - }; + () => ({ + TAG: "Eq", + _0: vv, + _1: [ + 1, + 3, + 5 + ] }) ], tl: { hd: [ "File \"ffi_arity_test.res\", line 53, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: hh, - _1: [ - 1, - 2, - 3 - ] - }; + () => ({ + TAG: "Eq", + _0: hh, + _1: [ + 1, + 2, + 3 + ] }) ], tl: /* [] */0 diff --git a/jscomp/test/ffi_array_test.js b/jscomp/test/ffi_array_test.js index 1fa6dbda0f..ea510b33cf 100644 --- a/jscomp/test/ffi_array_test.js +++ b/jscomp/test/ffi_array_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -33,9 +31,7 @@ eq("File \"ffi_array_test.res\", line 11, characters 12-19", [ 2, 3, 4 -].map(function (x) { - return x + 1 | 0; -}), [ +].map(x => x + 1 | 0), [ 2, 3, 4, diff --git a/jscomp/test/ffi_js_test.js b/jscomp/test/ffi_js_test.js index b97a7f580d..6fd4eb6399 100644 --- a/jscomp/test/ffi_js_test.js +++ b/jscomp/test/ffi_js_test.js @@ -27,12 +27,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/ffi_splice_test.js b/jscomp/test/ffi_splice_test.js index 7f52cffcc2..1885b6ec2e 100644 --- a/jscomp/test/ffi_splice_test.js +++ b/jscomp/test/ffi_splice_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/flexible_array_test.js b/jscomp/test/flexible_array_test.js index 8ce92b71c2..7e932c4ae9 100644 --- a/jscomp/test/flexible_array_test.js +++ b/jscomp/test/flexible_array_test.js @@ -269,12 +269,8 @@ function sort(s) { return s; } let head = get(s, 0); - let larger = sort(filter_from(1, (function (x) { - return Caml_obj.greaterthan(x, head); - }), s)); - let smaller = sort(filter_from(1, (function (x) { - return Caml_obj.lessequal(x, head); - }), s)); + let larger = sort(filter_from(1, x => Caml_obj.greaterthan(x, head), s)); + let smaller = sort(filter_from(1, x => Caml_obj.lessequal(x, head), s)); return append(smaller, push_front(larger, head)); } @@ -335,13 +331,9 @@ if (!$eq$tilde(sort(u), [ }); } -let v = $$Array.init(500, (function (i) { - return 500 - i | 0; -})); +let v = $$Array.init(500, i => 500 - i | 0); -$eq$tilde(sort(of_array(v)), $$Array.init(500, (function (i) { - return i + 1 | 0; -}))); +$eq$tilde(sort(of_array(v)), $$Array.init(500, i => i + 1 | 0)); exports.sub = sub; exports.update = update; diff --git a/jscomp/test/float_of_bits_test.js b/jscomp/test/float_of_bits_test.js index 7b6747eae2..d4f450973a 100644 --- a/jscomp/test/float_of_bits_test.js +++ b/jscomp/test/float_of_bits_test.js @@ -25,57 +25,49 @@ let int32_pairs = [ ]; function from_pairs(pair) { - return List.concat($$Array.to_list($$Array.mapi((function (i, param) { + return List.concat($$Array.to_list($$Array.mapi((i, param) => { let f = param[1]; let i32 = param[0]; return { hd: [ "int32_float_of_bits " + i, - (function (param) { - return { - TAG: "Eq", - _0: Caml_float.int_float_of_bits(i32), - _1: f - }; + param => ({ + TAG: "Eq", + _0: Caml_float.int_float_of_bits(i32), + _1: f }) ], tl: { hd: [ "int32_bits_of_float " + i, - (function (param) { - return { - TAG: "Eq", - _0: Caml_float.int_bits_of_float(f), - _1: i32 - }; + param => ({ + TAG: "Eq", + _0: Caml_float.int_bits_of_float(f), + _1: i32 }) ], tl: /* [] */0 } }; - }), int32_pairs))); + }, int32_pairs))); } let suites = Pervasives.$at({ hd: [ "one", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.bits_of_float(1.0), - _1: one_float - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.bits_of_float(1.0), + _1: one_float }) ], tl: { hd: [ "two", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.float_of_bits(one_float), - _1: 1.0 - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.float_of_bits(one_float), + _1: 1.0 }) ], tl: /* [] */0 diff --git a/jscomp/test/float_test.js b/jscomp/test/float_test.js index 7998fe9d09..e463d77f83 100644 --- a/jscomp/test/float_test.js +++ b/jscomp/test/float_test.js @@ -118,20 +118,18 @@ let results = $$Array.append([ ]); function from_pairs(ps) { - return $$Array.to_list($$Array.mapi((function (i, param) { + return $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "pair " + i, - (function (param) { - return { - TAG: "Approx", - _0: a, - _1: b - }; + param => ({ + TAG: "Approx", + _0: a, + _1: b }) ]; - }), ps)); + }, ps)); } let float_compare = Caml.float_compare; @@ -191,7 +189,7 @@ eq("File \"float_test.res\", line 62, characters 4-11", [ true ]); -eq("File \"float_test.res\", line 71, characters 4-11", $$Array.map((function (x) { +eq("File \"float_test.res\", line 71, characters 4-11", $$Array.map(x => { if (x > 0) { return 1; } else if (x < 0) { @@ -199,9 +197,7 @@ eq("File \"float_test.res\", line 71, characters 4-11", $$Array.map((function (x } else { return 0; } -}), $$Array.map((function (param) { - return Caml.float_compare(param[0], param[1]); -}), [ +}, $$Array.map(param => Caml.float_compare(param[0], param[1]), [ [ 1, 3 @@ -325,45 +321,37 @@ let a = match$4[0]; Mt.from_pair_suites("Float_test", Pervasives.$at({ hd: [ "mod_float", - (function () { - return { - TAG: "Approx", - _0: 3.2 % 0.5, - _1: 0.200000000000000178 - }; + () => ({ + TAG: "Approx", + _0: 3.2 % 0.5, + _1: 0.200000000000000178 }) ], tl: { hd: [ "modf_float1", - (function () { - return { - TAG: "Approx", - _0: a, - _1: 0.299999999999997158 - }; + () => ({ + TAG: "Approx", + _0: a, + _1: 0.299999999999997158 }) ], tl: { hd: [ "modf_float2", - (function () { - return { - TAG: "Approx", - _0: b, - _1: 32 - }; + () => ({ + TAG: "Approx", + _0: b, + _1: 32 }) ], tl: { hd: [ "int_of_float", - (function () { - return { - TAG: "Eq", - _0: 3, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: 3, + _1: 3 }) ], tl: /* [] */0 diff --git a/jscomp/test/for_loop_test.js b/jscomp/test/for_loop_test.js index 55b6cf0e27..11a546508a 100644 --- a/jscomp/test/for_loop_test.js +++ b/jscomp/test/for_loop_test.js @@ -9,20 +9,14 @@ function for_3(x) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let j = (i << 1); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + j | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -30,21 +24,15 @@ function for_4(x) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let j = (i << 1); let k = (j << 1); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + k | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -52,20 +40,14 @@ function for_5(x, u) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let k = Math.imul((u << 1), u); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + k | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -73,11 +55,7 @@ function for_6(x, u) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); let v4 = { contents: 0 }; @@ -95,15 +73,13 @@ function for_6(x, u) { let k = Math.imul((u << 1), u); let h = (v5.contents << 1); v2.contents = v2.contents + 1 | 0; - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = (((((v.contents + k | 0) + v2.contents | 0) + v4.contents | 0) + v5.contents | 0) + h | 0) + u | 0; - })); + }); } inspect_3 = v2.contents; } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return [ v.contents, v4.contents, @@ -116,19 +92,15 @@ function for_7() { let v = { contents: 0 }; - let arr = Caml_array.make(21, (function () { - - })); + let arr = Caml_array.make(21, () => {}); for (let i = 0; i <= 6; ++i) { for (let j = 0; j <= 2; ++j) { - Caml_array.set(arr, Math.imul(i, 3) + j | 0, (function () { + Caml_array.set(arr, Math.imul(i, 3) + j | 0, () => { v.contents = (v.contents + i | 0) + j | 0; - })); + }); } } - $$Array.iter((function (f) { - f(); - }), arr); + $$Array.iter(f => f(), arr); return v.contents; } @@ -136,21 +108,17 @@ function for_8() { let v = { contents: 0 }; - let arr = Caml_array.make(21, (function () { - - })); + let arr = Caml_array.make(21, () => {}); for (let i = 0; i <= 6; ++i) { let k = (i << 1); for (let j = 0; j <= 2; ++j) { let h = i + j | 0; - Caml_array.set(arr, Math.imul(i, 3) + j | 0, (function () { + Caml_array.set(arr, Math.imul(i, 3) + j | 0, () => { v.contents = (((v.contents + i | 0) + j | 0) + h | 0) + k | 0; - })); + }); } } - $$Array.iter((function (f) { - f(); - }), arr); + $$Array.iter(f => f(), arr); return v.contents; } @@ -158,7 +126,7 @@ function for_9() { let v = { contents: /* [] */0 }; - let collect = function (x) { + let collect = x => { v.contents = { hd: x, tl: v.contents @@ -170,12 +138,8 @@ function for_9() { let vv2 = { contents: 0 }; - let arr = Caml_array.make(4, (function () { - - })); - let arr2 = Caml_array.make(2, (function () { - - })); + let arr = Caml_array.make(4, () => {}); + let arr2 = Caml_array.make(2, () => {}); for (let i = 0; i <= 1; ++i) { let v$1 = { contents: 0 @@ -184,20 +148,16 @@ function for_9() { for (let j = 0; j <= 1; ++j) { v$1.contents = v$1.contents + 1 | 0; collect(v$1.contents); - Caml_array.set(arr, (i << 1) + j | 0, (function () { + Caml_array.set(arr, (i << 1) + j | 0, () => { vv.contents = vv.contents + v$1.contents | 0; - })); + }); } - Caml_array.set(arr2, i, (function () { + Caml_array.set(arr2, i, () => { vv2.contents = vv2.contents + v$1.contents | 0; - })); + }); } - $$Array.iter((function (f) { - f(); - }), arr); - $$Array.iter((function (f) { - f(); - }), arr2); + $$Array.iter(f => f(), arr); + $$Array.iter(f => f(), arr2); return [[ vv.contents, $$Array.of_list(List.rev(v.contents)), @@ -207,93 +167,79 @@ function for_9() { let suites_0 = [ "for_loop_test_3", - (function (param) { - return { - TAG: "Eq", - _0: 90, - _1: for_3(Caml_array.make(10, 2)) - }; + param => ({ + TAG: "Eq", + _0: 90, + _1: for_3(Caml_array.make(10, 2)) }) ]; let suites_1 = { hd: [ "for_loop_test_4", - (function (param) { - return { - TAG: "Eq", - _0: 180, - _1: for_4(Caml_array.make(10, 2)) - }; + param => ({ + TAG: "Eq", + _0: 180, + _1: for_4(Caml_array.make(10, 2)) }) ], tl: { hd: [ "for_loop_test_5", - (function (param) { - return { - TAG: "Eq", - _0: 2420, - _1: for_5(Caml_array.make(10, 2), 11) - }; + param => ({ + TAG: "Eq", + _0: 2420, + _1: for_5(Caml_array.make(10, 2), 11) }) ], tl: { hd: [ "for_loop_test_6", - (function (param) { - return { - TAG: "Eq", - _0: [ - 30, - 1, - 2, - 3 - ], - _1: for_6(Caml_array.make(3, 0), 0) - }; + param => ({ + TAG: "Eq", + _0: [ + 30, + 1, + 2, + 3 + ], + _1: for_6(Caml_array.make(3, 0), 0) }) ], tl: { hd: [ "for_loop_test_7", - (function (param) { - return { - TAG: "Eq", - _0: 84, - _1: for_7() - }; + param => ({ + TAG: "Eq", + _0: 84, + _1: for_7() }) ], tl: { hd: [ "for_loop_test_8", - (function (param) { - return { - TAG: "Eq", - _0: 294, - _1: for_8() - }; + param => ({ + TAG: "Eq", + _0: 294, + _1: for_8() }) ], tl: { hd: [ "for_loop_test_9", - (function (param) { - return { - TAG: "Eq", - _0: [[ - 10, - [ - 1, - 2, - 2, - 3 - ], - 5 - ]], - _1: for_9() - }; + param => ({ + TAG: "Eq", + _0: [[ + 10, + [ + 1, + 2, + 2, + 3 + ], + 5 + ]], + _1: for_9() }) ], tl: /* [] */0 diff --git a/jscomp/test/for_side_effect_test.js b/jscomp/test/for_side_effect_test.js index ad61a8bb8d..5ad59cf45d 100644 --- a/jscomp/test/for_side_effect_test.js +++ b/jscomp/test/for_side_effect_test.js @@ -21,12 +21,10 @@ function test2() { let suites_0 = [ "for_order", - (function (param) { - return { - TAG: "Eq", - _0: 10, - _1: test2() - }; + param => ({ + TAG: "Eq", + _0: 10, + _1: test2() }) ]; diff --git a/jscomp/test/format_test.js b/jscomp/test/format_test.js index e7dbc96ed5..126980a702 100644 --- a/jscomp/test/format_test.js +++ b/jscomp/test/format_test.js @@ -20,12 +20,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -77,9 +75,7 @@ eq("File \"format_test.res\", line 45, characters 5-12", (1 + 4095 / 4096) * 8, eq("File \"format_test.res\", line 46, characters 5-12", (1 + 65535 / 65536) * 8, 15.9998779296875); function f(loc, ls) { - List.iter((function (param) { - eq(loc, Caml_format.float_of_string(param[0]), param[1]); - }), ls); + List.iter(param => eq(loc, Caml_format.float_of_string(param[0]), param[1]), ls); } f("File \"format_test.res\", line 53, characters 11-18", { @@ -107,9 +103,7 @@ function sl(f) { } function aux_list(loc, ls) { - List.iter((function (param) { - eq(loc, Caml_format.hexstring_of_float(param[0], -1, /* '-' */45), param[1]); - }), ls); + List.iter(param => eq(loc, Caml_format.hexstring_of_float(param[0], -1, /* '-' */45), param[1]), ls); } let literals_0 = [ @@ -186,9 +180,7 @@ scan_float("File \"format_test.res\", line 80, characters 13-20", "0x3f.p1", 126 scan_float("File \"format_test.res\", line 81, characters 13-20", "0x1.3333333333333p-2", 0.3); -List.iter((function (param) { - scan_float("File \"format_test.res\", line 82, characters 35-42", param[1], param[0]); -}), literals); +List.iter(param => scan_float("File \"format_test.res\", line 82, characters 35-42", param[1], param[0]), literals); let f1 = - -9.9; diff --git a/jscomp/test/functor_app_test.js b/jscomp/test/functor_app_test.js index 53402b6e29..0bbeb2abfc 100644 --- a/jscomp/test/functor_app_test.js +++ b/jscomp/test/functor_app_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/functor_def.js b/jscomp/test/functor_def.js index 8c1046548d..756262d85a 100644 --- a/jscomp/test/functor_def.js +++ b/jscomp/test/functor_def.js @@ -16,7 +16,7 @@ function $$return() { } function Make(U) { - let h = function (x, x$1) { + let h = (x, x$1) => { console.log(f(x$1, x$1)); return U.say(x$1, x$1); }; diff --git a/jscomp/test/functor_ffi.js b/jscomp/test/functor_ffi.js index 0d7c442e2e..70f82d1356 100644 --- a/jscomp/test/functor_ffi.js +++ b/jscomp/test/functor_ffi.js @@ -4,9 +4,7 @@ let Caml_option = require("../../lib/js/caml_option.js"); function Make(S) { - let opt_get = function (f, i) { - return Caml_option.undefined_to_opt(f[i]); - }; + let opt_get = (f, i) => Caml_option.undefined_to_opt(f[i]); return { opt_get: opt_get }; diff --git a/jscomp/test/functors.js b/jscomp/test/functors.js index f56f95b996..44b8b1ef0a 100644 --- a/jscomp/test/functors.js +++ b/jscomp/test/functors.js @@ -3,12 +3,8 @@ function O(X) { - let cow = function (x) { - return X.foo(x); - }; - let sheep = function (x) { - return 1 + X.foo(x) | 0; - }; + let cow = x => X.foo(x); + let sheep = x => 1 + X.foo(x) | 0; return { cow: cow, sheep: sheep @@ -16,12 +12,8 @@ function O(X) { } function F(X, Y) { - let cow = function (x) { - return Y.foo(X.foo(x)); - }; - let sheep = function (x) { - return 1 + Y.foo(X.foo(x)) | 0; - }; + let cow = x => Y.foo(X.foo(x)); + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; return { cow: cow, sheep: sheep @@ -29,32 +21,26 @@ function F(X, Y) { } function F1(X, Y) { - let sheep = function (x) { - return 1 + Y.foo(X.foo(x)) | 0; - }; + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; return { sheep: sheep }; } function F2(X, Y) { - let sheep = function (x) { - return 1 + Y.foo(X.foo(x)) | 0; - }; + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; return { sheep: sheep }; } let M = { - F: (function (funarg, funarg$1) { - let sheep = function (x) { - return 1 + funarg$1.foo(funarg.foo(x)) | 0; - }; + F: (funarg, funarg$1) => { + let sheep = x => 1 + funarg$1.foo(funarg.foo(x)) | 0; return { sheep: sheep }; - }) + } }; exports.O = O; diff --git a/jscomp/test/genlex_test.js b/jscomp/test/genlex_test.js index 0638104f8c..7aa4e74b15 100644 --- a/jscomp/test/genlex_test.js +++ b/jscomp/test/genlex_test.js @@ -59,54 +59,52 @@ function to_list(s) { let suites_0 = [ "lexer_stream_genlex", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: { + TAG: "Int", + _0: 3 + }, + tl: { hd: { - TAG: "Int", - _0: 3 + TAG: "Kwd", + _0: "(" }, tl: { hd: { - TAG: "Kwd", - _0: "(" + TAG: "Int", + _0: 3 }, tl: { hd: { - TAG: "Int", - _0: 3 + TAG: "Kwd", + _0: "+" }, tl: { hd: { - TAG: "Kwd", - _0: "+" + TAG: "Int", + _0: 2 }, tl: { hd: { TAG: "Int", - _0: 2 + _0: -1 }, tl: { hd: { - TAG: "Int", - _0: -1 + TAG: "Kwd", + _0: ")" }, - tl: { - hd: { - TAG: "Kwd", - _0: ")" - }, - tl: /* [] */0 - } + tl: /* [] */0 } } } } } - }, - _1: to_list(lexer(Stream.of_string("3(3 + 2 -1)"))) - }; + } + }, + _1: to_list(lexer(Stream.of_string("3(3 + 2 -1)"))) }) ]; diff --git a/jscomp/test/global_exception_regression_test.js b/jscomp/test/global_exception_regression_test.js index 443bf1ee90..a659c2d3fb 100644 --- a/jscomp/test/global_exception_regression_test.js +++ b/jscomp/test/global_exception_regression_test.js @@ -17,24 +17,20 @@ let s = { let suites_0 = [ "not_found_equal", - (function (param) { - return { - TAG: "Eq", - _0: u, - _1: v - }; + param => ({ + TAG: "Eq", + _0: u, + _1: v }) ]; let suites_1 = { hd: [ "not_found_not_equal_end_of_file", - (function (param) { - return { - TAG: "Neq", - _0: u, - _1: s - }; + param => ({ + TAG: "Neq", + _0: u, + _1: s }) ], tl: /* [] */0 diff --git a/jscomp/test/global_module_alias_test.js b/jscomp/test/global_module_alias_test.js index 99890d07ea..7752010026 100644 --- a/jscomp/test/global_module_alias_test.js +++ b/jscomp/test/global_module_alias_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/google_closure_test.js b/jscomp/test/google_closure_test.js index 488df56280..2e9cbe212d 100644 --- a/jscomp/test/google_closure_test.js +++ b/jscomp/test/google_closure_test.js @@ -7,23 +7,21 @@ let Test_google_closure = require("./test_google_closure.js"); Mt.from_pair_suites("Closure", { hd: [ "partial", - (function () { - return { - TAG: "Eq", - _0: [ - Test_google_closure.a, - Test_google_closure.b, - Test_google_closure.c - ], - _1: [ - "3", - 101, - [ - 1, - 2 - ] + () => ({ + TAG: "Eq", + _0: [ + Test_google_closure.a, + Test_google_closure.b, + Test_google_closure.c + ], + _1: [ + "3", + 101, + [ + 1, + 2 ] - }; + ] }) ], tl: /* [] */0 diff --git a/jscomp/test/gpr496_test.js b/jscomp/test/gpr496_test.js index 89eb671d8d..b7c42a58bc 100644 --- a/jscomp/test/gpr496_test.js +++ b/jscomp/test/gpr496_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1154_test.js b/jscomp/test/gpr_1154_test.js index b951f6fc97..409b24e7fa 100644 --- a/jscomp/test/gpr_1154_test.js +++ b/jscomp/test/gpr_1154_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1409_test.js b/jscomp/test/gpr_1409_test.js index ec0b717f46..0fd2d32db4 100644 --- a/jscomp/test/gpr_1409_test.js +++ b/jscomp/test/gpr_1409_test.js @@ -19,12 +19,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -46,9 +44,7 @@ function map(f, x) { function make(foo, param) { let tmp = {}; - let tmp$1 = map((function (prim) { - return String(prim); - }), foo); + let tmp$1 = map(prim => String(prim), foo); if (tmp$1 !== undefined) { tmp.foo = tmp$1; } diff --git a/jscomp/test/gpr_1423_app_test.js b/jscomp/test/gpr_1423_app_test.js index da8edcbc0e..e87c3e1fc1 100644 --- a/jscomp/test/gpr_1423_app_test.js +++ b/jscomp/test/gpr_1423_app_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -32,9 +30,7 @@ function foo(f) { console.log(f("a1", undefined)); } -foo(function (none, extra) { - return none + "a2"; -}); +foo((none, extra) => none + "a2"); function foo2(f) { return f("a1", undefined); diff --git a/jscomp/test/gpr_1438.js b/jscomp/test/gpr_1438.js index 9d8750c886..8f89b09dfb 100644 --- a/jscomp/test/gpr_1438.js +++ b/jscomp/test/gpr_1438.js @@ -16,9 +16,7 @@ function actionKey(key, a, b, c, d, e) { case 118 : return a; } - return function (param) { - - }; + return param => {}; } exports.actionKey = actionKey; diff --git a/jscomp/test/gpr_1503_test.js b/jscomp/test/gpr_1503_test.js index 41af088b96..c5bd31f0c6 100644 --- a/jscomp/test/gpr_1503_test.js +++ b/jscomp/test/gpr_1503_test.js @@ -19,12 +19,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1539_test.js b/jscomp/test/gpr_1539_test.js index 3cd7784433..e8b2d507a8 100644 --- a/jscomp/test/gpr_1539_test.js +++ b/jscomp/test/gpr_1539_test.js @@ -22,9 +22,7 @@ Caml_module.update_mod({ "add" ]] }, Point, { - add: (function (prim0, prim1) { - return prim0.add(prim1); - }) + add: (prim0, prim1) => prim0.add(prim1) }); let CRS; diff --git a/jscomp/test/gpr_1658_test.js b/jscomp/test/gpr_1658_test.js index 22768108a3..f0b9e8752e 100644 --- a/jscomp/test/gpr_1658_test.js +++ b/jscomp/test/gpr_1658_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1667_test.js b/jscomp/test/gpr_1667_test.js index a1f9c44493..9da1661ecb 100644 --- a/jscomp/test/gpr_1667_test.js +++ b/jscomp/test/gpr_1667_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1692_test.js b/jscomp/test/gpr_1692_test.js index 884c49a7dc..7c0694ed44 100644 --- a/jscomp/test/gpr_1692_test.js +++ b/jscomp/test/gpr_1692_test.js @@ -2,8 +2,6 @@ 'use strict'; -((function (f) { - return 0; - })("")); +(f => 0)(""); /* Not a pure module */ diff --git a/jscomp/test/gpr_1701_test.js b/jscomp/test/gpr_1701_test.js index 81226bbfca..dbf9f7c67a 100644 --- a/jscomp/test/gpr_1701_test.js +++ b/jscomp/test/gpr_1701_test.js @@ -83,7 +83,7 @@ function read_lines2(inc) { } function read_lines3(inc) { - let loop = function (acc) { + let loop = acc => { try { let l = input_line(inc); return loop({ diff --git a/jscomp/test/gpr_1716_test.js b/jscomp/test/gpr_1716_test.js index ae4d162250..63584127f3 100644 --- a/jscomp/test/gpr_1716_test.js +++ b/jscomp/test/gpr_1716_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1728_test.js b/jscomp/test/gpr_1728_test.js index 90f5f5fa50..a593c54a84 100644 --- a/jscomp/test/gpr_1728_test.js +++ b/jscomp/test/gpr_1728_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1749_test.js b/jscomp/test/gpr_1749_test.js index c0df289865..a253398ae6 100644 --- a/jscomp/test/gpr_1749_test.js +++ b/jscomp/test/gpr_1749_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1760_test.js b/jscomp/test/gpr_1760_test.js index 070945f187..a1a7811211 100644 --- a/jscomp/test/gpr_1760_test.js +++ b/jscomp/test/gpr_1760_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1762_test.js b/jscomp/test/gpr_1762_test.js index 99d10508f4..5624f6b6c7 100644 --- a/jscomp/test/gpr_1762_test.js +++ b/jscomp/test/gpr_1762_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1817_test.js b/jscomp/test/gpr_1817_test.js index f28147a06b..a8e9c48e83 100644 --- a/jscomp/test/gpr_1817_test.js +++ b/jscomp/test/gpr_1817_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1822_test.js b/jscomp/test/gpr_1822_test.js index 73e3a281bb..bbabae4d9f 100644 --- a/jscomp/test/gpr_1822_test.js +++ b/jscomp/test/gpr_1822_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1943_test.js b/jscomp/test/gpr_1943_test.js index 49cadb62cf..0231c905ae 100644 --- a/jscomp/test/gpr_1943_test.js +++ b/jscomp/test/gpr_1943_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_2316_test.js b/jscomp/test/gpr_2316_test.js index 9740acfc1a..aa33122ecb 100644 --- a/jscomp/test/gpr_2316_test.js +++ b/jscomp/test/gpr_2316_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_2487.js b/jscomp/test/gpr_2487.js index 64a188c760..517bf784b3 100644 --- a/jscomp/test/gpr_2487.js +++ b/jscomp/test/gpr_2487.js @@ -11,9 +11,7 @@ let b = Belt_Array.eq([ 1, 2, 3 -], (function (prim0, prim1) { - return prim0 === prim1; -})); +], (prim0, prim1) => prim0 === prim1); let A; diff --git a/jscomp/test/gpr_2608_test.js b/jscomp/test/gpr_2608_test.js index 3e58451f94..f3a4853f53 100644 --- a/jscomp/test/gpr_2608_test.js +++ b/jscomp/test/gpr_2608_test.js @@ -24,18 +24,14 @@ let oppHeroes = { let huntGrootCondition = false; if (List.length(/* [] */0) > 0) { - let x = List.filter((function (h) { - return List.hd(/* [] */0) <= 1000; - }), oppHeroes); + let x = List.filter(h => List.hd(/* [] */0) <= 1000, oppHeroes); huntGrootCondition = List.length(x) === 0; } let huntGrootCondition2 = true; if (List.length(/* [] */0) < 0) { - let x$1 = List.filter((function (h) { - return List.hd(/* [] */0) <= 1000; - }), oppHeroes); + let x$1 = List.filter(h => List.hd(/* [] */0) <= 1000, oppHeroes); huntGrootCondition2 = List.length(x$1) === 0; } diff --git a/jscomp/test/gpr_2682_test.js b/jscomp/test/gpr_2682_test.js index 9cad19d945..4b85655c95 100644 --- a/jscomp/test/gpr_2682_test.js +++ b/jscomp/test/gpr_2682_test.js @@ -30,16 +30,16 @@ let N = { forIn({ x: 3 -}, (function (x) { +}, x => { console.log(x); -})); +}); forIn({ x: 3, y: 3 -}, (function (x) { +}, x => { console.log(x); -})); +}); let f3 = (()=>true); diff --git a/jscomp/test/gpr_3536_test.js b/jscomp/test/gpr_3536_test.js index e07b0156a2..4f40fea997 100644 --- a/jscomp/test/gpr_3536_test.js +++ b/jscomp/test/gpr_3536_test.js @@ -23,13 +23,7 @@ function xx(obj, a0, a1, a2, a3, a4, a5) { eq("File \"gpr_3536_test.res\", line 18, characters 12-19", 5, 5); -eq("File \"gpr_3536_test.res\", line 20, characters 12-19", xx(3, (function (prim0, prim1) { - return prim0 - prim1 | 0; -}), 2, (function (prim0, prim1) { - return prim0 + prim1 | 0; -}), 4, (function (prim0, prim1) { - return Math.imul(prim0, prim1); -}), 3), 11); +eq("File \"gpr_3536_test.res\", line 20, characters 12-19", xx(3, (prim0, prim1) => prim0 - prim1 | 0, 2, (prim0, prim1) => prim0 + prim1 | 0, 4, (prim0, prim1) => Math.imul(prim0, prim1), 3), 11); Mt.from_pair_suites("Gpr_3536_test", suites.contents); diff --git a/jscomp/test/gpr_3566_test.js b/jscomp/test/gpr_3566_test.js index 5604508e53..aab0570a8a 100644 --- a/jscomp/test/gpr_3566_test.js +++ b/jscomp/test/gpr_3566_test.js @@ -75,9 +75,7 @@ function Test4($star) { } function Test5($star) { - let f = function (x) { - return Caml_option.some(x); - }; + let f = x => Caml_option.some(x); let Caml_option$1 = {}; return { f: f, @@ -87,9 +85,7 @@ function Test5($star) { function Test6($star) { let Caml_option$1 = {}; - let f = function (x) { - return Caml_option.some(x); - }; + let f = x => Caml_option.some(x); return { Caml_option: Caml_option$1, f: f @@ -105,9 +101,7 @@ function Test7($star) { function Test8($star) { let Curry = {}; - let f = function (x) { - return x(1); - }; + let f = x => x(1); return { Curry: Curry, f: f @@ -115,9 +109,7 @@ function Test8($star) { } function Test9($star) { - let f = function (x) { - return x(1); - }; + let f = x => x(1); let Curry = {}; return { f: f, diff --git a/jscomp/test/gpr_3697_test.js b/jscomp/test/gpr_3697_test.js index 4e52d927dc..c2bae67104 100644 --- a/jscomp/test/gpr_3697_test.js +++ b/jscomp/test/gpr_3697_test.js @@ -6,9 +6,7 @@ let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); function fix() { return { TAG: "Fix", - _0: CamlinternalLazy.from_fun(function () { - return fix(); - }) + _0: CamlinternalLazy.from_fun(() => fix()) }; } diff --git a/jscomp/test/gpr_3875_test.js b/jscomp/test/gpr_3875_test.js index 51d9d0db8d..6dcd01cc61 100644 --- a/jscomp/test/gpr_3875_test.js +++ b/jscomp/test/gpr_3875_test.js @@ -58,9 +58,7 @@ function eq(loc, x, y) { Mt.eq_suites(test_id, suites, loc, x, y); } -compilerBug("x", undefined, true, (function () { - return true; -})); +compilerBug("x", undefined, true, () => true); eq("File \"gpr_3875_test.res\", line 35, characters 5-12", result.contents, "Some x, f returns true"); diff --git a/jscomp/test/gpr_405_test.js b/jscomp/test/gpr_405_test.js index fc7a5c6494..3c406084b4 100644 --- a/jscomp/test/gpr_405_test.js +++ b/jscomp/test/gpr_405_test.js @@ -11,7 +11,7 @@ function Make(funarg) { equal: $$let.equal, hash: $$let.hash }); - let find_default = function (htbl, x) { + let find_default = (htbl, x) => { try { return H.find(htbl, x); } catch (raw_exn) { @@ -24,7 +24,7 @@ function Make(funarg) { }); } }; - let min_cutset = function (gr, first_node) { + let min_cutset = (gr, first_node) => { let n_labels = H.create(97); let l_labels = H.create(97); let already_processed = H.create(97); @@ -35,7 +35,7 @@ function Make(funarg) { let counter = { contents: 1 }; - let step2 = function (top, rest_of_stack) { + let step2 = (top, rest_of_stack) => { if (find_default(already_processed, top)) { throw new Error("Assert_failure", { cause: { diff --git a/jscomp/test/gpr_4274_test.js b/jscomp/test/gpr_4274_test.js index 125e98a008..c32273387d 100644 --- a/jscomp/test/gpr_4274_test.js +++ b/jscomp/test/gpr_4274_test.js @@ -8,9 +8,9 @@ let N = {}; function f(X, xs) { X.forEach(xs, { - i: (function (x) { + i: x => { console.log(x.x); - }) + } }); } @@ -19,9 +19,9 @@ Belt_List.forEach({ x: 3 }, tl: /* [] */0 -}, (function (x) { +}, x => { console.log(x.x); -})); +}); let Foo = {}; @@ -29,9 +29,7 @@ let bar = [{ foo: "bar" }]; -Belt_Array.map(bar, (function (b) { - return b.foo; -})); +Belt_Array.map(bar, b => b.foo); exports.N = N; exports.f = f; diff --git a/jscomp/test/gpr_459_test.js b/jscomp/test/gpr_459_test.js index 3284e178ee..c43d1267f6 100644 --- a/jscomp/test/gpr_459_test.js +++ b/jscomp/test/gpr_459_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_858_unit2_test.js b/jscomp/test/gpr_858_unit2_test.js index ce8f9934ef..8485cff5a8 100644 --- a/jscomp/test/gpr_858_unit2_test.js +++ b/jscomp/test/gpr_858_unit2_test.js @@ -3,19 +3,17 @@ let delayed = { - contents: (function () { - - }) + contents: () => {} }; for (let i = 1; i <= 2; ++i) { - let f = function (n, x) { + let f = (n, x) => { if (x !== 0) { let prev = delayed.contents; - delayed.contents = (function () { + delayed.contents = () => { prev(); f(((n + 1 | 0) + i | 0) - i | 0, x - 1 | 0); - }); + }; return; } if (i === n) { diff --git a/jscomp/test/gpr_904_test.js b/jscomp/test/gpr_904_test.js index f130ac5a27..7f1380b73f 100644 --- a/jscomp/test/gpr_904_test.js +++ b/jscomp/test/gpr_904_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_977_test.js b/jscomp/test/gpr_977_test.js index 46834c894a..aa765405f2 100644 --- a/jscomp/test/gpr_977_test.js +++ b/jscomp/test/gpr_977_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/hash_test.js b/jscomp/test/hash_test.js index e16a1f3cc0..aebfabff04 100644 --- a/jscomp/test/hash_test.js +++ b/jscomp/test/hash_test.js @@ -20,9 +20,7 @@ function eq(f, x, y) { Mt_global.collect_eq(test_id, suites, f, x, y); } -let test_strings = $$Array.init(32, (function (i) { - return Caml_string.make(i, Char.chr(i)); -})); +let test_strings = $$Array.init(32, i => Caml_string.make(i, Char.chr(i))); let test_strings_hash_results = [ 0, diff --git a/jscomp/test/hashtbl_test.js b/jscomp/test/hashtbl_test.js index c772bd678d..a4b95c66f8 100644 --- a/jscomp/test/hashtbl_test.js +++ b/jscomp/test/hashtbl_test.js @@ -9,14 +9,12 @@ let Hashtbl = require("../../lib/js/hashtbl.js"); let MoreLabels = require("../../lib/js/moreLabels.js"); function to_list(tbl) { - return Hashtbl.fold((function (k, v, acc) { - return { - hd: [ - k, - v - ], - tl: acc - }; + return Hashtbl.fold((k, v, acc) => ({ + hd: [ + k, + v + ], + tl: acc }), tbl, /* [] */0); } @@ -25,9 +23,7 @@ function f() { Hashtbl.add(tbl, 1, /* '1' */49); Hashtbl.add(tbl, 2, /* '2' */50); let extra = to_list(tbl); - return List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), extra); + return List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), extra); } function g(count) { @@ -39,54 +35,46 @@ function g(count) { Hashtbl.replace(tbl, (i$1 << 1), String(i$1)); } let v = to_list(tbl); - return $$Array.of_list(List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), v)); + return $$Array.of_list(List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), v)); } let suites_0 = [ "simple", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: [ + 1, + /* '1' */49 + ], + tl: { hd: [ - 1, - /* '1' */49 + 2, + /* '2' */50 ], - tl: { - hd: [ - 2, - /* '2' */50 - ], - tl: /* [] */0 - } - }, - _1: f() - }; + tl: /* [] */0 + } + }, + _1: f() }) ]; let suites_1 = { hd: [ "more_iterations", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.init(1001, (function (i) { - return [ - (i << 1), - String(i) - ]; - })), - _1: g(1000) - }; + param => ({ + TAG: "Eq", + _0: $$Array.init(1001, i => [ + (i << 1), + String(i) + ]), + _1: g(1000) }) ], tl: { hd: [ "More_labels_regressionfix_374", - (function (param) { + param => { let tbl = MoreLabels.Hashtbl.create(undefined, 30); Hashtbl.add(tbl, 3, 3); return { @@ -94,7 +82,7 @@ let suites_1 = { _0: tbl.size, _1: 1 }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/ignore_test.js b/jscomp/test/ignore_test.js index a32d149c2b..dc2915a59f 100644 --- a/jscomp/test/ignore_test.js +++ b/jscomp/test/ignore_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/import2.js b/jscomp/test/import2.js index 54321a1a75..3f5a1f3bb1 100644 --- a/jscomp/test/import2.js +++ b/jscomp/test/import2.js @@ -3,9 +3,7 @@ let A = require("a").default; -let a = import("a").then(function (m) { - return m.default; -}); +let a = import("a").then(m => m.default); let b = A; diff --git a/jscomp/test/import_external.js b/jscomp/test/import_external.js index 324766ba4b..38dab08678 100644 --- a/jscomp/test/import_external.js +++ b/jscomp/test/import_external.js @@ -2,9 +2,7 @@ 'use strict'; -let f8 = import("a").then(function (m) { - return m.default; -}); +let f8 = import("a").then(m => m.default); exports.f8 = f8; /* f8 Not a pure module */ diff --git a/jscomp/test/import_side_effect.js b/jscomp/test/import_side_effect.js index a00f681262..afbe3337f7 100644 --- a/jscomp/test/import_side_effect.js +++ b/jscomp/test/import_side_effect.js @@ -2,9 +2,7 @@ 'use strict'; -let a = import("./side_effect2.js").then(function (m) { - return m.a; -}); +let a = import("./side_effect2.js").then(m => m.a); let M = await import("./side_effect.js"); diff --git a/jscomp/test/import_side_effect_free.js b/jscomp/test/import_side_effect_free.js index 918c70f482..4df30a1a43 100644 --- a/jscomp/test/import_side_effect_free.js +++ b/jscomp/test/import_side_effect_free.js @@ -2,9 +2,7 @@ 'use strict'; -let a = await import("./side_effect_free.js").then(function (m) { - return m.a; -}); +let a = await import("./side_effect_free.js").then(m => m.a); exports.a = a; /* a Not a pure module */ diff --git a/jscomp/test/inline_map2_test.js b/jscomp/test/inline_map2_test.js index 8acb03a28d..f9d8d4da7c 100644 --- a/jscomp/test/inline_map2_test.js +++ b/jscomp/test/inline_map2_test.js @@ -7,14 +7,14 @@ let List = require("../../lib/js/list.js"); let Caml_option = require("../../lib/js/caml_option.js"); function Make(Ord) { - let height = function (x) { + let height = x => { if (typeof x !== "object") { return 0; } else { return x._4; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -26,17 +26,15 @@ function Make(Ord) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: d, - _3: "Empty", - _4: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + _0: "Empty", + _1: x, + _2: d, + _3: "Empty", + _4: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l._4; let hr; @@ -102,14 +100,14 @@ function Make(Ord) { } }); }; - let is_empty = function (x) { + let is_empty = x => { if (typeof x !== "object") { return true; } else { return false; } }; - let add = function (x, data, x_) { + let add = (x, data, x_) => { if (typeof x_ !== "object") { return { TAG: "Node", @@ -140,7 +138,7 @@ function Make(Ord) { return bal(l, v, d, add(x, data, r)); } }; - let find = function (x, _x_) { + let find = (x, _x_) => { while (true) { let x_ = _x_; if (typeof x_ !== "object") { @@ -158,7 +156,7 @@ function Make(Ord) { continue; }; }; - let mem = function (x, _x_) { + let mem = (x, _x_) => { while (true) { let x_ = _x_; if (typeof x_ !== "object") { @@ -172,7 +170,7 @@ function Make(Ord) { continue; }; }; - let min_binding = function (_x) { + let min_binding = _x => { while (true) { let x = _x; if (typeof x !== "object") { @@ -193,7 +191,7 @@ function Make(Ord) { continue; }; }; - let max_binding = function (_x) { + let max_binding = _x => { while (true) { let x = _x; if (typeof x !== "object") { @@ -214,7 +212,7 @@ function Make(Ord) { continue; }; }; - let remove_min_binding = function (x) { + let remove_min_binding = x => { if (typeof x !== "object") { throw new Error("Invalid_argument", { cause: { @@ -230,7 +228,7 @@ function Make(Ord) { return bal(remove_min_binding(l), x._1, x._2, x._3); } }; - let remove = function (x, x_) { + let remove = (x, x_) => { if (typeof x_ !== "object") { return "Empty"; } @@ -254,7 +252,7 @@ function Make(Ord) { return bal(l, v, d, remove(x, r)); } }; - let iter = function (f, _x) { + let iter = (f, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -266,7 +264,7 @@ function Make(Ord) { continue; }; }; - let map = function (f, x) { + let map = (f, x) => { if (typeof x !== "object") { return "Empty"; } @@ -282,7 +280,7 @@ function Make(Ord) { _4: x._4 }; }; - let mapi = function (f, x) { + let mapi = (f, x) => { if (typeof x !== "object") { return "Empty"; } @@ -299,7 +297,7 @@ function Make(Ord) { _4: x._4 }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -311,7 +309,7 @@ function Make(Ord) { continue; }; }; - let for_all = function (p, _x) { + let for_all = (p, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -327,7 +325,7 @@ function Make(Ord) { continue; }; }; - let exists = function (p, _x) { + let exists = (p, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -343,21 +341,21 @@ function Make(Ord) { continue; }; }; - let add_min_binding = function (k, v, x) { + let add_min_binding = (k, v, x) => { if (typeof x !== "object") { return singleton(k, v); } else { return bal(add_min_binding(k, v, x._0), x._1, x._2, x._3); } }; - let add_max_binding = function (k, v, x) { + let add_max_binding = (k, v, x) => { if (typeof x !== "object") { return singleton(k, v); } else { return bal(x._0, x._1, x._2, add_max_binding(k, v, x._3)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -374,7 +372,7 @@ function Make(Ord) { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -384,14 +382,14 @@ function Make(Ord) { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, x_) { + let split = (x, x_) => { if (typeof x_ !== "object") { return [ "Empty", @@ -426,7 +424,7 @@ function Make(Ord) { match$1[2] ]; }; - let merge = function (f, s1, s2) { + let merge = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -456,7 +454,7 @@ function Make(Ord) { 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)); }; - let filter = function (p, x) { + let filter = (p, x) => { if (typeof x !== "object") { return "Empty"; } @@ -471,7 +469,7 @@ function Make(Ord) { return concat(l$p, r$p); } }; - let partition = function (p, x) { + let partition = (p, x) => { if (typeof x !== "object") { return [ "Empty", @@ -499,7 +497,7 @@ function Make(Ord) { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -517,7 +515,7 @@ function Make(Ord) { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -546,7 +544,7 @@ function Make(Ord) { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -573,14 +571,14 @@ function Make(Ord) { continue; }; }; - let cardinal = function (x) { + let cardinal = x => { if (typeof x !== "object") { return 0; } else { return (cardinal(x._0) + 1 | 0) + cardinal(x._3) | 0; } }; - let bindings_aux = function (_accu, _x) { + let bindings_aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -598,9 +596,7 @@ function Make(Ord) { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { height: height, create: create, @@ -1305,9 +1301,7 @@ let IntMap = { choose: min_binding }; -let m = List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +let m = List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 @@ -1998,9 +1992,7 @@ let SMap = { choose: min_binding$1 }; -let s = List.fold_left((function (acc, param) { - return add$1(param[0], param[1], acc); -}), "Empty", { +let s = List.fold_left((acc, param) => add$1(param[0], param[1], acc), "Empty", { hd: [ "10", /* 'a' */97 @@ -2029,23 +2021,19 @@ let s = List.fold_left((function (acc, param) { Mt.from_pair_suites("Inline_map2_test", { hd: [ "assertion1", - (function () { - return { - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 }) ], tl: { hd: [ "assertion2", - (function () { - return { - TAG: "Eq", - _0: find$1("10", s), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find$1("10", s), + _1: /* 'a' */97 }) ], tl: /* [] */0 diff --git a/jscomp/test/inline_map_demo.js b/jscomp/test/inline_map_demo.js index 842d8a800a..10ebfd5494 100644 --- a/jscomp/test/inline_map_demo.js +++ b/jscomp/test/inline_map_demo.js @@ -141,9 +141,7 @@ function add(x, data, tree) { } } -let m = List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +let m = List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 @@ -191,12 +189,10 @@ function find(px, _x) { Mt.from_pair_suites("Inline_map_demo", { hd: [ "find", - (function () { - return { - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 }) ], tl: /* [] */0 diff --git a/jscomp/test/inline_map_test.js b/jscomp/test/inline_map_test.js index 1a2655903f..343b9ec72f 100644 --- a/jscomp/test/inline_map_test.js +++ b/jscomp/test/inline_map_test.js @@ -144,9 +144,7 @@ function find(x, _x_) { }; } -let m = List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +let m = List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 @@ -175,12 +173,10 @@ let m = List.fold_left((function (acc, param) { Mt.from_pair_suites("Inline_map_test", { hd: [ "find", - (function () { - return { - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 }) ], tl: /* [] */0 diff --git a/jscomp/test/inline_record_test.js b/jscomp/test/inline_record_test.js index 28e795d78f..b6e71324b1 100644 --- a/jscomp/test/inline_record_test.js +++ b/jscomp/test/inline_record_test.js @@ -36,13 +36,9 @@ let v1 = { function f(x) { if (x.TAG === "A0") { - return List.fold_left((function (prim0, prim1) { - return prim0 + prim1 | 0; - }), x.lbl, x.more); + return List.fold_left((prim0, prim1) => prim0 + prim1 | 0, x.lbl, x.more); } else { - return List.fold_left((function (prim0, prim1) { - return prim0 + prim1 | 0; - }), 0, x.more); + return List.fold_left((prim0, prim1) => prim0 + prim1 | 0, 0, x.more); } } diff --git a/jscomp/test/inline_regression_test.js b/jscomp/test/inline_regression_test.js index 2eefed637f..a1ca7bdd55 100644 --- a/jscomp/test/inline_regression_test.js +++ b/jscomp/test/inline_regression_test.js @@ -38,19 +38,15 @@ function generic_basename(is_dir_sep, current_dir_name, name) { } function basename(extra) { - return generic_basename((function (s, i) { - return Caml_string.get(s, i) === /* '/' */47; - }), Filename.current_dir_name, extra); + return generic_basename((s, i) => Caml_string.get(s, i) === /* '/' */47, Filename.current_dir_name, extra); } let suites_0 = [ "basename", - (function (param) { - return { - TAG: "Eq", - _0: basename("b/c/a.b"), - _1: "a.b" - }; + param => ({ + TAG: "Eq", + _0: basename("b/c/a.b"), + _1: "a.b" }) ]; diff --git a/jscomp/test/inner_unused.js b/jscomp/test/inner_unused.js index a4d727f7ea..9f4fb403b8 100644 --- a/jscomp/test/inner_unused.js +++ b/jscomp/test/inner_unused.js @@ -7,9 +7,7 @@ function f(x) { } function M(S) { - let f = function (x) { - return x; - }; + let f = x => x; return { f: f }; diff --git a/jscomp/test/installation_test.js b/jscomp/test/installation_test.js index 3f46493c48..0c84e4c34b 100644 --- a/jscomp/test/installation_test.js +++ b/jscomp/test/installation_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/int32_test.js b/jscomp/test/int32_test.js index a2d0f1710f..de01fef604 100644 --- a/jscomp/test/int32_test.js +++ b/jscomp/test/int32_test.js @@ -16,9 +16,7 @@ function f(x) { ]; } -let shift_right_logical_tests_0 = $$Array.map((function (x) { - return (-1 >>> x) | 0; -}), Ext_array_test.range(0, 31)); +let shift_right_logical_tests_0 = $$Array.map(x => (-1 >>> x) | 0, Ext_array_test.range(0, 31)); let shift_right_logical_tests_1 = [ -1, @@ -60,9 +58,7 @@ let shift_right_logical_tests = [ shift_right_logical_tests_1 ]; -let shift_right_tests_0 = $$Array.map((function (x) { - return (Int32.min_int >> x); -}), Ext_array_test.range(0, 31)); +let shift_right_tests_0 = $$Array.map(x => (Int32.min_int >> x), Ext_array_test.range(0, 31)); let shift_right_tests_1 = [ -2147483648, @@ -104,9 +100,7 @@ let shift_right_tests = [ shift_right_tests_1 ]; -let shift_left_tests_0 = $$Array.map((function (x) { - return (1 << x); -}), Ext_array_test.range(0, 31)); +let shift_left_tests_0 = $$Array.map(x => (1 << x), Ext_array_test.range(0, 31)); let shift_left_tests_1 = [ 1, @@ -156,61 +150,45 @@ let suites = { contents: Pervasives.$at({ hd: [ "File \"int32_test.res\", line 131, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: 1, - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: 1, + _1: 1 }) ], tl: { hd: [ "File \"int32_test.res\", line 132, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: -2147483647, - _1: -2147483647 - }; + () => ({ + TAG: "Eq", + _0: -2147483647, + _1: -2147483647 }) ], tl: /* [] */0 } - }, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_logical_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; - }), shift_right_logical_tests_0, shift_right_logical_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; - }), shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_left_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; - }), shift_left_tests_0, shift_left_tests_1))))) + }, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_logical_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) + ], shift_right_logical_tests_0, shift_right_logical_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) + ], shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_left_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) + ], shift_left_tests_0, shift_left_tests_1))))) }; let test_id = { diff --git a/jscomp/test/int64_mul_div_test.js b/jscomp/test/int64_mul_div_test.js index 0b3755be19..e2c3036e63 100644 --- a/jscomp/test/int64_mul_div_test.js +++ b/jscomp/test/int64_mul_div_test.js @@ -306,17 +306,15 @@ let pairs = [ ]; function from_pairs(prefix, pairs) { - return $$Array.to_list($$Array.mapi((function (i, param) { + return $$Array.to_list($$Array.mapi((i, param) => { let b = param[2]; let a = param[1]; let result = param[0]; return [ prefix + "_" + i, - (function (param) { - return commutative_mul(result, a, b); - }) + param => commutative_mul(result, a, b) ]; - }), pairs)); + }, pairs)); } let small_pairs = [ @@ -1509,28 +1507,26 @@ let simple_divs = [ ]; function from(xs) { - return List.mapi((function (i, param) { + return List.mapi((i, param) => { let d = param[3]; let c = param[2]; let b = param[1]; let a = param[0]; return [ "small_divs " + i, - (function (param) { - return { - TAG: "Eq", - _0: [ - c, - d - ], - _1: [ - Caml_int64.div(a, b), - Caml_int64.mod_(a, b) - ] - }; + param => ({ + TAG: "Eq", + _0: [ + c, + d + ], + _1: [ + Caml_int64.div(a, b), + Caml_int64.mod_(a, b) + ] }) ]; - }), $$Array.to_list(xs)); + }, $$Array.to_list(xs)); } let to_string = [[ @@ -1566,111 +1562,93 @@ let int64_compare_tests = [ ]; function from_compare(xs) { - return List.mapi((function (i, param) { + return List.mapi((i, param) => { let c = param[2]; let b = param[1]; let a = param[0]; return [ "int64_compare " + i, - (function (param) { - return { - TAG: "Eq", - _0: c, - _1: Caml_int64.compare(a, b) - }; + param => ({ + TAG: "Eq", + _0: c, + _1: Caml_int64.compare(a, b) }) ]; - }), $$Array.to_list(xs)); + }, $$Array.to_list(xs)); } function from_to_string(xs) { - return List.mapi((function (i, param) { + return List.mapi((i, param) => { let str_a = param[1]; let a = param[0]; return [ "to_string " + i, - (function (param) { - return { - TAG: "Eq", - _0: str_a, - _1: Caml_int64.to_string(a) - }; + param => ({ + TAG: "Eq", + _0: str_a, + _1: Caml_int64.to_string(a) }) ]; - }), $$Array.to_list(xs)); + }, $$Array.to_list(xs)); } -Mt.from_pair_suites("Int64_mul_div_test", Pervasives.$at(from_pairs("random", pairs), Pervasives.$at(from_pairs("small", small_pairs), Pervasives.$at(List.mapi((function (i, param) { +Mt.from_pair_suites("Int64_mul_div_test", Pervasives.$at(from_pairs("random", pairs), Pervasives.$at(from_pairs("small", small_pairs), Pervasives.$at(List.mapi((i, param) => { let f = param[1]; let i64 = param[0]; return [ "to_float_" + i, - (function () { - return { - TAG: "Eq", - _0: Caml_int64.to_float(i64), - _1: f - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.to_float(i64), + _1: f }) ]; -}), $$Array.to_list(to_floats)), Pervasives.$at(List.mapi((function (i, param) { +}, $$Array.to_list(to_floats)), Pervasives.$at(List.mapi((i, param) => { let i64 = param[1]; let f = param[0]; return [ "of_float_" + i, - (function () { - return { - TAG: "Eq", - _0: Caml_int64.of_float(f), - _1: i64 - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.of_float(f), + _1: i64 }) ]; -}), $$Array.to_list(of_float_pairs)), Pervasives.$at({ +}, $$Array.to_list(of_float_pairs)), Pervasives.$at({ hd: [ "compare_check_complete", - (function () { - return { - TAG: "Eq", - _0: $$Array.map((function (param) { - return true; - }), check_complete_compare), - _1: check_complete_compare - }; + () => ({ + TAG: "Eq", + _0: $$Array.map(param => true, check_complete_compare), + _1: check_complete_compare }) ], tl: /* [] */0 }, Pervasives.$at(from(simple_divs), Pervasives.$at(from_compare(int64_compare_tests), { hd: [ "div_rem_0", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.zero, - _1: Caml_int64.zero - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.zero, + _1: Caml_int64.zero }) ], tl: { hd: [ "div_rem_1", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.neg_one, - _1: Caml_int64.neg_one - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.neg_one, + _1: Caml_int64.neg_one }) ], tl: { hd: [ "File \"int64_mul_div_test.res\", line 263, characters 19-26", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.to_float(Int64.max_int), - _1: 9.22337203685477581e+18 - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.to_float(Int64.max_int), + _1: 9.22337203685477581e+18 }) ], tl: /* [] */0 diff --git a/jscomp/test/int64_string_test.js b/jscomp/test/int64_string_test.js index 2d59d31d7d..c1ce0329b6 100644 --- a/jscomp/test/int64_string_test.js +++ b/jscomp/test/int64_string_test.js @@ -1304,7 +1304,7 @@ let random_data = { } }; -Belt_List.forEach(random_data, (function (u) { +Belt_List.forEach(random_data, u => { if (u) { if (u.tl) { throw new Error("Assert_failure", { @@ -1331,7 +1331,7 @@ Belt_List.forEach(random_data, (function (u) { ] } }); -})); +}); eq("File \"int64_string_test.res\", line 195, characters 3-10", Caml_int64.to_string([ -2097152, diff --git a/jscomp/test/int64_test.js b/jscomp/test/int64_test.js index 1e80a73778..fa1dbbd745 100644 --- a/jscomp/test/int64_test.js +++ b/jscomp/test/int64_test.js @@ -35,9 +35,7 @@ function commutative_add(result, a, b) { let generic_compare = Caml_obj.compare; -let shift_left_tests_0 = $$Array.map((function (i) { - return Caml_int64.lsl_(Caml_int64.one, i); -}), Ext_array_test.range(0, 63)); +let shift_left_tests_0 = $$Array.map(i => Caml_int64.lsl_(Caml_int64.one, i), Ext_array_test.range(0, 63)); let shift_left_tests_1 = [ Caml_int64.one, @@ -297,9 +295,7 @@ let shift_left_tests = [ shift_left_tests_1 ]; -let shift_right_tests_0 = $$Array.map((function (i) { - return Caml_int64.asr_(Caml_int64.min_int, i); -}), Ext_array_test.range(0, 63)); +let shift_right_tests_0 = $$Array.map(i => Caml_int64.asr_(Caml_int64.min_int, i), Ext_array_test.range(0, 63)); let shift_right_tests_1 = [ Caml_int64.min_int, @@ -559,9 +555,7 @@ let shift_right_tests = [ shift_right_tests_1 ]; -let shift_right_logical_suites_0 = $$Array.map((function (i) { - return Caml_int64.lsr_(Caml_int64.min_int, i); -}), Ext_array_test.range(0, 63)); +let shift_right_logical_suites_0 = $$Array.map(i => Caml_int64.lsr_(Caml_int64.min_int, i), Ext_array_test.range(0, 63)); let shift_right_logical_suites_1 = [ Caml_int64.min_int, @@ -852,1208 +846,1112 @@ function fac(_n, _acc) { let suites = Pervasives.$at({ hd: [ "add_one", - (function () { - return { - TAG: "Eq", - _0: v, - _1: [ - 0, - 2147483648 - ] - }; + () => ({ + TAG: "Eq", + _0: v, + _1: [ + 0, + 2147483648 + ] }) ], tl: { hd: [ "add_2", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4294967294 - ], - _1: Caml_int64.add(a, a) - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967294 + ], + _1: Caml_int64.add(a, a) }) ], tl: { hd: [ "add_3", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.zero, - _1: Caml_int64.zero - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.zero, + _1: Caml_int64.zero }) ], tl: { hd: [ "add_4", - (function () { - return commutative_add([ - -1, - 4294967294 - ], [ - -1, - 4294967293 - ], Caml_int64.one); - }) + () => commutative_add([ + -1, + 4294967294 + ], [ + -1, + 4294967293 + ], Caml_int64.one) ], tl: { hd: [ "add_5", - (function () { - return commutative_add([ - -1, - 4294967293 - ], [ - -1, - 4294967293 - ], Caml_int64.zero); - }) + () => commutative_add([ + -1, + 4294967293 + ], [ + -1, + 4294967293 + ], Caml_int64.zero) ], tl: { hd: [ "add_6", - (function () { - return commutative_add([ - 0, - 4 - ], [ - -1, - 4294967293 - ], [ - 0, - 7 - ]); - }) + () => commutative_add([ + 0, + 4 + ], [ + -1, + 4294967293 + ], [ + 0, + 7 + ]) ], tl: { hd: [ "add_7", - (function () { - return commutative_add([ - 1, - 0 - ], [ - 0, - 2147483648 - ], [ - 0, - 2147483648 - ]); - }) + () => commutative_add([ + 1, + 0 + ], [ + 0, + 2147483648 + ], [ + 0, + 2147483648 + ]) ], tl: { hd: [ "add_8", - (function () { - return commutative_add([ - 1, - 0 - ], [ - 0, - 4294967295 - ], Caml_int64.one); - }) + () => commutative_add([ + 1, + 0 + ], [ + 0, + 4294967295 + ], Caml_int64.one) ], tl: { hd: [ "add_9", - (function () { - return commutative_add([ - 0, - 4294967295 - ], [ - 0, - 2147483648 - ], [ - 0, - 2147483647 - ]); - }) + () => commutative_add([ + 0, + 4294967295 + ], [ + 0, + 2147483648 + ], [ + 0, + 2147483647 + ]) ], tl: { hd: [ "add_10", - (function () { - return commutative_add([ - 0, - 2147483648 - ], [ - 0, - 2147483648 - ], Caml_int64.zero); - }) + () => commutative_add([ + 0, + 2147483648 + ], [ + 0, + 2147483648 + ], Caml_int64.zero) ], tl: { hd: [ "add_11", - (function () { - return commutative_add([ - 0, - 4294967295 - ], [ - 0, - 4294967295 - ], Caml_int64.zero); - }) + () => commutative_add([ + 0, + 4294967295 + ], [ + 0, + 4294967295 + ], Caml_int64.zero) ], tl: { hd: [ "to_int32", - (function () { - return { + () => ({ + TAG: "Eq", + _0: 3, + _1: Caml_int64.to_int32([ + 0, + 3 + ]) + }) + ], + tl: { + hd: [ + "to_int", + () => ({ TAG: "Eq", _0: 3, _1: Caml_int64.to_int32([ 0, 3 ]) - }; - }) - ], - tl: { - hd: [ - "to_int", - (function () { - return { - TAG: "Eq", - _0: 3, - _1: Caml_int64.to_int32([ - 0, - 3 - ]) - }; }) ], tl: { hd: [ "of_int", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 3 - ], - _1: [ - 0, - 3 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 3 + ], + _1: [ + 0, + 3 + ] }) ], tl: { hd: [ "lognot", - (function () { - return { + () => ({ + TAG: "Eq", + _0: [ + -1, + 4294967293 + ], + _1: [ + -1, + 4294967293 + ] + }) + ], + tl: { + hd: [ + "neg", + () => ({ TAG: "Eq", _0: [ -1, - 4294967293 + 4294967294 ], _1: [ -1, - 4294967293 + 4294967294 ] - }; - }) - ], - tl: { - hd: [ - "neg", - (function () { - return { - TAG: "Eq", - _0: [ - -1, - 4294967294 - ], - _1: [ - -1, - 4294967294 - ] - }; }) ], tl: { hd: [ "File \"int64_test.res\", line 277, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: Int64.min_int, - _1: Caml_int64.neg(Int64.min_int) - }; + () => ({ + TAG: "Eq", + _0: Int64.min_int, + _1: Caml_int64.neg(Int64.min_int) }) ], tl: { hd: [ "File \"int64_test.res\", line 279, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Int64.max_int, - _1: Caml_int64.neg(Caml_int64.add(Int64.min_int, Caml_int64.one)) - }; + () => ({ + TAG: "Eq", + _0: Int64.max_int, + _1: Caml_int64.neg(Caml_int64.add(Int64.min_int, Caml_int64.one)) }) ], tl: { hd: [ "sub1", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 2 - ], - _1: [ - 0, - 2 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 2 + ], + _1: [ + 0, + 2 + ] }) ], tl: { hd: [ "xor1", - (function () { - return { - TAG: "Eq", - _0: [ - [ - 0, - 286331153 - ], - Caml_int64.xor(a, [ - 0, - 4009750271 - ]) + () => ({ + TAG: "Eq", + _0: [ + [ + 0, + 286331153 ], - _1: [ - [ - 0, - 286331153 - ], - [ - 0, - 2432700672 - ] + Caml_int64.xor(a, [ + 0, + 4009750271 + ]) + ], + _1: [ + [ + 0, + 286331153 + ], + [ + 0, + 2432700672 ] - }; + ] }) ], tl: { hd: [ "or", - (function () { - return { + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967295 + ], + _1: [ + 0, + 4294967295 + ] + }) + ], + tl: { + hd: [ + "and", + () => ({ TAG: "Eq", _0: [ 0, - 4294967295 + 4008636142 ], _1: [ 0, - 4294967295 + 4008636142 ] - }; - }) - ], - tl: { - hd: [ - "and", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4008636142 - ], - _1: [ - 0, - 4008636142 - ] - }; }) ], tl: { hd: [ "lsl", - (function () { - return { + () => ({ + TAG: "Eq", + _0: $$Array.map(x => Caml_int64.lsl_(Caml_int64.one, x), $$Array.init(64, i => i)), + _1: [ + Caml_int64.one, + [ + 0, + 2 + ], + [ + 0, + 4 + ], + [ + 0, + 8 + ], + [ + 0, + 16 + ], + [ + 0, + 32 + ], + [ + 0, + 64 + ], + [ + 0, + 128 + ], + [ + 0, + 256 + ], + [ + 0, + 512 + ], + [ + 0, + 1024 + ], + [ + 0, + 2048 + ], + [ + 0, + 4096 + ], + [ + 0, + 8192 + ], + [ + 0, + 16384 + ], + [ + 0, + 32768 + ], + [ + 0, + 65536 + ], + [ + 0, + 131072 + ], + [ + 0, + 262144 + ], + [ + 0, + 524288 + ], + [ + 0, + 1048576 + ], + [ + 0, + 2097152 + ], + [ + 0, + 4194304 + ], + [ + 0, + 8388608 + ], + [ + 0, + 16777216 + ], + [ + 0, + 33554432 + ], + [ + 0, + 67108864 + ], + [ + 0, + 134217728 + ], + [ + 0, + 268435456 + ], + [ + 0, + 536870912 + ], + [ + 0, + 1073741824 + ], + [ + 0, + 2147483648 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ], + [ + 4, + 0 + ], + [ + 8, + 0 + ], + [ + 16, + 0 + ], + [ + 32, + 0 + ], + [ + 64, + 0 + ], + [ + 128, + 0 + ], + [ + 256, + 0 + ], + [ + 512, + 0 + ], + [ + 1024, + 0 + ], + [ + 2048, + 0 + ], + [ + 4096, + 0 + ], + [ + 8192, + 0 + ], + [ + 16384, + 0 + ], + [ + 32768, + 0 + ], + [ + 65536, + 0 + ], + [ + 131072, + 0 + ], + [ + 262144, + 0 + ], + [ + 524288, + 0 + ], + [ + 1048576, + 0 + ], + [ + 2097152, + 0 + ], + [ + 4194304, + 0 + ], + [ + 8388608, + 0 + ], + [ + 16777216, + 0 + ], + [ + 33554432, + 0 + ], + [ + 67108864, + 0 + ], + [ + 134217728, + 0 + ], + [ + 268435456, + 0 + ], + [ + 536870912, + 0 + ], + [ + 1073741824, + 0 + ], + Caml_int64.min_int + ] + }) + ], + tl: { + hd: [ + "lsr", + () => ({ TAG: "Eq", - _0: $$Array.map((function (x) { - return Caml_int64.lsl_(Caml_int64.one, x); - }), $$Array.init(64, (function (i) { - return i; - }))), + _0: $$Array.map(x => Caml_int64.lsr_(Caml_int64.neg_one, x), $$Array.init(64, i => i)), _1: [ - Caml_int64.one, + Caml_int64.neg_one, + Caml_int64.max_int, [ - 0, - 2 + 1073741823, + 4294967295 ], [ - 0, - 4 + 536870911, + 4294967295 ], [ - 0, - 8 + 268435455, + 4294967295 ], [ - 0, - 16 + 134217727, + 4294967295 ], [ - 0, - 32 + 67108863, + 4294967295 ], [ - 0, - 64 + 33554431, + 4294967295 ], [ - 0, - 128 + 16777215, + 4294967295 ], [ - 0, - 256 + 8388607, + 4294967295 ], [ - 0, - 512 + 4194303, + 4294967295 ], [ - 0, - 1024 + 2097151, + 4294967295 ], [ - 0, - 2048 + 1048575, + 4294967295 ], [ - 0, - 4096 + 524287, + 4294967295 ], [ - 0, - 8192 + 262143, + 4294967295 ], [ - 0, - 16384 + 131071, + 4294967295 ], [ - 0, - 32768 + 65535, + 4294967295 ], [ - 0, - 65536 + 32767, + 4294967295 ], [ - 0, - 131072 + 16383, + 4294967295 ], [ - 0, - 262144 + 8191, + 4294967295 ], [ - 0, - 524288 + 4095, + 4294967295 ], [ - 0, - 1048576 + 2047, + 4294967295 ], [ - 0, - 2097152 + 1023, + 4294967295 ], [ - 0, - 4194304 + 511, + 4294967295 ], [ - 0, - 8388608 + 255, + 4294967295 ], [ - 0, - 16777216 + 127, + 4294967295 ], [ - 0, - 33554432 + 63, + 4294967295 ], [ - 0, - 67108864 + 31, + 4294967295 ], [ - 0, - 134217728 + 15, + 4294967295 ], [ - 0, - 268435456 + 7, + 4294967295 ], [ - 0, - 536870912 + 3, + 4294967295 ], [ - 0, - 1073741824 + 1, + 4294967295 ], [ 0, - 2147483648 - ], - [ - 1, - 0 + 4294967295 ], [ - 2, - 0 + 0, + 2147483647 ], [ - 4, - 0 + 0, + 1073741823 ], [ - 8, - 0 + 0, + 536870911 ], [ - 16, - 0 + 0, + 268435455 ], [ - 32, - 0 + 0, + 134217727 ], [ - 64, - 0 + 0, + 67108863 ], [ - 128, - 0 + 0, + 33554431 ], [ - 256, - 0 + 0, + 16777215 ], [ - 512, - 0 + 0, + 8388607 ], [ - 1024, - 0 + 0, + 4194303 ], [ - 2048, - 0 + 0, + 2097151 ], [ - 4096, - 0 + 0, + 1048575 ], [ - 8192, - 0 + 0, + 524287 ], [ - 16384, - 0 + 0, + 262143 ], [ - 32768, - 0 + 0, + 131071 ], [ - 65536, - 0 + 0, + 65535 ], [ - 131072, - 0 + 0, + 32767 ], [ - 262144, - 0 + 0, + 16383 ], [ - 524288, - 0 + 0, + 8191 ], [ - 1048576, - 0 + 0, + 4095 ], [ - 2097152, - 0 + 0, + 2047 ], [ - 4194304, - 0 + 0, + 1023 ], [ - 8388608, - 0 + 0, + 511 ], [ - 16777216, - 0 + 0, + 255 ], [ - 33554432, - 0 + 0, + 127 ], [ - 67108864, - 0 + 0, + 63 ], [ - 134217728, - 0 + 0, + 31 ], [ - 268435456, - 0 + 0, + 15 ], [ - 536870912, - 0 + 0, + 7 ], [ - 1073741824, - 0 + 0, + 3 ], - Caml_int64.min_int + Caml_int64.one ] - }; - }) - ], - tl: { - hd: [ - "lsr", - (function () { - return { - TAG: "Eq", - _0: $$Array.map((function (x) { - return Caml_int64.lsr_(Caml_int64.neg_one, x); - }), $$Array.init(64, (function (i) { - return i; - }))), - _1: [ - Caml_int64.neg_one, - Caml_int64.max_int, - [ - 1073741823, - 4294967295 - ], - [ - 536870911, - 4294967295 - ], - [ - 268435455, - 4294967295 - ], - [ - 134217727, - 4294967295 - ], - [ - 67108863, - 4294967295 - ], - [ - 33554431, - 4294967295 - ], - [ - 16777215, - 4294967295 - ], - [ - 8388607, - 4294967295 - ], - [ - 4194303, - 4294967295 - ], - [ - 2097151, - 4294967295 - ], - [ - 1048575, - 4294967295 - ], - [ - 524287, - 4294967295 - ], - [ - 262143, - 4294967295 - ], - [ - 131071, - 4294967295 - ], - [ - 65535, - 4294967295 - ], - [ - 32767, - 4294967295 - ], - [ - 16383, - 4294967295 - ], - [ - 8191, - 4294967295 - ], - [ - 4095, - 4294967295 - ], - [ - 2047, - 4294967295 - ], - [ - 1023, - 4294967295 - ], - [ - 511, - 4294967295 - ], - [ - 255, - 4294967295 - ], - [ - 127, - 4294967295 - ], - [ - 63, - 4294967295 - ], - [ - 31, - 4294967295 - ], - [ - 15, - 4294967295 - ], - [ - 7, - 4294967295 - ], - [ - 3, - 4294967295 - ], - [ - 1, - 4294967295 - ], - [ - 0, - 4294967295 - ], - [ - 0, - 2147483647 - ], - [ - 0, - 1073741823 - ], - [ - 0, - 536870911 - ], - [ - 0, - 268435455 - ], - [ - 0, - 134217727 - ], - [ - 0, - 67108863 - ], - [ - 0, - 33554431 - ], - [ - 0, - 16777215 - ], - [ - 0, - 8388607 - ], - [ - 0, - 4194303 - ], - [ - 0, - 2097151 - ], - [ - 0, - 1048575 - ], - [ - 0, - 524287 - ], - [ - 0, - 262143 - ], - [ - 0, - 131071 - ], - [ - 0, - 65535 - ], - [ - 0, - 32767 - ], - [ - 0, - 16383 - ], - [ - 0, - 8191 - ], - [ - 0, - 4095 - ], - [ - 0, - 2047 - ], - [ - 0, - 1023 - ], - [ - 0, - 511 - ], - [ - 0, - 255 - ], - [ - 0, - 127 - ], - [ - 0, - 63 - ], - [ - 0, - 31 - ], - [ - 0, - 15 - ], - [ - 0, - 7 - ], - [ - 0, - 3 - ], - Caml_int64.one - ] - }; }) ], tl: { hd: [ "asr", - (function () { - return { - TAG: "Eq", - _0: $$Array.map((function (x) { - return Caml_int64.asr_(Caml_int64.neg_one, x); - }), $$Array.init(64, (function (i) { - return i; - }))), - _1: [ - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one - ] - }; + () => ({ + TAG: "Eq", + _0: $$Array.map(x => Caml_int64.asr_(Caml_int64.neg_one, x), $$Array.init(64, i => i)), + _1: [ + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one + ] }) ], tl: { hd: [ "mul simple", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 6 - ], - _1: [ - 0, - 6 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 6 + ], + _1: [ + 0, + 6 + ] }) ], tl: { hd: [ "of_int32", - (function () { - return { - TAG: "Eq", - _0: $$Array.map(Caml_int64.of_int32, [ - 0, - -2147483648 - ]), - _1: [ - Caml_int64.zero, - [ - -1, - 2147483648 - ] + () => ({ + TAG: "Eq", + _0: $$Array.map(Caml_int64.of_int32, [ + 0, + -2147483648 + ]), + _1: [ + Caml_int64.zero, + [ + -1, + 2147483648 ] - }; + ] }) ], tl: { hd: [ "of_int32_singleton", - (function () { - return { - TAG: "Eq", - _0: [ - -1, - 4294967293 - ], - _1: [ - -1, - 4294967293 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + -1, + 4294967293 + ], + _1: [ + -1, + 4294967293 + ] }) ], tl: { hd: [ "File \"int64_test.res\", line 526, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 3 - ], - _1: [ - 0, - 3 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 3 + ], + _1: [ + 0, + 3 + ] }) ], tl: { hd: [ "to_int32", - (function () { - return { - TAG: "Eq", - _0: $$Array.map(Caml_int64.to_int32, [ - Caml_int64.zero, - [ - 0, - 2147483648 - ] - ]), - _1: [ + () => ({ + TAG: "Eq", + _0: $$Array.map(Caml_int64.to_int32, [ + Caml_int64.zero, + [ 0, - -2147483648 + 2147483648 ] - }; + ]), + _1: [ + 0, + -2147483648 + ] }) ], tl: { hd: [ "discard_sign", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.discard_sign(Caml_int64.neg_one), - _1: Caml_int64.max_int - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.discard_sign(Caml_int64.neg_one), + _1: Caml_int64.max_int }) ], tl: { hd: [ "div_mod", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.div_mod([ - 0, - 7 - ], [ + () => ({ + TAG: "Eq", + _0: Caml_int64.div_mod([ + 0, + 7 + ], [ + 0, + 3 + ]), + _1: [ + [ 0, - 3 - ]), - _1: [ - [ - 0, - 2 - ], - Caml_int64.one - ] - }; + 2 + ], + Caml_int64.one + ] }) ], tl: { hd: [ "to_hex", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.to_hex(Caml_int64.neg_one), - _1: "ffffffffffffffff" - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.to_hex(Caml_int64.neg_one), + _1: "ffffffffffffffff" }) ], tl: { hd: [ "generic_compare", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare([ - 1, - 0 - ], Caml_int64.one) > 0, - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare([ + 1, + 0 + ], Caml_int64.one) > 0, + _1: true }) ], tl: { hd: [ "test_compier_literal", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4294967295 - ], - _1: [ - 0, - 4294967295 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967295 + ], + _1: [ + 0, + 4294967295 + ] }) ], tl: { hd: [ "generic_compare2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare([ - 0, - 2147483648 - ], Caml_int64.one) > 0, - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare([ + 0, + 2147483648 + ], Caml_int64.one) > 0, + _1: true }) ], tl: { hd: [ "shift_left", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4294967040 - ], - _1: [ - 0, - 4294967040 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967040 + ], + _1: [ + 0, + 4294967040 + ] }) ], tl: { hd: [ "fib_int64", - (function () { - return { - TAG: "Eq", - _0: fib(1000, Caml_int64.one, [ - 0, - 2 - ]), - _1: [ - -1990564327, - 2874523960 - ] - }; + () => ({ + TAG: "Eq", + _0: fib(1000, Caml_int64.one, [ + 0, + 2 + ]), + _1: [ + -1990564327, + 2874523960 + ] }) ], tl: { hd: [ "fac_int64", - (function () { - return { - TAG: "Eq", - _0: fac(30, Caml_int64.one), - _1: [ - -2040662563, - 1409286144 - ] - }; + () => ({ + TAG: "Eq", + _0: fac(30, Caml_int64.one), + _1: [ + -2040662563, + 1409286144 + ] }) ], tl: { hd: [ "File \"int64_test.res\", line 553, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.add(Int64.max_int, Int64.max_int), - _1: [ - -1, - 4294967294 - ] - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.add(Int64.max_int, Int64.max_int), + _1: [ + -1, + 4294967294 + ] }) ], tl: { hd: [ "File \"int64_test.res\", line 563, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.add(Int64.min_int, Int64.min_int), - _1: Caml_int64.zero - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.add(Int64.min_int, Int64.min_int), + _1: Caml_int64.zero }) ], tl: { hd: [ "File \"int64_test.res\", line 573, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.neg_one, - _1: Caml_int64.neg_one - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.neg_one, + _1: Caml_int64.neg_one }) ], tl: /* [] */0 @@ -2098,40 +1996,28 @@ let suites = Pervasives.$at({ } } } -}, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_left_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; -}), shift_left_tests_0, shift_left_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; -}), shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_logical_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; -}), shift_right_logical_suites_0, shift_right_logical_suites_1))))); +}, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_left_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) +], shift_left_tests_0, shift_left_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) +], shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_logical_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) +], shift_right_logical_suites_0, shift_right_logical_suites_1))))); let suites$1 = { contents: suites diff --git a/jscomp/test/int_hashtbl_test.js b/jscomp/test/int_hashtbl_test.js index 837abb1369..27976bf186 100644 --- a/jscomp/test/int_hashtbl_test.js +++ b/jscomp/test/int_hashtbl_test.js @@ -11,18 +11,14 @@ 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) { - return { - hd: [ - k, - v - ], - tl: acc - }; + let extra = H.fold((k, v, acc) => ({ + hd: [ + k, + v + ], + tl: acc }), tbl, /* [] */0); - return List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), extra); + return List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), extra); } function g(H, count) { @@ -33,18 +29,14 @@ function g(H, count) { for (let i$1 = 0; i$1 <= count; ++i$1) { H.replace(tbl, (i$1 << 1), String(i$1)); } - let v = H.fold((function (k, v, acc) { - return { - hd: [ - k, - v - ], - tl: acc - }; + let v = H.fold((k, v, acc) => ({ + hd: [ + k, + v + ], + tl: acc }), tbl, /* [] */0); - return $$Array.of_list(List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), v)); + return $$Array.of_list(List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), v)); } let hash = Hashtbl.hash; @@ -60,41 +52,35 @@ let Int_hash = Hashtbl.Make({ let suites_0 = [ "simple", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: [ + 1, + /* '1' */49 + ], + tl: { hd: [ - 1, - /* '1' */49 + 2, + /* '2' */50 ], - tl: { - hd: [ - 2, - /* '2' */50 - ], - tl: /* [] */0 - } - }, - _1: f(Int_hash) - }; + tl: /* [] */0 + } + }, + _1: f(Int_hash) }) ]; let suites_1 = { hd: [ "more_iterations", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.init(1001, (function (i) { - return [ - (i << 1), - String(i) - ]; - })), - _1: g(Int_hash, 1000) - }; + param => ({ + TAG: "Eq", + _0: $$Array.init(1001, i => [ + (i << 1), + String(i) + ]), + _1: g(Int_hash, 1000) }) ], tl: /* [] */0 diff --git a/jscomp/test/int_overflow_test.js b/jscomp/test/int_overflow_test.js index e8c7c42cee..5b5bd932d0 100644 --- a/jscomp/test/int_overflow_test.js +++ b/jscomp/test/int_overflow_test.js @@ -41,155 +41,127 @@ function fib(x) { Mt.from_pair_suites("Int_overflow_test", { hd: [ "plus_overflow", - (function () { - return { - TAG: "Eq", - _0: true, - _1: (Int32.max_int + 1 | 0) === Int32.min_int - }; + () => ({ + TAG: "Eq", + _0: true, + _1: (Int32.max_int + 1 | 0) === Int32.min_int }) ], tl: { hd: [ "minus_overflow", - (function () { - return { - TAG: "Eq", - _0: true, - _1: (Int32.min_int - Int32.one | 0) === Int32.max_int - }; + () => ({ + TAG: "Eq", + _0: true, + _1: (Int32.min_int - Int32.one | 0) === Int32.max_int }) ], tl: { hd: [ "flow_again", - (function () { - return { - TAG: "Eq", - _0: 2147483646, - _1: (Int32.max_int + Int32.max_int | 0) + Int32.min_int | 0 - }; + () => ({ + TAG: "Eq", + _0: 2147483646, + _1: (Int32.max_int + Int32.max_int | 0) + Int32.min_int | 0 }) ], tl: { hd: [ "flow_again", - (function () { - return { - TAG: "Eq", - _0: -2, - _1: Int32.max_int + Int32.max_int | 0 - }; + () => ({ + TAG: "Eq", + _0: -2, + _1: Int32.max_int + Int32.max_int | 0 }) ], tl: { hd: [ "hash_test", - (function () { - return { - TAG: "Eq", - _0: hash_variant("xxyyzzuuxxzzyy00112233"), - _1: 544087776 - }; + () => ({ + TAG: "Eq", + _0: hash_variant("xxyyzzuuxxzzyy00112233"), + _1: 544087776 }) ], tl: { hd: [ "hash_test2", - (function () { - return { - TAG: "Eq", - _0: hash_variant("xxyyzxzzyy"), - _1: -449896130 - }; + () => ({ + TAG: "Eq", + _0: hash_variant("xxyyzxzzyy"), + _1: -449896130 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 88, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: hash_variant2("xxyyzzuuxxzzyy00112233"), - _1: 544087776 - }; + () => ({ + TAG: "Eq", + _0: hash_variant2("xxyyzzuuxxzzyy00112233"), + _1: 544087776 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 89, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: hash_variant2("xxyyzxzzyy"), - _1: -449896130 - }; + () => ({ + TAG: "Eq", + _0: hash_variant2("xxyyzxzzyy"), + _1: -449896130 }) ], tl: { hd: [ "int_literal_flow", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 }) ], tl: { hd: [ "int_literal_flow2", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 }) ], tl: { hd: [ "int_literal_flow3", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 }) ], tl: { hd: [ "int32_mul", - (function () { - return { - TAG: "Eq", - _0: -33554431, - _1: -33554431 - }; + () => ({ + TAG: "Eq", + _0: -33554431, + _1: -33554431 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 94, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Number("3") | 0, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: Number("3") | 0, + _1: 3 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 96, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Number("3.2") | 0, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: Number("3.2") | 0, + _1: 3 }) ], tl: /* [] */0 diff --git a/jscomp/test/int_switch_test.js b/jscomp/test/int_switch_test.js index 2a0e0e9b34..54e513b7bf 100644 --- a/jscomp/test/int_switch_test.js +++ b/jscomp/test/int_switch_test.js @@ -61,25 +61,15 @@ function f33(x) { } } -eq("File \"int_switch_test.res\", line 32, characters 3-10", f(function () { - return 1; -}), /* 'a' */97); +eq("File \"int_switch_test.res\", line 32, characters 3-10", f(() => 1), /* 'a' */97); -eq("File \"int_switch_test.res\", line 33, characters 3-10", f(function () { - return 2; -}), /* 'b' */98); +eq("File \"int_switch_test.res\", line 33, characters 3-10", f(() => 2), /* 'b' */98); -eq("File \"int_switch_test.res\", line 34, characters 3-10", f(function () { - return 3; -}), /* 'c' */99); +eq("File \"int_switch_test.res\", line 34, characters 3-10", f(() => 3), /* 'c' */99); -eq("File \"int_switch_test.res\", line 35, characters 3-10", f(function () { - return 0; -}), /* 'x' */120); +eq("File \"int_switch_test.res\", line 35, characters 3-10", f(() => 0), /* 'x' */120); -eq("File \"int_switch_test.res\", line 36, characters 3-10", f(function () { - return -1; -}), /* 'x' */120); +eq("File \"int_switch_test.res\", line 36, characters 3-10", f(() => -1), /* 'x' */120); Mt.from_pair_suites("Int_switch_test", suites.contents); diff --git a/jscomp/test/js_array_test.js b/jscomp/test/js_array_test.js index 926b544782..fa7a168a30 100644 --- a/jscomp/test/js_array_test.js +++ b/jscomp/test/js_array_test.js @@ -6,53 +6,67 @@ let Caml_option = require("../../lib/js/caml_option.js"); let suites_0 = [ "isArray_array", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Array.isArray([]) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Array.isArray([]) }) ]; let suites_1 = { hd: [ "isArray_int", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Array.isArray(34) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Array.isArray(34) }) ], tl: { hd: [ "length", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: [ - 1, - 2, - 3 - ].length - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: [ + 1, + 2, + 3 + ].length }) ], tl: { hd: [ "copyWithin", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 1, + 2 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].copyWithin(-2) + }) + ], + tl: { + hd: [ + "copyWithinFrom", + param => ({ TAG: "Eq", _0: [ - 1, - 2, + 4, + 5, 3, - 1, - 2 + 4, + 5 ], _1: [ 1, @@ -60,19 +74,17 @@ let suites_1 = { 3, 4, 5 - ].copyWithin(-2) - }; - }) - ], - tl: { - hd: [ - "copyWithinFrom", - (function (param) { - return { + ].copyWithin(0, 3) + }) + ], + tl: { + hd: [ + "copyWithinFromRange", + param => ({ TAG: "Eq", _0: [ 4, - 5, + 2, 3, 4, 5 @@ -83,41 +95,33 @@ let suites_1 = { 3, 4, 5 - ].copyWithin(0, 3) - }; - }) - ], - tl: { - hd: [ - "copyWithinFromRange", - (function (param) { - return { + ].copyWithin(0, 3, 4) + }) + ], + tl: { + hd: [ + "fillInPlace", + param => ({ TAG: "Eq", _0: [ 4, - 2, - 3, 4, - 5 + 4 ], _1: [ 1, 2, - 3, - 4, - 5 - ].copyWithin(0, 3, 4) - }; - }) - ], - tl: { - hd: [ - "fillInPlace", - (function (param) { - return { + 3 + ].fill(4) + }) + ], + tl: { + hd: [ + "fillFromInPlace", + param => ({ TAG: "Eq", _0: [ - 4, + 1, 4, 4 ], @@ -125,193 +129,151 @@ let suites_1 = { 1, 2, 3 - ].fill(4) - }; - }) - ], - tl: { - hd: [ - "fillFromInPlace", - (function (param) { - return { + ].fill(4, 1) + }) + ], + tl: { + hd: [ + "fillRangeInPlace", + param => ({ TAG: "Eq", _0: [ 1, 4, - 4 + 3 ], _1: [ 1, 2, 3 - ].fill(4, 1) - }; - }) - ], - tl: { - hd: [ - "fillRangeInPlace", - (function (param) { - return { - TAG: "Eq", - _0: [ - 1, - 4, - 3 - ], - _1: [ - 1, - 2, - 3 - ].fill(4, 1, 2) - }; + ].fill(4, 1, 2) }) ], tl: { hd: [ "pop", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Caml_option.undefined_to_opt([ - 1, - 2, - 3 - ].pop()) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Caml_option.undefined_to_opt([ + 1, + 2, + 3 + ].pop()) }) ], tl: { hd: [ "pop - empty array", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Caml_option.undefined_to_opt([].pop()) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Caml_option.undefined_to_opt([].pop()) }) ], tl: { hd: [ "push", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: [ - 1, - 2, - 3 - ].push(4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: [ + 1, + 2, + 3 + ].push(4) }) ], tl: { hd: [ "pushMany", - (function (param) { - return { - TAG: "Eq", - _0: 5, - _1: [ - 1, - 2, - 3 - ].push(4, 5) - }; + param => ({ + TAG: "Eq", + _0: 5, + _1: [ + 1, + 2, + 3 + ].push(4, 5) }) ], tl: { hd: [ "reverseInPlace", - (function (param) { - return { - TAG: "Eq", - _0: [ - 3, - 2, - 1 - ], - _1: [ - 1, - 2, - 3 - ].reverse() - }; + param => ({ + TAG: "Eq", + _0: [ + 3, + 2, + 1 + ], + _1: [ + 1, + 2, + 3 + ].reverse() }) ], tl: { hd: [ "shift", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: Caml_option.undefined_to_opt([ - 1, - 2, - 3 - ].shift()) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: Caml_option.undefined_to_opt([ + 1, + 2, + 3 + ].shift()) }) ], tl: { hd: [ "shift - empty array", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Caml_option.undefined_to_opt([].shift()) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Caml_option.undefined_to_opt([].shift()) }) ], tl: { hd: [ "sortInPlace", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3 + ], + _1: [ + 3, + 1, + 2 + ].sort() + }) + ], + tl: { + hd: [ + "sortInPlaceWith", + param => ({ TAG: "Eq", _0: [ - 1, + 3, 2, - 3 + 1 ], _1: [ 3, 1, 2 - ].sort() - }; - }) - ], - tl: { - hd: [ - "sortInPlaceWith", - (function (param) { - return { - TAG: "Eq", - _0: [ - 3, - 2, - 1 - ], - _1: [ - 3, - 1, - 2 - ].sort(function (a, b) { - return b - a | 0; - }) - }; + ].sort((a, b) => b - a | 0) }) ], tl: { hd: [ "spliceInPlace", - (function (param) { + param => { let arr = [ 1, 2, @@ -336,12 +298,12 @@ let suites_1 = { removed ] }; - }) + } ], tl: { hd: [ "removeFromInPlace", - (function (param) { + param => { let arr = [ 1, 2, @@ -366,12 +328,12 @@ let suites_1 = { removed ] }; - }) + } ], tl: { hd: [ "removeCountInPlace", - (function (param) { + param => { let arr = [ 1, 2, @@ -394,70 +356,87 @@ let suites_1 = { removed ] }; - }) + } ], tl: { hd: [ "unshift", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: [ - 1, - 2, - 3 - ].unshift(4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: [ + 1, + 2, + 3 + ].unshift(4) }) ], tl: { hd: [ "unshiftMany", - (function (param) { - return { - TAG: "Eq", - _0: 5, - _1: [ - 1, - 2, - 3 - ].unshift(4, 5) - }; + param => ({ + TAG: "Eq", + _0: 5, + _1: [ + 1, + 2, + 3 + ].unshift(4, 5) }) ], tl: { hd: [ "append", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 4 + ], + _1: [ + 1, + 2, + 3 + ].concat([4]) + }) + ], + tl: { + hd: [ + "concat", + param => ({ TAG: "Eq", _0: [ 1, 2, 3, - 4 + 4, + 5 ], _1: [ 1, 2, 3 - ].concat([4]) - }; - }) - ], - tl: { - hd: [ - "concat", - (function (param) { - return { + ].concat([ + 4, + 5 + ]) + }) + ], + tl: { + hd: [ + "concatMany", + param => ({ TAG: "Eq", _0: [ 1, 2, 3, 4, - 5 + 5, + 6, + 7 ], _1: [ 1, @@ -466,155 +445,134 @@ let suites_1 = { ].concat([ 4, 5 + ], [ + 6, + 7 ]) - }; - }) - ], - tl: { - hd: [ - "concatMany", - (function (param) { - return { - TAG: "Eq", - _0: [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - _1: [ - 1, - 2, - 3 - ].concat([ - 4, - 5 - ], [ - 6, - 7 - ]) - }; }) ], tl: { hd: [ "includes", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3 - ].includes(3) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: [ + 1, + 2, + 3 + ].includes(3) }) ], tl: { hd: [ "indexOf", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3 - ].indexOf(2) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3 + ].indexOf(2) }) ], tl: { hd: [ "indexOfFrom", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: [ - 1, - 2, - 3, - 2 - ].indexOf(2, 2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: [ + 1, + 2, + 3, + 2 + ].indexOf(2, 2) }) ], tl: { hd: [ "join", - (function (param) { - return { - TAG: "Eq", - _0: "1,2,3", - _1: [ - 1, - 2, - 3 - ].join() - }; + param => ({ + TAG: "Eq", + _0: "1,2,3", + _1: [ + 1, + 2, + 3 + ].join() }) ], tl: { hd: [ "joinWith", - (function (param) { - return { - TAG: "Eq", - _0: "1;2;3", - _1: [ - 1, - 2, - 3 - ].join(";") - }; + param => ({ + TAG: "Eq", + _0: "1;2;3", + _1: [ + 1, + 2, + 3 + ].join(";") }) ], tl: { hd: [ "lastIndexOf", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3 - ].lastIndexOf(2) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3 + ].lastIndexOf(2) }) ], tl: { hd: [ "lastIndexOfFrom", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3, - 2 - ].lastIndexOf(2, 2) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3, + 2 + ].lastIndexOf(2, 2) }) ], tl: { hd: [ "slice", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 2, + 3 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].slice(1, 3) + }) + ], + tl: { + hd: [ + "copy", + param => ({ TAG: "Eq", _0: [ + 1, 2, - 3 + 3, + 4, + 5 ], _1: [ 1, @@ -622,19 +580,15 @@ let suites_1 = { 3, 4, 5 - ].slice(1, 3) - }; - }) - ], - tl: { - hd: [ - "copy", - (function (param) { - return { + ].slice() + }) + ], + tl: { + hd: [ + "sliceFrom", + param => ({ TAG: "Eq", _0: [ - 1, - 2, 3, 4, 5 @@ -645,249 +599,183 @@ let suites_1 = { 3, 4, 5 - ].slice() - }; - }) - ], - tl: { - hd: [ - "sliceFrom", - (function (param) { - return { - TAG: "Eq", - _0: [ - 3, - 4, - 5 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].slice(2) - }; + ].slice(2) }) ], tl: { hd: [ "toString", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: "1,2,3", + _1: [ + 1, + 2, + 3 + ].toString() + }) + ], + tl: { + hd: [ + "toLocaleString", + param => ({ TAG: "Eq", _0: "1,2,3", _1: [ 1, 2, 3 - ].toString() - }; - }) - ], - tl: { - hd: [ - "toLocaleString", - (function (param) { - return { - TAG: "Eq", - _0: "1,2,3", - _1: [ - 1, - 2, - 3 - ].toLocaleString() - }; + ].toLocaleString() }) ], tl: { hd: [ "every", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3 - ].every(function (n) { - return n > 0; - }) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: [ + 1, + 2, + 3 + ].every(n => n > 0) }) ], tl: { hd: [ "everyi", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: [ - 1, - 2, - 3 - ].every(function (param, i) { - return i > 0; - }) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: [ + 1, + 2, + 3 + ].every((param, i) => i > 0) }) ], tl: { hd: [ "filter", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 2, + 4 + ], + _1: [ + 1, + 2, + 3, + 4 + ].filter(n => n % 2 === 0) + }) + ], + tl: { + hd: [ + "filteri", + param => ({ TAG: "Eq", _0: [ - 2, - 4 + 1, + 3 ], _1: [ 1, 2, 3, 4 - ].filter(function (n) { - return n % 2 === 0; - }) - }; - }) - ], - tl: { - hd: [ - "filteri", - (function (param) { - return { - TAG: "Eq", - _0: [ - 1, - 3 - ], - _1: [ - 1, - 2, - 3, - 4 - ].filter(function (param, i) { - return i % 2 === 0; - }) - }; + ].filter((param, i) => i % 2 === 0) }) ], tl: { hd: [ "find", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: 2, + _1: Caml_option.undefined_to_opt([ + 1, + 2, + 3, + 4 + ].find(n => n % 2 === 0)) + }) + ], + tl: { + hd: [ + "find - no match", + param => ({ TAG: "Eq", - _0: 2, + _0: undefined, _1: Caml_option.undefined_to_opt([ 1, 2, 3, 4 - ].find(function (n) { - return n % 2 === 0; - })) - }; - }) - ], - tl: { - hd: [ - "find - no match", - (function (param) { - return { + ].find(n => n % 2 === 5)) + }) + ], + tl: { + hd: [ + "findi", + param => ({ TAG: "Eq", - _0: undefined, + _0: 1, _1: Caml_option.undefined_to_opt([ 1, 2, 3, 4 - ].find(function (n) { - return n % 2 === 5; - })) - }; - }) - ], - tl: { - hd: [ - "findi", - (function (param) { - return { + ].find((param, i) => i % 2 === 0)) + }) + ], + tl: { + hd: [ + "findi - no match", + param => ({ TAG: "Eq", - _0: 1, + _0: undefined, _1: Caml_option.undefined_to_opt([ 1, 2, 3, 4 - ].find(function (param, i) { - return i % 2 === 0; - })) - }; - }) - ], - tl: { - hd: [ - "findi - no match", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Caml_option.undefined_to_opt([ - 1, - 2, - 3, - 4 - ].find(function (param, i) { - return i % 2 === 5; - })) - }; + ].find((param, i) => i % 2 === 5)) }) ], tl: { hd: [ "findIndex", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3, + 4 + ].findIndex(n => n % 2 === 0) + }) + ], + tl: { + hd: [ + "findIndexi", + param => ({ TAG: "Eq", - _0: 1, + _0: 0, _1: [ 1, 2, 3, 4 - ].findIndex(function (n) { - return n % 2 === 0; - }) - }; - }) - ], - tl: { - hd: [ - "findIndexi", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: [ - 1, - 2, - 3, - 4 - ].findIndex(function (param, i) { - return i % 2 === 0; - }) - }; + ].findIndex((param, i) => i % 2 === 0) }) ], tl: { hd: [ "forEach", - (function (param) { + param => { let sum = { contents: 0 }; @@ -895,7 +783,7 @@ let suites_1 = { 1, 2, 3 - ].forEach(function (n) { + ].forEach(n => { sum.contents = sum.contents + n | 0; }); return { @@ -903,12 +791,12 @@ let suites_1 = { _0: 6, _1: sum.contents }; - }) + } ], tl: { hd: [ "forEachi", - (function (param) { + param => { let sum = { contents: 0 }; @@ -916,7 +804,7 @@ let suites_1 = { 1, 2, 3 - ].forEach(function (param, i) { + ].forEach((param, i) => { sum.contents = sum.contents + i | 0; }); return { @@ -924,160 +812,128 @@ let suites_1 = { _0: 3, _1: sum.contents }; - }) + } ], tl: { hd: [ "map", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 2, + 4, + 6, + 8 + ], + _1: [ + 1, + 2, + 3, + 4 + ].map(n => (n << 1)) + }) + ], + tl: { + hd: [ + "map", + param => ({ TAG: "Eq", _0: [ + 0, 2, 4, - 6, - 8 + 6 ], _1: [ 1, 2, 3, 4 - ].map(function (n) { - return (n << 1); - }) - }; - }) - ], - tl: { - hd: [ - "map", - (function (param) { - return { + ].map((param, i) => (i << 1)) + }) + ], + tl: { + hd: [ + "reduce", + param => ({ TAG: "Eq", - _0: [ - 0, - 2, - 4, - 6 - ], + _0: -10, _1: [ 1, 2, 3, 4 - ].map(function (param, i) { - return (i << 1); - }) - }; - }) - ], - tl: { - hd: [ - "reduce", - (function (param) { - return { + ].reduce((acc, n) => acc - n | 0, 0) + }) + ], + tl: { + hd: [ + "reducei", + param => ({ TAG: "Eq", - _0: -10, + _0: -6, _1: [ 1, 2, 3, 4 - ].reduce((function (acc, n) { - return acc - n | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "reducei", - (function (param) { - return { + ].reduce((acc, param, i) => acc - i | 0, 0) + }) + ], + tl: { + hd: [ + "reduceRight", + param => ({ TAG: "Eq", - _0: -6, + _0: -10, _1: [ 1, 2, 3, 4 - ].reduce((function (acc, param, i) { - return acc - i | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "reduceRight", - (function (param) { - return { + ].reduceRight((acc, n) => acc - n | 0, 0) + }) + ], + tl: { + hd: [ + "reduceRighti", + param => ({ TAG: "Eq", - _0: -10, + _0: -6, _1: [ 1, 2, 3, 4 - ].reduceRight((function (acc, n) { - return acc - n | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "reduceRighti", - (function (param) { - return { + ].reduceRight((acc, param, i) => acc - i | 0, 0) + }) + ], + tl: { + hd: [ + "some", + param => ({ TAG: "Eq", - _0: -6, + _0: false, _1: [ 1, 2, 3, 4 - ].reduceRight((function (acc, param, i) { - return acc - i | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "some", - (function (param) { - return { + ].some(n => n <= 0) + }) + ], + tl: { + hd: [ + "somei", + param => ({ TAG: "Eq", - _0: false, + _0: true, _1: [ 1, 2, 3, 4 - ].some(function (n) { - return n <= 0; - }) - }; - }) - ], - tl: { - hd: [ - "somei", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3, - 4 - ].some(function (param, i) { - return i <= 0; - }) - }; + ].some((param, i) => i <= 0) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_bool_test.js b/jscomp/test/js_bool_test.js index 1c1f6bd5fe..50bd8edab0 100644 --- a/jscomp/test/js_bool_test.js +++ b/jscomp/test/js_bool_test.js @@ -33,35 +33,29 @@ let v = true; let suites_0 = [ "?bool_eq_caml_bool", - (function (param) { - return { - TAG: "Eq", - _0: u, - _1: true - }; + param => ({ + TAG: "Eq", + _0: u, + _1: true }) ]; let suites_1 = { hd: [ "js_bool_eq_js_bool", - (function (param) { - return { - TAG: "Eq", - _0: v, - _1: true - }; + param => ({ + TAG: "Eq", + _0: v, + _1: true }) ], tl: { hd: [ "js_bool_neq_acml_bool", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true === true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true === true }) ], tl: /* [] */0 diff --git a/jscomp/test/js_cast_test.js b/jscomp/test/js_cast_test.js index ba86ae998f..c392fd4587 100644 --- a/jscomp/test/js_cast_test.js +++ b/jscomp/test/js_cast_test.js @@ -24,12 +24,10 @@ function add_test(loc, test) { } function eq(loc, x, y) { - add_test(loc, (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y })); } diff --git a/jscomp/test/js_date_test.js b/jscomp/test/js_date_test.js index ae4924ef81..eb79311a2c 100644 --- a/jscomp/test/js_date_test.js +++ b/jscomp/test/js_date_test.js @@ -10,82 +10,68 @@ function date() { let suites_0 = [ "valueOf", - (function (param) { - return { - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").valueOf() - }; + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").valueOf() }) ]; let suites_1 = { hd: [ "make", - (function (param) { - return { - TAG: "Ok", - _0: new Date().getTime() > 1487223505382 - }; + param => ({ + TAG: "Ok", + _0: new Date().getTime() > 1487223505382 }) ], tl: { hd: [ "parseAsFloat", - (function (param) { - return { - TAG: "Eq", - _0: Date.parse("1976-03-08T12:34:56.789+01:23"), - _1: 195131516789 - }; + param => ({ + TAG: "Eq", + _0: Date.parse("1976-03-08T12:34:56.789+01:23"), + _1: 195131516789 }) ], tl: { hd: [ "parseAsFloat_invalid", - (function (param) { - return { - TAG: "Ok", - _0: Number.isNaN(Date.parse("gibberish")) - }; + param => ({ + TAG: "Ok", + _0: Number.isNaN(Date.parse("gibberish")) }) ], tl: { hd: [ "fromFloat", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date(195131516789).toISOString() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date(195131516789).toISOString() }) ], tl: { hd: [ "fromString_valid", - (function (param) { - return { - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() - }; + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() }) ], tl: { hd: [ "fromString_invalid", - (function (param) { - return { - TAG: "Ok", - _0: Number.isNaN(new Date("gibberish").getTime()) - }; + param => ({ + TAG: "Ok", + _0: Number.isNaN(new Date("gibberish").getTime()) }) ], tl: { hd: [ "makeWithYM", - (function (param) { + param => { let d = new Date(1984, 4); return { TAG: "Eq", @@ -98,12 +84,12 @@ let suites_1 = { d.getMonth() ] }; - }) + } ], tl: { hd: [ "makeWithYMD", - (function (param) { + param => { let d = new Date(1984, 4, 6); return { TAG: "Eq", @@ -118,12 +104,12 @@ let suites_1 = { d.getDate() ] }; - }) + } ], tl: { hd: [ "makeWithYMDH", - (function (param) { + param => { let d = new Date(1984, 4, 6, 3); return { TAG: "Eq", @@ -140,12 +126,12 @@ let suites_1 = { d.getHours() ] }; - }) + } ], tl: { hd: [ "makeWithYMDHM", - (function (param) { + param => { let d = new Date(1984, 4, 6, 3, 59); return { TAG: "Eq", @@ -164,12 +150,12 @@ let suites_1 = { d.getMinutes() ] }; - }) + } ], tl: { hd: [ "makeWithYMDHMS", - (function (param) { + param => { let d = new Date(1984, 4, 6, 3, 59, 27); return { TAG: "Eq", @@ -190,12 +176,12 @@ let suites_1 = { d.getSeconds() ] }; - }) + } ], tl: { hd: [ "utcWithYM", - (function (param) { + param => { let d = Date.UTC(1984, 4); let d$1 = new Date(d); return { @@ -209,12 +195,12 @@ let suites_1 = { d$1.getUTCMonth() ] }; - }) + } ], tl: { hd: [ "utcWithYMD", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6); let d$1 = new Date(d); return { @@ -230,12 +216,12 @@ let suites_1 = { d$1.getUTCDate() ] }; - }) + } ], tl: { hd: [ "utcWithYMDH", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6, 3); let d$1 = new Date(d); return { @@ -253,12 +239,12 @@ let suites_1 = { d$1.getUTCHours() ] }; - }) + } ], tl: { hd: [ "utcWithYMDHM", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6, 3, 59); let d$1 = new Date(d); return { @@ -278,12 +264,12 @@ let suites_1 = { d$1.getUTCMinutes() ] }; - }) + } ], tl: { hd: [ "utcWithYMDHMS", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6, 3, 59, 27); let d$1 = new Date(d); return { @@ -305,155 +291,129 @@ let suites_1 = { d$1.getUTCSeconds() ] }; - }) + } ], tl: { hd: [ "getFullYear", - (function (param) { - return { - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() - }; + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() }) ], tl: { hd: [ "getMilliseconds", - (function (param) { - return { - TAG: "Eq", - _0: 789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getMilliseconds() - }; + param => ({ + TAG: "Eq", + _0: 789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getMilliseconds() }) ], tl: { hd: [ "getSeconds", - (function (param) { - return { - TAG: "Eq", - _0: 56, - _1: new Date("1976-03-08T12:34:56.789+01:23").getSeconds() - }; + param => ({ + TAG: "Eq", + _0: 56, + _1: new Date("1976-03-08T12:34:56.789+01:23").getSeconds() }) ], tl: { hd: [ "getTime", - (function (param) { - return { - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() - }; + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() }) ], tl: { hd: [ "getUTCDate", - (function (param) { - return { - TAG: "Eq", - _0: 8, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDate() - }; + param => ({ + TAG: "Eq", + _0: 8, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDate() }) ], tl: { hd: [ "getUTCDay", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDay() - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDay() }) ], tl: { hd: [ "getUTCFUllYear", - (function (param) { - return { - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCFullYear() - }; + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCFullYear() }) ], tl: { hd: [ "getUTCHours", - (function (param) { - return { - TAG: "Eq", - _0: 11, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCHours() - }; + param => ({ + TAG: "Eq", + _0: 11, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCHours() }) ], tl: { hd: [ "getUTCMilliseconds", - (function (param) { - return { - TAG: "Eq", - _0: 789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMilliseconds() - }; + param => ({ + TAG: "Eq", + _0: 789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMilliseconds() }) ], tl: { hd: [ "getUTCMinutes", - (function (param) { - return { - TAG: "Eq", - _0: 11, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMinutes() - }; + param => ({ + TAG: "Eq", + _0: 11, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMinutes() }) ], tl: { hd: [ "getUTCMonth", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMonth() - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMonth() }) ], tl: { hd: [ "getUTCSeconds", - (function (param) { - return { - TAG: "Eq", - _0: 56, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCSeconds() - }; + param => ({ + TAG: "Eq", + _0: 56, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCSeconds() }) ], tl: { hd: [ "getYear", - (function (param) { - return { - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() - }; + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() }) ], tl: { hd: [ "setDate", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setDate(12); return { @@ -461,12 +421,12 @@ let suites_1 = { _0: 12, _1: d.getDate() }; - }) + } ], tl: { hd: [ "setFullYear", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setFullYear(1986); return { @@ -474,12 +434,12 @@ let suites_1 = { _0: 1986, _1: d.getFullYear() }; - }) + } ], tl: { hd: [ "setFullYearM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setFullYear(1986, 7); return { @@ -493,12 +453,12 @@ let suites_1 = { d.getMonth() ] }; - }) + } ], tl: { hd: [ "setFullYearMD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setFullYear(1986, 7, 23); return { @@ -514,12 +474,12 @@ let suites_1 = { d.getDate() ] }; - }) + } ], tl: { hd: [ "setHours", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setHours(22); return { @@ -527,12 +487,12 @@ let suites_1 = { _0: 22, _1: d.getHours() }; - }) + } ], tl: { hd: [ "setHoursM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setHours(22, 48); return { @@ -546,12 +506,12 @@ let suites_1 = { d.getMinutes() ] }; - }) + } ], tl: { hd: [ "setHoursMS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setHours(22, 48, 54); return { @@ -567,12 +527,12 @@ let suites_1 = { d.getSeconds() ] }; - }) + } ], tl: { hd: [ "setMilliseconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMilliseconds(543); return { @@ -580,12 +540,12 @@ let suites_1 = { _0: 543, _1: d.getMilliseconds() }; - }) + } ], tl: { hd: [ "setMinutes", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMinutes(18); return { @@ -593,12 +553,12 @@ let suites_1 = { _0: 18, _1: d.getMinutes() }; - }) + } ], tl: { hd: [ "setMinutesS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMinutes(18, 42); return { @@ -612,12 +572,12 @@ let suites_1 = { d.getSeconds() ] }; - }) + } ], tl: { hd: [ "setMinutesSMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMinutes(18, 42, 311); return { @@ -633,12 +593,12 @@ let suites_1 = { d.getMilliseconds() ] }; - }) + } ], tl: { hd: [ "setMonth", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMonth(10); return { @@ -646,12 +606,12 @@ let suites_1 = { _0: 10, _1: d.getMonth() }; - }) + } ], tl: { hd: [ "setMonthD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMonth(10, 14); return { @@ -665,12 +625,12 @@ let suites_1 = { d.getDate() ] }; - }) + } ], tl: { hd: [ "setSeconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setSeconds(36); return { @@ -678,12 +638,12 @@ let suites_1 = { _0: 36, _1: d.getSeconds() }; - }) + } ], tl: { hd: [ "setSecondsMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setSeconds(36, 420); return { @@ -697,12 +657,12 @@ let suites_1 = { d.getMilliseconds() ] }; - }) + } ], tl: { hd: [ "setUTCDate", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCDate(12); return { @@ -710,12 +670,12 @@ let suites_1 = { _0: 12, _1: d.getUTCDate() }; - }) + } ], tl: { hd: [ "setUTCFullYear", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCFullYear(1986); return { @@ -723,12 +683,12 @@ let suites_1 = { _0: 1986, _1: d.getUTCFullYear() }; - }) + } ], tl: { hd: [ "setUTCFullYearM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCFullYear(1986, 7); return { @@ -742,12 +702,12 @@ let suites_1 = { d.getUTCMonth() ] }; - }) + } ], tl: { hd: [ "setUTCFullYearMD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCFullYear(1986, 7, 23); return { @@ -763,12 +723,12 @@ let suites_1 = { d.getUTCDate() ] }; - }) + } ], tl: { hd: [ "setUTCHours", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCHours(22); return { @@ -776,12 +736,12 @@ let suites_1 = { _0: 22, _1: d.getUTCHours() }; - }) + } ], tl: { hd: [ "setUTCHoursM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCHours(22, 48); return { @@ -795,12 +755,12 @@ let suites_1 = { d.getUTCMinutes() ] }; - }) + } ], tl: { hd: [ "setUTCHoursMS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCHours(22, 48, 54); return { @@ -816,12 +776,12 @@ let suites_1 = { d.getUTCSeconds() ] }; - }) + } ], tl: { hd: [ "setUTCMilliseconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMilliseconds(543); return { @@ -829,12 +789,12 @@ let suites_1 = { _0: 543, _1: d.getUTCMilliseconds() }; - }) + } ], tl: { hd: [ "setUTCMinutes", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMinutes(18); return { @@ -842,12 +802,12 @@ let suites_1 = { _0: 18, _1: d.getUTCMinutes() }; - }) + } ], tl: { hd: [ "setUTCMinutesS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMinutes(18, 42); return { @@ -861,12 +821,12 @@ let suites_1 = { d.getUTCSeconds() ] }; - }) + } ], tl: { hd: [ "setUTCMinutesSMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMinutes(18, 42, 311); return { @@ -882,12 +842,12 @@ let suites_1 = { d.getUTCMilliseconds() ] }; - }) + } ], tl: { hd: [ "setUTCMonth", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMonth(10); return { @@ -895,12 +855,12 @@ let suites_1 = { _0: 10, _1: d.getUTCMonth() }; - }) + } ], tl: { hd: [ "setUTCMonthD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMonth(10, 14); return { @@ -914,12 +874,12 @@ let suites_1 = { d.getUTCDate() ] }; - }) + } ], tl: { hd: [ "setUTCSeconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCSeconds(36); return { @@ -927,12 +887,12 @@ let suites_1 = { _0: 36, _1: d.getUTCSeconds() }; - }) + } ], tl: { hd: [ "setUTCSecondsMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCSeconds(36, 420); return { @@ -946,78 +906,66 @@ let suites_1 = { d.getUTCMilliseconds() ] }; - }) + } ], tl: { hd: [ "toDateString", - (function (param) { - return { - TAG: "Eq", - _0: "Mon Mar 08 1976", - _1: new Date("1976-03-08T12:34:56.789+01:23").toDateString() - }; + param => ({ + TAG: "Eq", + _0: "Mon Mar 08 1976", + _1: new Date("1976-03-08T12:34:56.789+01:23").toDateString() }) ], tl: { hd: [ "toGMTString", - (function (param) { - return { - TAG: "Eq", - _0: "Mon, 08 Mar 1976 11:11:56 GMT", - _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() - }; + param => ({ + TAG: "Eq", + _0: "Mon, 08 Mar 1976 11:11:56 GMT", + _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() }) ], tl: { hd: [ "toISOString", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toISOString() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toISOString() }) ], tl: { hd: [ "toJSON", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() }) ], tl: { hd: [ "toJSONUnsafe", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() }) ], tl: { hd: [ "toUTCString", - (function (param) { - return { - TAG: "Eq", - _0: "Mon, 08 Mar 1976 11:11:56 GMT", - _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() - }; + param => ({ + TAG: "Eq", + _0: "Mon, 08 Mar 1976 11:11:56 GMT", + _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() }) ], tl: { hd: [ "eq", - (function (param) { + param => { let a = new Date("2013-03-01T01:10:00"); let b = new Date("2013-03-01T01:10:00"); let c = new Date("2013-03-01T01:10:01"); @@ -1025,7 +973,7 @@ let suites_1 = { TAG: "Ok", _0: Caml_obj.equal(a, b) && Caml_obj.notequal(b, c) && Caml_obj.greaterthan(c, b) }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/js_dict_test.js b/jscomp/test/js_dict_test.js index e9085c3ca6..231646783a 100644 --- a/jscomp/test/js_dict_test.js +++ b/jscomp/test/js_dict_test.js @@ -13,61 +13,53 @@ function obj() { let suites_0 = [ "empty", - (function (param) { - return { - TAG: "Eq", - _0: [], - _1: Object.keys({}) - }; + param => ({ + TAG: "Eq", + _0: [], + _1: Object.keys({}) }) ]; let suites_1 = { hd: [ "get", - (function (param) { - return { - TAG: "Eq", - _0: 43, - _1: Js_dict.get({ - foo: 43, - bar: 86 - }, "foo") - }; + param => ({ + TAG: "Eq", + _0: 43, + _1: Js_dict.get({ + foo: 43, + bar: 86 + }, "foo") }) ], tl: { hd: [ "get - property not in object", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_dict.get({ - foo: 43, - bar: 86 - }, "baz") - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_dict.get({ + foo: 43, + bar: 86 + }, "baz") }) ], tl: { hd: [ "unsafe_get", - (function (param) { - return { - TAG: "Eq", - _0: 43, - _1: ({ - foo: 43, - bar: 86 - })["foo"] - }; + param => ({ + TAG: "Eq", + _0: 43, + _1: ({ + foo: 43, + bar: 86 + })["foo"] }) ], tl: { hd: [ "set", - (function (param) { + param => { let o = { foo: 43, bar: 86 @@ -78,165 +70,147 @@ let suites_1 = { _0: 36, _1: Js_dict.get(o, "foo") }; - }) + } ], tl: { hd: [ "keys", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + "foo", + "bar" + ], + _1: Object.keys({ + foo: 43, + bar: 86 + }) + }) + ], + tl: { + hd: [ + "entries", + param => ({ TAG: "Eq", _0: [ - "foo", - "bar" + [ + "foo", + 43 + ], + [ + "bar", + 86 + ] ], - _1: Object.keys({ + _1: Js_dict.entries({ foo: 43, bar: 86 }) - }; - }) - ], - tl: { - hd: [ - "entries", - (function (param) { - return { + }) + ], + tl: { + hd: [ + "values", + param => ({ TAG: "Eq", _0: [ - [ - "foo", - 43 - ], - [ - "bar", - 86 - ] + 43, + 86 ], - _1: Js_dict.entries({ + _1: Js_dict.values({ foo: 43, bar: 86 }) - }; - }) - ], - tl: { - hd: [ - "values", - (function (param) { - return { - TAG: "Eq", - _0: [ - 43, - 86 - ], - _1: Js_dict.values({ - foo: 43, - bar: 86 - }) - }; }) ], tl: { hd: [ "fromList - []", - (function (param) { - return { - TAG: "Eq", - _0: {}, - _1: Js_dict.fromList(/* [] */0) - }; + param => ({ + TAG: "Eq", + _0: {}, + _1: Js_dict.fromList(/* [] */0) }) ], tl: { hd: [ "fromList", - (function (param) { - return { - TAG: "Eq", - _0: [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] + param => ({ + TAG: "Eq", + _0: [ + [ + "x", + 23 + ], + [ + "y", + 46 + ] + ], + _1: Js_dict.entries(Js_dict.fromList({ + hd: [ + "x", + 23 ], - _1: Js_dict.entries(Js_dict.fromList({ + tl: { hd: [ - "x", - 23 + "y", + 46 ], - tl: { - hd: [ - "y", - 46 - ], - tl: /* [] */0 - } - })) - }; + tl: /* [] */0 + } + })) }) ], tl: { hd: [ "fromArray - []", - (function (param) { - return { - TAG: "Eq", - _0: {}, - _1: Js_dict.fromArray([]) - }; + param => ({ + TAG: "Eq", + _0: {}, + _1: Js_dict.fromArray([]) }) ], tl: { hd: [ "fromArray", - (function (param) { - return { - TAG: "Eq", - _0: [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] + param => ({ + TAG: "Eq", + _0: [ + [ + "x", + 23 ], - _1: Js_dict.entries(Js_dict.fromArray([ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ])) - }; + [ + "y", + 46 + ] + ], + _1: Js_dict.entries(Js_dict.fromArray([ + [ + "x", + 23 + ], + [ + "y", + 46 + ] + ])) }) ], tl: { hd: [ "map", - (function (param) { - return { - TAG: "Eq", - _0: { - foo: "43", - bar: "86" - }, - _1: Js_dict.map((function (i) { - return String(i); - }), { - foo: 43, - bar: 86 - }) - }; + param => ({ + TAG: "Eq", + _0: { + foo: "43", + bar: "86" + }, + _1: Js_dict.map(i => String(i), { + foo: 43, + bar: 86 + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_exception_catch_test.js b/jscomp/test/js_exception_catch_test.js index 4f0fa303d2..f4580b614a 100644 --- a/jscomp/test/js_exception_catch_test.js +++ b/jscomp/test/js_exception_catch_test.js @@ -27,30 +27,24 @@ function add_test(loc, test) { } function eq(loc, x, y) { - add_test(loc, (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y })); } function false_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } function true_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: true - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: true })); } @@ -64,11 +58,9 @@ try { } catch (raw_x) { let x = Caml_js_exceptions.internalToOCamlException(raw_x); if (x.RE_EXN_ID === Js_exn.$$Error) { - add_test("File \"js_exception_catch_test.res\", line 18, characters 37-44", (function () { - return { - TAG: "Ok", - _0: true - }; + add_test("File \"js_exception_catch_test.res\", line 18, characters 37-44", () => ({ + TAG: "Ok", + _0: true })); } else { throw new Error(x.RE_EXN_ID, { @@ -78,11 +70,9 @@ try { } if (exit === 1) { - add_test("File \"js_exception_catch_test.res\", line 19, characters 14-21", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_exception_catch_test.res\", line 19, characters 14-21", () => ({ + TAG: "Ok", + _0: false })); } @@ -128,11 +118,9 @@ function test(f) { } } -eq("File \"js_exception_catch_test.res\", line 44, characters 5-12", test(function () { - -}), "No_error"); +eq("File \"js_exception_catch_test.res\", line 44, characters 5-12", test(() => {}), "No_error"); -eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(() => { throw new Error("Not_found", { cause: { RE_EXN_ID: "Not_found" @@ -140,7 +128,7 @@ eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(functi }); }), "Not_found"); -eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(() => { throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", @@ -149,7 +137,7 @@ eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(functi }); }), "Invalid_argument"); -eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(() => { throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", @@ -158,7 +146,7 @@ eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(functi }); }), "Invalid_any"); -eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(() => { throw new Error(A, { cause: { RE_EXN_ID: A, @@ -167,7 +155,7 @@ eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(functi }); }), "A2"); -eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(() => { throw new Error(A, { cause: { RE_EXN_ID: A, @@ -176,7 +164,7 @@ eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(functi }); }), "A_any"); -eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(() => { throw new Error(B, { cause: { RE_EXN_ID: B @@ -184,7 +172,7 @@ eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(functi }); }), "B"); -eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(() => { throw new Error(C, { cause: { RE_EXN_ID: C, @@ -194,7 +182,7 @@ eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(functi }); }), "C"); -eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(() => { throw new Error(C, { cause: { RE_EXN_ID: C, @@ -204,13 +192,13 @@ eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(functi }); }), "C_any"); -eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => { throw new Error(new Error("x").RE_EXN_ID, { cause: new Error("x") }); }), "Js_error"); -eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(() => { throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", diff --git a/jscomp/test/js_float_test.js b/jscomp/test/js_float_test.js index 28a31f0f7a..9c7bd025d5 100644 --- a/jscomp/test/js_float_test.js +++ b/jscomp/test/js_float_test.js @@ -6,484 +6,398 @@ let Pervasives = require("../../lib/js/pervasives.js"); let suites_0 = [ "_NaN <> _NaN", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: NaN === NaN - }; + param => ({ + TAG: "Eq", + _0: false, + _1: NaN === NaN }) ]; let suites_1 = { hd: [ "isNaN - _NaN", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Number.isNaN(NaN) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isNaN(NaN) }) ], tl: { hd: [ "isNaN - 0.", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isNaN(0) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isNaN(0) }) ], tl: { hd: [ "isFinite - infinity", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isFinite(Pervasives.infinity) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(Pervasives.infinity) }) ], tl: { hd: [ "isFinite - neg_infinity", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isFinite(Pervasives.neg_infinity) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(Pervasives.neg_infinity) }) ], tl: { hd: [ "isFinite - _NaN", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isFinite(NaN) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(NaN) }) ], tl: { hd: [ "isFinite - 0.", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Number.isFinite(0) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isFinite(0) }) ], tl: { hd: [ "toExponential", - (function (param) { - return { - TAG: "Eq", - _0: "1.23456e+2", - _1: (123.456).toExponential() - }; + param => ({ + TAG: "Eq", + _0: "1.23456e+2", + _1: (123.456).toExponential() }) ], tl: { hd: [ "toExponential - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toExponential() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toExponential() }) ], tl: { hd: [ "toExponentialWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.23e+2", - _1: (123.456).toExponential(2) - }; + param => ({ + TAG: "Eq", + _0: "1.23e+2", + _1: (123.456).toExponential(2) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "1.2346e+2", - _1: (123.456).toExponential(4) - }; + param => ({ + TAG: "Eq", + _0: "1.2346e+2", + _1: (123.456).toExponential(4) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.00000000000000000000e+0", - _1: (0).toExponential(20) - }; + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000e+0", + _1: (0).toExponential(20) }) ], tl: { hd: [ "File \"js_float_test.res\", line 27, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(101); + } }) ], tl: { hd: [ "toExponentialWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(-1); + } }) ], tl: { hd: [ "toFixed", - (function (param) { - return { - TAG: "Eq", - _0: "123", - _1: (123.456).toFixed() - }; + param => ({ + TAG: "Eq", + _0: "123", + _1: (123.456).toFixed() }) ], tl: { hd: [ "toFixed - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toFixed() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toFixed() }) ], tl: { hd: [ "toFixedWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "123.46", - _1: (123.456).toFixed(2) - }; + param => ({ + TAG: "Eq", + _0: "123.46", + _1: (123.456).toFixed(2) }) ], tl: { hd: [ "toFixedWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "123.4560", - _1: (123.456).toFixed(4) - }; + param => ({ + TAG: "Eq", + _0: "123.4560", + _1: (123.456).toFixed(4) }) ], tl: { hd: [ "toFixedWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.00000000000000000000", - _1: (0).toFixed(20) - }; + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000", + _1: (0).toFixed(20) }) ], tl: { hd: [ "toFixedWithPrecision - digits:101", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toFixed(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toFixed(101); + } }) ], tl: { hd: [ "toFixedWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toFixed(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toFixed(-1); + } }) ], tl: { hd: [ "toPrecision", - (function (param) { - return { - TAG: "Eq", - _0: "123.456", - _1: (123.456).toPrecision() - }; + param => ({ + TAG: "Eq", + _0: "123.456", + _1: (123.456).toPrecision() }) ], tl: { hd: [ "toPrecision - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toPrecision() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toPrecision() }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+2", - _1: (123.456).toPrecision(2) - }; + param => ({ + TAG: "Eq", + _0: "1.2e+2", + _1: (123.456).toPrecision(2) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "123.5", - _1: (123.456).toPrecision(4) - }; + param => ({ + TAG: "Eq", + _0: "123.5", + _1: (123.456).toPrecision(4) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.0000000000000000000", - _1: (0).toPrecision(20) - }; + param => ({ + TAG: "Eq", + _0: "0.0000000000000000000", + _1: (0).toPrecision(20) }) ], tl: { hd: [ "File \"js_float_test.res\", line 68, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(101); + } }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(-1); + } }) ], tl: { hd: [ "toString", - (function (param) { - return { - TAG: "Eq", - _0: "1.23", - _1: (1.23).toString() - }; + param => ({ + TAG: "Eq", + _0: "1.23", + _1: (1.23).toString() }) ], tl: { hd: [ "toString - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toString() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toString() }) ], tl: { hd: [ "toStringWithRadix - radix:2", - (function (param) { - return { - TAG: "Eq", - _0: "1111011.0111010010111100011010100111111011111001110111", - _1: (123.456).toString(2) - }; + param => ({ + TAG: "Eq", + _0: "1111011.0111010010111100011010100111111011111001110111", + _1: (123.456).toString(2) }) ], tl: { hd: [ "toStringWithRadix - radix:16", - (function (param) { - return { - TAG: "Eq", - _0: "7b.74bc6a7ef9dc", - _1: (123.456).toString(16) - }; + param => ({ + TAG: "Eq", + _0: "7b.74bc6a7ef9dc", + _1: (123.456).toString(16) }) ], tl: { hd: [ "toStringWithRadix - radix:36", - (function (param) { - return { - TAG: "Eq", - _0: "3f", - _1: (123).toString(36) - }; + param => ({ + TAG: "Eq", + _0: "3f", + _1: (123).toString(36) }) ], tl: { hd: [ "toStringWithRadix - radix:37", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(37); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(37); + } }) ], tl: { hd: [ "toStringWithRadix - radix:1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(1); + } }) ], tl: { hd: [ "toStringWithRadix - radix:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(-1); + } }) ], tl: { hd: [ "fromString - 123", - (function (param) { - return { - TAG: "Eq", - _0: 123, - _1: Number("123") - }; + param => ({ + TAG: "Eq", + _0: 123, + _1: Number("123") }) ], tl: { hd: [ "fromString - 12.3", - (function (param) { - return { - TAG: "Eq", - _0: 12.3, - _1: Number("12.3") - }; + param => ({ + TAG: "Eq", + _0: 12.3, + _1: Number("12.3") }) ], tl: { hd: [ "fromString - empty string", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Number("") - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Number("") }) ], tl: { hd: [ "fromString - 0x11", - (function (param) { - return { - TAG: "Eq", - _0: 17, - _1: Number("0x11") - }; + param => ({ + TAG: "Eq", + _0: 17, + _1: Number("0x11") }) ], tl: { hd: [ "fromString - 0b11", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Number("0b11") - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Number("0b11") }) ], tl: { hd: [ "fromString - 0o11", - (function (param) { - return { - TAG: "Eq", - _0: 9, - _1: Number("0o11") - }; + param => ({ + TAG: "Eq", + _0: 9, + _1: Number("0o11") }) ], tl: { hd: [ "fromString - invalid string", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Number.isNaN(Number("foo")) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isNaN(Number("foo")) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_global_test.js b/jscomp/test/js_global_test.js index 298af9a7c6..8a77b3aef1 100644 --- a/jscomp/test/js_global_test.js +++ b/jscomp/test/js_global_test.js @@ -5,74 +5,62 @@ let Mt = require("./mt.js"); let suites_0 = [ "setTimeout/clearTimeout sanity check", - (function (param) { - let handle = setTimeout((function () { - - }), 0); + param => { + let handle = setTimeout(() => {}, 0); clearTimeout(handle); return { TAG: "Ok", _0: true }; - }) + } ]; let suites_1 = { hd: [ "setInerval/clearInterval sanity check", - (function (param) { - let handle = setInterval((function () { - - }), 0); + param => { + let handle = setInterval(() => {}, 0); clearInterval(handle); return { TAG: "Ok", _0: true }; - }) + } ], tl: { hd: [ "encodeURI", - (function (param) { - return { - TAG: "Eq", - _0: encodeURI("[-=-]"), - _1: "%5B-=-%5D" - }; + param => ({ + TAG: "Eq", + _0: encodeURI("[-=-]"), + _1: "%5B-=-%5D" }) ], tl: { hd: [ "decodeURI", - (function (param) { - return { - TAG: "Eq", - _0: decodeURI("%5B-=-%5D"), - _1: "[-=-]" - }; + param => ({ + TAG: "Eq", + _0: decodeURI("%5B-=-%5D"), + _1: "[-=-]" }) ], tl: { hd: [ "encodeURIComponent", - (function (param) { - return { - TAG: "Eq", - _0: encodeURIComponent("[-=-]"), - _1: "%5B-%3D-%5D" - }; + param => ({ + TAG: "Eq", + _0: encodeURIComponent("[-=-]"), + _1: "%5B-%3D-%5D" }) ], tl: { hd: [ "decodeURIComponent", - (function (param) { - return { - TAG: "Eq", - _0: decodeURIComponent("%5B-%3D-%5D"), - _1: "[-=-]" - }; + param => ({ + TAG: "Eq", + _0: decodeURIComponent("%5B-%3D-%5D"), + _1: "[-=-]" }) ], tl: /* [] */0 diff --git a/jscomp/test/js_int_test.js b/jscomp/test/js_int_test.js index bb6fb5d699..e7a41d3a1f 100644 --- a/jscomp/test/js_int_test.js +++ b/jscomp/test/js_int_test.js @@ -5,218 +5,180 @@ let Mt = require("./mt.js"); let suites_0 = [ "toExponential", - (function (param) { - return { - TAG: "Eq", - _0: "1.23456e+5", - _1: (123456).toExponential() - }; + param => ({ + TAG: "Eq", + _0: "1.23456e+5", + _1: (123456).toExponential() }) ]; let suites_1 = { hd: [ "toExponentialWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.23e+5", - _1: (123456).toExponential(2) - }; + param => ({ + TAG: "Eq", + _0: "1.23e+5", + _1: (123456).toExponential(2) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "1.2346e+5", - _1: (123456).toExponential(4) - }; + param => ({ + TAG: "Eq", + _0: "1.2346e+5", + _1: (123456).toExponential(4) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.00000000000000000000e+0", - _1: (0).toExponential(20) - }; + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000e+0", + _1: (0).toExponential(20) }) ], tl: { hd: [ "File \"js_int_test.res\", line 19, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(101); + } }) ], tl: { hd: [ "toExponentialWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(-1); + } }) ], tl: { hd: [ "toPrecision", - (function (param) { - return { - TAG: "Eq", - _0: "123456", - _1: (123456).toPrecision() - }; + param => ({ + TAG: "Eq", + _0: "123456", + _1: (123456).toPrecision() }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+5", - _1: (123456).toPrecision(2) - }; + param => ({ + TAG: "Eq", + _0: "1.2e+5", + _1: (123456).toPrecision(2) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "1.235e+5", - _1: (123456).toPrecision(4) - }; + param => ({ + TAG: "Eq", + _0: "1.235e+5", + _1: (123456).toPrecision(4) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.0000000000000000000", - _1: (0).toPrecision(20) - }; + param => ({ + TAG: "Eq", + _0: "0.0000000000000000000", + _1: (0).toPrecision(20) }) ], tl: { hd: [ "File \"js_int_test.res\", line 37, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(101); + } }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(-1); + } }) ], tl: { hd: [ "toString", - (function (param) { - return { - TAG: "Eq", - _0: "123", - _1: (123).toString() - }; + param => ({ + TAG: "Eq", + _0: "123", + _1: (123).toString() }) ], tl: { hd: [ "toStringWithRadix - radix:2", - (function (param) { - return { - TAG: "Eq", - _0: "11110001001000000", - _1: (123456).toString(2) - }; + param => ({ + TAG: "Eq", + _0: "11110001001000000", + _1: (123456).toString(2) }) ], tl: { hd: [ "toStringWithRadix - radix:16", - (function (param) { - return { - TAG: "Eq", - _0: "1e240", - _1: (123456).toString(16) - }; + param => ({ + TAG: "Eq", + _0: "1e240", + _1: (123456).toString(16) }) ], tl: { hd: [ "toStringWithRadix - radix:36", - (function (param) { - return { - TAG: "Eq", - _0: "2n9c", - _1: (123456).toString(36) - }; + param => ({ + TAG: "Eq", + _0: "2n9c", + _1: (123456).toString(36) }) ], tl: { hd: [ "toStringWithRadix - radix:37", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(37); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(37); + } }) ], tl: { hd: [ "toStringWithRadix - radix:1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(1); + } }) ], tl: { hd: [ "toStringWithRadix - radix:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(-1); + } }) ], tl: /* [] */0 diff --git a/jscomp/test/js_json_test.js b/jscomp/test/js_json_test.js index 98d00e1596..e9af1d1c3b 100644 --- a/jscomp/test/js_json_test.js +++ b/jscomp/test/js_json_test.js @@ -31,36 +31,30 @@ function add_test(loc, test) { } function eq(loc, x, y) { - add_test(loc, (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y })); } function false_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } function true_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: true - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: true })); } let v = JSON.parse(" { \"x\" : [1, 2, 3 ] } "); -add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { +add_test("File \"js_json_test.res\", line 22, characters 11-18", () => { let ty = Js_json.classify(v); if (typeof ty !== "object") { return { @@ -94,7 +88,7 @@ add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { _0: false }; } - ty2._0.forEach(function (x) { + ty2._0.forEach(x => { let ty3 = Js_json.classify(x); if (typeof ty3 !== "object") { throw new Error("Assert_failure", { @@ -126,7 +120,7 @@ add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { TAG: "Ok", _0: true }; -})); +}); eq("File \"js_json_test.res\", line 48, characters 5-12", Js_json.test(v, "Object"), true); @@ -136,28 +130,22 @@ let ty = Js_json.classify(json); if (typeof ty !== "object") { if (ty === "JSONNull") { - add_test("File \"js_json_test.res\", line 55, characters 24-31", (function () { - return { - TAG: "Ok", - _0: true - }; + add_test("File \"js_json_test.res\", line 55, characters 24-31", () => ({ + TAG: "Ok", + _0: true })); } else { console.log(ty); - add_test("File \"js_json_test.res\", line 58, characters 11-18", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 58, characters 11-18", () => ({ + TAG: "Ok", + _0: false })); } } else { console.log(ty); - add_test("File \"js_json_test.res\", line 58, characters 11-18", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 58, characters 11-18", () => ({ + TAG: "Ok", + _0: false })); } @@ -166,20 +154,16 @@ let json$1 = JSON.parse(JSON.stringify("test string")); let ty$1 = Js_json.classify(json$1); if (typeof ty$1 !== "object") { - add_test("File \"js_json_test.res\", line 68, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 68, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONString") { eq("File \"js_json_test.res\", line 67, characters 26-33", ty$1._0, "test string"); } else { - add_test("File \"js_json_test.res\", line 68, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 68, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } @@ -196,11 +180,9 @@ if (typeof ty$2 !== "object" || ty$2.TAG !== "JSONNumber") { } if (exit === 1) { - add_test("File \"js_json_test.res\", line 78, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 78, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } @@ -217,11 +199,9 @@ if (typeof ty$3 !== "object" || ty$3.TAG !== "JSONNumber") { } if (exit$1 === 1) { - add_test("File \"js_json_test.res\", line 88, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 88, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } @@ -229,11 +209,9 @@ function test(v) { let json = JSON.parse(JSON.stringify(v)); let ty = Js_json.classify(json); if (typeof ty === "object") { - return add_test("File \"js_json_test.res\", line 100, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test("File \"js_json_test.res\", line 100, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } switch (ty) { @@ -242,11 +220,9 @@ function test(v) { case "JSONTrue" : return eq("File \"js_json_test.res\", line 98, characters 23-30", true, v); default: - return add_test("File \"js_json_test.res\", line 100, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test("File \"js_json_test.res\", line 100, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } } @@ -282,173 +258,135 @@ let json$4 = JSON.parse(JSON.stringify(dict)); let ty$4 = Js_json.classify(json$4); if (typeof ty$4 !== "object") { - add_test("File \"js_json_test.res\", line 142, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 142, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$4.TAG === "JSONObject") { let x = ty$4._0; let ta = Js_json.classify(option_get(Js_dict.get(x, "a"))); if (typeof ta !== "object") { - add_test("File \"js_json_test.res\", line 140, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 140, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } else if (ta.TAG === "JSONString") { if (ta._0 !== "test string") { - add_test("File \"js_json_test.res\", line 131, characters 15-22", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 131, characters 15-22", () => ({ + TAG: "Ok", + _0: false })); } else { let ty$5 = Js_json.classify(option_get(Js_dict.get(x, "b"))); if (typeof ty$5 !== "object") { - add_test("File \"js_json_test.res\", line 137, characters 22-29", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 137, characters 22-29", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$5.TAG === "JSONNumber") { let b = ty$5._0; - add_test("File \"js_json_test.res\", line 136, characters 38-45", (function () { - return { - TAG: "Approx", - _0: 123.0, - _1: b - }; + add_test("File \"js_json_test.res\", line 136, characters 38-45", () => ({ + TAG: "Approx", + _0: 123.0, + _1: b })); } else { - add_test("File \"js_json_test.res\", line 137, characters 22-29", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 137, characters 22-29", () => ({ + TAG: "Ok", + _0: false })); } } } else { - add_test("File \"js_json_test.res\", line 140, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 140, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } } else { - add_test("File \"js_json_test.res\", line 142, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 142, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } function eq_at_i(loc, json, i, kind, expected) { let ty = Js_json.classify(json); if (typeof ty !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } if (ty.TAG !== "JSONArray") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } let ty$1 = Js_json.classify(Caml_array.get(ty._0, i)); switch (kind) { case "String" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONString") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Number" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONNumber") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Object" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONObject") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Array" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONArray") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Boolean" : if (typeof ty$1 === "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } switch (ty$1) { @@ -457,44 +395,34 @@ function eq_at_i(loc, json, i, kind, expected) { case "JSONTrue" : return eq(loc, true, expected); default: - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Null" : if (typeof ty$1 !== "object") { if (ty$1 === "JSONNull") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: true - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: true })); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } } } -let json$5 = JSON.parse(JSON.stringify($$Array.map((function (prim) { - return prim; -}), [ +let json$5 = JSON.parse(JSON.stringify($$Array.map(prim => prim, [ "string 0", "string 1", "string 2" @@ -538,9 +466,7 @@ let a$1 = [ -268391749 ]; -let json$8 = JSON.parse(JSON.stringify($$Array.map((function (prim) { - return prim; -}), a$1))); +let json$8 = JSON.parse(JSON.stringify($$Array.map(prim => prim, a$1))); eq_at_i("File \"js_json_test.res\", line 230, characters 10-17", json$8, 0, "Number", Caml_array.get(a$1, 0)); @@ -579,71 +505,55 @@ let json$10 = JSON.parse(JSON.stringify(a$3)); let ty$6 = Js_json.classify(json$10); if (typeof ty$6 !== "object") { - add_test("File \"js_json_test.res\", line 271, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$6.TAG === "JSONArray") { let ty$7 = Js_json.classify(Caml_array.get(ty$6._0, 1)); if (typeof ty$7 !== "object") { - add_test("File \"js_json_test.res\", line 269, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$7.TAG === "JSONObject") { let ty$8 = Js_json.classify(option_get(Js_dict.get(ty$7._0, "a"))); if (typeof ty$8 !== "object") { - add_test("File \"js_json_test.res\", line 267, characters 20-27", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$8.TAG === "JSONString") { eq("File \"js_json_test.res\", line 266, characters 35-42", ty$8._0, "bbb"); } else { - add_test("File \"js_json_test.res\", line 267, characters 20-27", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ + TAG: "Ok", + _0: false })); } } else { - add_test("File \"js_json_test.res\", line 269, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } } else { - add_test("File \"js_json_test.res\", line 271, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } try { JSON.parse("{{ A}"); - add_test("File \"js_json_test.res\", line 279, characters 11-18", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 279, characters 11-18", () => ({ + TAG: "Ok", + _0: false })); } catch (exn) { - add_test("File \"js_json_test.res\", line 281, characters 17-24", (function () { - return { - TAG: "Ok", - _0: true - }; + add_test("File \"js_json_test.res\", line 281, characters 17-24", () => ({ + TAG: "Ok", + _0: true })); } @@ -756,21 +666,21 @@ idtest({ tl: /* [] */0 }); -idtest(Belt_List.makeBy(500, (function (i) { +idtest(Belt_List.makeBy(500, i => { if (i % 2 === 0) { return; } else { return 1; } -}))); +})); -idtest(Belt_Array.makeBy(500, (function (i) { +idtest(Belt_Array.makeBy(500, i => { if (i % 2 === 0) { return; } else { return 1; } -}))); +})); Mt.from_pair_suites("Js_json_test", suites.contents); diff --git a/jscomp/test/js_math_test.js b/jscomp/test/js_math_test.js index 1d1ab94d30..fc2059ea26 100644 --- a/jscomp/test/js_math_test.js +++ b/jscomp/test/js_math_test.js @@ -6,670 +6,558 @@ let Js_math = require("../../lib/js/js_math.js"); let suites_0 = [ "_E", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 2.718, - _2: Math.E - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 2.718, + _2: Math.E }) ]; let suites_1 = { hd: [ "_LN2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.693, - _2: Math.LN2 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.693, + _2: Math.LN2 }) ], tl: { hd: [ "_LN10", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 2.303, - _2: Math.LN10 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 2.303, + _2: Math.LN10 }) ], tl: { hd: [ "_LOG2E", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.443, - _2: Math.LOG2E - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.443, + _2: Math.LOG2E }) ], tl: { hd: [ "_LOG10E", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.434, - _2: Math.LOG10E - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.434, + _2: Math.LOG10E }) ], tl: { hd: [ "_PI", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.00001, - _1: 3.14159, - _2: Math.PI - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.00001, + _1: 3.14159, + _2: Math.PI }) ], tl: { hd: [ "_SQRT1_2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.707, - _2: Math.SQRT1_2 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.707, + _2: Math.SQRT1_2 }) ], tl: { hd: [ "_SQRT2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.414, - _2: Math.SQRT2 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.414, + _2: Math.SQRT2 }) ], tl: { hd: [ "abs_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.abs(-4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.abs(-4) }) ], tl: { hd: [ "abs_float", - (function (param) { - return { - TAG: "Eq", - _0: 1.2, - _1: Math.abs(-1.2) - }; + param => ({ + TAG: "Eq", + _0: 1.2, + _1: Math.abs(-1.2) }) ], tl: { hd: [ "acos", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.159, - _2: Math.acos(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.159, + _2: Math.acos(0.4) }) ], tl: { hd: [ "acosh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.622, - _2: Math.acosh(1.2) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.622, + _2: Math.acosh(1.2) }) ], tl: { hd: [ "asin", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.411, - _2: Math.asin(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.411, + _2: Math.asin(0.4) }) ], tl: { hd: [ "asinh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.390, - _2: Math.asinh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.390, + _2: Math.asinh(0.4) }) ], tl: { hd: [ "atan", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.380, - _2: Math.atan(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.380, + _2: Math.atan(0.4) }) ], tl: { hd: [ "atanh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.423, - _2: Math.atanh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.423, + _2: Math.atanh(0.4) }) ], tl: { hd: [ "atan2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.588, - _2: Math.atan2(0.4, 0.6) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.588, + _2: Math.atan2(0.4, 0.6) }) ], tl: { hd: [ "cbrt", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Math.cbrt(8) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.cbrt(8) }) ], tl: { hd: [ "unsafe_ceil_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.ceil(3.2) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.ceil(3.2) }) ], tl: { hd: [ "ceil_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Js_math.ceil_int(3.2) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_math.ceil_int(3.2) }) ], tl: { hd: [ "ceil_float", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.ceil(3.2) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.ceil(3.2) }) ], tl: { hd: [ "cos", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.921, - _2: Math.cos(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.921, + _2: Math.cos(0.4) }) ], tl: { hd: [ "cosh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.081, - _2: Math.cosh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.081, + _2: Math.cosh(0.4) }) ], tl: { hd: [ "exp", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.491, - _2: Math.exp(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.491, + _2: Math.exp(0.4) }) ], tl: { hd: [ "expm1", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.491, - _2: Math.expm1(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.491, + _2: Math.expm1(0.4) }) ], tl: { hd: [ "unsafe_floor_int", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.floor(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.floor(3.2) }) ], tl: { hd: [ "floor_int", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Js_math.floor_int(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Js_math.floor_int(3.2) }) ], tl: { hd: [ "floor_float", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.floor(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.floor(3.2) }) ], tl: { hd: [ "fround", - (function (param) { - return { - TAG: "Approx", - _0: 3.2, - _1: Math.fround(3.2) - }; + param => ({ + TAG: "Approx", + _0: 3.2, + _1: Math.fround(3.2) }) ], tl: { hd: [ "hypot", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.721, - _2: Math.hypot(0.4, 0.6) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.721, + _2: Math.hypot(0.4, 0.6) }) ], tl: { hd: [ "hypotMany", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.077, - _2: Math.hypot(0.4, 0.6, 0.8) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.077, + _2: Math.hypot(0.4, 0.6, 0.8) }) ], tl: { hd: [ "imul", - (function (param) { - return { - TAG: "Eq", - _0: 8, - _1: Math.imul(4, 2) - }; + param => ({ + TAG: "Eq", + _0: 8, + _1: Math.imul(4, 2) }) ], tl: { hd: [ "log", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: -0.916, - _2: Math.log(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -0.916, + _2: Math.log(0.4) }) ], tl: { hd: [ "log1p", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.336, - _2: Math.log1p(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.336, + _2: Math.log1p(0.4) }) ], tl: { hd: [ "log10", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: -0.397, - _2: Math.log10(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -0.397, + _2: Math.log10(0.4) }) ], tl: { hd: [ "log2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: -1.321, - _2: Math.log2(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -1.321, + _2: Math.log2(0.4) }) ], tl: { hd: [ "max_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.max(2, 4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.max(2, 4) }) ], tl: { hd: [ "maxMany_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.max(2, 4, 3) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.max(2, 4, 3) }) ], tl: { hd: [ "max_float", - (function (param) { - return { - TAG: "Eq", - _0: 4.2, - _1: Math.max(2.7, 4.2) - }; + param => ({ + TAG: "Eq", + _0: 4.2, + _1: Math.max(2.7, 4.2) }) ], tl: { hd: [ "maxMany_float", - (function (param) { - return { - TAG: "Eq", - _0: 4.2, - _1: Math.max(2.7, 4.2, 3.9) - }; + param => ({ + TAG: "Eq", + _0: 4.2, + _1: Math.max(2.7, 4.2, 3.9) }) ], tl: { hd: [ "min_int", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Math.min(2, 4) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.min(2, 4) }) ], tl: { hd: [ "minMany_int", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Math.min(2, 4, 3) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.min(2, 4, 3) }) ], tl: { hd: [ "min_float", - (function (param) { - return { - TAG: "Eq", - _0: 2.7, - _1: Math.min(2.7, 4.2) - }; + param => ({ + TAG: "Eq", + _0: 2.7, + _1: Math.min(2.7, 4.2) }) ], tl: { hd: [ "minMany_float", - (function (param) { - return { - TAG: "Eq", - _0: 2.7, - _1: Math.min(2.7, 4.2, 3.9) - }; + param => ({ + TAG: "Eq", + _0: 2.7, + _1: Math.min(2.7, 4.2, 3.9) }) ], tl: { hd: [ "random", - (function (param) { + param => { let a = Math.random(); return { TAG: "Ok", _0: a >= 0 && a < 1 }; - }) + } ], tl: { hd: [ "random_int", - (function (param) { + param => { let a = Js_math.random_int(1, 3); return { TAG: "Ok", _0: a >= 1 && a < 3 }; - }) + } ], tl: { hd: [ "unsafe_round", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.round(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.round(3.2) }) ], tl: { hd: [ "round", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.round(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.round(3.2) }) ], tl: { hd: [ "sign_int", - (function (param) { - return { - TAG: "Eq", - _0: -1, - _1: Math.sign(-4) - }; + param => ({ + TAG: "Eq", + _0: -1, + _1: Math.sign(-4) }) ], tl: { hd: [ "sign_float", - (function (param) { - return { - TAG: "Eq", - _0: -1, - _1: Math.sign(-4.2) - }; + param => ({ + TAG: "Eq", + _0: -1, + _1: Math.sign(-4.2) }) ], tl: { hd: [ "sign_float -0", - (function (param) { - return { - TAG: "Eq", - _0: -0, - _1: Math.sign(-0) - }; + param => ({ + TAG: "Eq", + _0: -0, + _1: Math.sign(-0) }) ], tl: { hd: [ "sin", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.389, - _2: Math.sin(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.389, + _2: Math.sin(0.4) }) ], tl: { hd: [ "sinh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.410, - _2: Math.sinh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.410, + _2: Math.sinh(0.4) }) ], tl: { hd: [ "sqrt", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.632, - _2: Math.sqrt(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.632, + _2: Math.sqrt(0.4) }) ], tl: { hd: [ "tan", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.422, - _2: Math.tan(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.422, + _2: Math.tan(0.4) }) ], tl: { hd: [ "tanh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.379, - _2: Math.tanh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.379, + _2: Math.tanh(0.4) }) ], tl: { hd: [ "unsafe_trunc", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.trunc(4.2156) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.trunc(4.2156) }) ], tl: { hd: [ "trunc", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.trunc(4.2156) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.trunc(4.2156) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_null_test.js b/jscomp/test/js_null_test.js index 1e3b56e403..abcceec261 100644 --- a/jscomp/test/js_null_test.js +++ b/jscomp/test/js_null_test.js @@ -7,139 +7,117 @@ let Caml_option = require("../../lib/js/caml_option.js"); let suites_0 = [ "toOption - empty", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ]; let suites_1 = { hd: [ "toOption - 'a", - (function (param) { - return { - TAG: "Eq", - _0: Caml_option.some(undefined), - _1: Caml_option.some() - }; + param => ({ + TAG: "Eq", + _0: Caml_option.some(undefined), + _1: Caml_option.some() }) ], tl: { hd: [ "return", - (function (param) { - return { - TAG: "Eq", - _0: "something", - _1: Caml_option.null_to_opt("something") - }; + param => ({ + TAG: "Eq", + _0: "something", + _1: Caml_option.null_to_opt("something") }) ], tl: { hd: [ "test - empty", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "test - 'a", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: false - }; + param => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "bind - empty", - (function (param) { - return { - TAG: "StrictEq", - _0: null, - _1: Js_null.bind(null, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: null, + _1: Js_null.bind(null, v => v) }) ], tl: { hd: [ "bind - 'a", - (function (param) { - return { - TAG: "StrictEq", - _0: 4, - _1: Js_null.bind(2, (function (n) { - return (n << 1); - })) - }; + param => ({ + TAG: "StrictEq", + _0: 4, + _1: Js_null.bind(2, n => (n << 1)) }) ], tl: { hd: [ "iter - empty", - (function (param) { + param => { let hit = { contents: false }; - Js_null.iter(null, (function (param) { + Js_null.iter(null, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - 'a", - (function (param) { + param => { let hit = { contents: 0 }; - Js_null.iter(2, (function (v) { + Js_null.iter(2, v => { hit.contents = v; - })); + }); return { TAG: "Eq", _0: 2, _1: hit.contents }; - }) + } ], tl: { hd: [ "fromOption - None", - (function (param) { - return { - TAG: "Eq", - _0: null, - _1: Js_null.fromOption(undefined) - }; + param => ({ + TAG: "Eq", + _0: null, + _1: Js_null.fromOption(undefined) }) ], tl: { hd: [ "fromOption - Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_null.fromOption(2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_null.fromOption(2) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_null_undefined_test.js b/jscomp/test/js_null_undefined_test.js index 74c496f7d8..b57628e898 100644 --- a/jscomp/test/js_null_undefined_test.js +++ b/jscomp/test/js_null_undefined_test.js @@ -7,283 +7,237 @@ let Js_null_undefined = require("../../lib/js/js_null_undefined.js"); let suites_0 = [ "toOption - null", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ]; let suites_1 = { hd: [ "toOption - undefined", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ], tl: { hd: [ "toOption - empty", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ], tl: { hd: [ "File \"js_null_undefined_test.res\", line 9, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: "foo", - _1: Caml_option.nullable_to_opt("foo") - }; + param => ({ + TAG: "Eq", + _0: "foo", + _1: Caml_option.nullable_to_opt("foo") }) ], tl: { hd: [ "return", - (function (param) { - return { - TAG: "Eq", - _0: "something", - _1: Caml_option.nullable_to_opt("something") - }; + param => ({ + TAG: "Eq", + _0: "something", + _1: Caml_option.nullable_to_opt("something") }) ], tl: { hd: [ "test - null", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "test - undefined", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "test - empty", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "File \"js_null_undefined_test.res\", line 14, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "bind - null", - (function (param) { - return { - TAG: "StrictEq", - _0: null, - _1: Js_null_undefined.bind(null, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: null, + _1: Js_null_undefined.bind(null, v => v) }) ], tl: { hd: [ "bind - undefined", - (function (param) { - return { - TAG: "StrictEq", - _0: undefined, - _1: Js_null_undefined.bind(undefined, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: undefined, + _1: Js_null_undefined.bind(undefined, v => v) }) ], tl: { hd: [ "bind - empty", - (function (param) { - return { - TAG: "StrictEq", - _0: undefined, - _1: Js_null_undefined.bind(undefined, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: undefined, + _1: Js_null_undefined.bind(undefined, v => v) }) ], tl: { hd: [ "bind - 'a", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Js_null_undefined.bind(2, (function (n) { - return (n << 1); - })) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_null_undefined.bind(2, n => (n << 1)) }) ], tl: { hd: [ "iter - null", - (function (param) { + param => { let hit = { contents: false }; - Js_null_undefined.iter(null, (function (param) { + Js_null_undefined.iter(null, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - undefined", - (function (param) { + param => { let hit = { contents: false }; - Js_null_undefined.iter(undefined, (function (param) { + Js_null_undefined.iter(undefined, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - empty", - (function (param) { + param => { let hit = { contents: false }; - Js_null_undefined.iter(undefined, (function (param) { + Js_null_undefined.iter(undefined, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - 'a", - (function (param) { + param => { let hit = { contents: 0 }; - Js_null_undefined.iter(2, (function (v) { + Js_null_undefined.iter(2, v => { hit.contents = v; - })); + }); return { TAG: "Eq", _0: 2, _1: hit.contents }; - }) + } ], tl: { hd: [ "fromOption - None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_null_undefined.fromOption(undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_null_undefined.fromOption(undefined) }) ], tl: { hd: [ "fromOption - Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_null_undefined.fromOption(2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_null_undefined.fromOption(2) }) ], tl: { hd: [ "null <> undefined", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: { hd: [ "null <> empty", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: { hd: [ "undefined = empty", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: { hd: [ "File \"js_null_undefined_test.res\", line 57, characters 6-13", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: /* [] */0 diff --git a/jscomp/test/js_nullable_test.js b/jscomp/test/js_nullable_test.js index ba64e5e938..15f396e862 100644 --- a/jscomp/test/js_nullable_test.js +++ b/jscomp/test/js_nullable_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/js_obj_test.js b/jscomp/test/js_obj_test.js index 8b535ae7a5..b39bb04e02 100644 --- a/jscomp/test/js_obj_test.js +++ b/jscomp/test/js_obj_test.js @@ -5,28 +5,24 @@ let Mt = require("./mt.js"); let suites_0 = [ "empty", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Object.keys({}).length - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Object.keys({}).length }) ]; let suites_1 = { hd: [ "assign", - (function (param) { - return { - TAG: "Eq", - _0: { - a: 1 - }, - _1: Object.assign({}, { - a: 1 - }) - }; + param => ({ + TAG: "Eq", + _0: { + a: 1 + }, + _1: Object.assign({}, { + a: 1 + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_option_test.js b/jscomp/test/js_option_test.js index 1159c4c2fd..c1052a0514 100644 --- a/jscomp/test/js_option_test.js +++ b/jscomp/test/js_option_test.js @@ -10,269 +10,209 @@ function simpleEq(a, b) { let option_suites_0 = [ "option_isSome_Some", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ]; let option_suites_1 = { hd: [ "option_isSome_None", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: false - }; + param => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "option_isNone_Some", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: false - }; + param => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "option_isNone_None", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "option_isSomeValue_Eq", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, 2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, 2) }) ], tl: { hd: [ "option_isSomeValue_Diff", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 1, 2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 1, 2) }) ], tl: { hd: [ "option_isSomeValue_DiffNone", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 1, undefined) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 1, undefined) }) ], tl: { hd: [ "option_getExn_Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_option.getExn(2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_option.getExn(2) }) ], tl: { hd: [ "option_equal_Eq", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.equal(simpleEq, 2, 2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.equal(simpleEq, 2, 2) }) ], tl: { hd: [ "option_equal_Diff", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.equal(simpleEq, 1, 2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.equal(simpleEq, 1, 2) }) ], tl: { hd: [ "option_equal_DiffNone", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.equal(simpleEq, 1, undefined) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.equal(simpleEq, 1, undefined) }) ], tl: { hd: [ "option_andThen_SomeSome", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen((function (a) { - return a + 1 | 0; - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(a => a + 1 | 0, 2)) }) ], tl: { hd: [ "option_andThen_SomeNone", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen((function (param) { - - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(param => {}, 2)) }) ], tl: { hd: [ "option_map_Some", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.map((function (a) { - return a + 1 | 0; - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.map(a => a + 1 | 0, 2)) }) ], tl: { hd: [ "option_map_None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.map((function (a) { - return a + 1 | 0; - }), undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.map(a => a + 1 | 0, undefined) }) ], tl: { hd: [ "option_default_Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_option.getWithDefault(3, 2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_option.getWithDefault(3, 2) }) ], tl: { hd: [ "option_default_None", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Js_option.getWithDefault(3, undefined) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Js_option.getWithDefault(3, undefined) }) ], tl: { hd: [ "option_filter_Pass", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, Js_option.filter((function (a) { - return a % 2 === 0; - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, Js_option.filter(a => a % 2 === 0, 2)) }) ], tl: { hd: [ "option_filter_Reject", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.filter((function (a) { - return a % 3 === 0; - }), 2) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.filter(a => a % 3 === 0, 2) }) ], tl: { hd: [ "option_filter_None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.filter((function (a) { - return a % 3 === 0; - }), undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.filter(a => a % 3 === 0, undefined) }) ], tl: { hd: [ "option_firstSome_First", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.firstSome(3, 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.firstSome(3, 2)) }) ], tl: { hd: [ "option_firstSome_First", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, Js_option.firstSome(undefined, 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, Js_option.firstSome(undefined, 2)) }) ], tl: { hd: [ "option_firstSome_None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.firstSome(undefined, undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.firstSome(undefined, undefined) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_re_test.js b/jscomp/test/js_re_test.js index 32dab9fbaf..2fdc4f2d08 100644 --- a/jscomp/test/js_re_test.js +++ b/jscomp/test/js_re_test.js @@ -7,7 +7,7 @@ let Caml_option = require("../../lib/js/caml_option.js"); let suites_0 = [ "captures", - (function (param) { + param => { let re = /(\d+)-(?:(\d+))?/g; let result = re.exec("3-"); if (result === null) { @@ -29,14 +29,14 @@ let suites_0 = [ $$undefined ] }; - }) + } ]; let suites_1 = { hd: [ "fromString", - (function (param) { - let contentOf = function (tag, xmlString) { + param => { + let contentOf = (tag, xmlString) => { let x = Caml_option.null_to_opt(new RegExp("<" + (tag + (">(.*?)<\\/" + (tag + ">")))).exec(xmlString)); if (x !== undefined) { return Caml_option.nullable_to_opt(Caml_array.get(Caml_option.valFromOption(x), 1)); @@ -48,12 +48,12 @@ let suites_1 = { _0: contentOf("div", "
Hi
"), _1: "Hi" }; - }) + } ], tl: { hd: [ "exec_literal", - (function (param) { + param => { let res = /[^.]+/.exec("http://xxx.domain.com"); if (res !== null) { return { @@ -67,12 +67,12 @@ let suites_1 = { _0: "regex should match" }; } - }) + } ], tl: { hd: [ "exec_no_match", - (function (param) { + param => { let match = /https:\/\/(.*)/.exec("http://xxx.domain.com"); if (match !== null) { return { @@ -85,36 +85,36 @@ let suites_1 = { _0: true }; } - }) + } ], tl: { hd: [ "test_str", - (function (param) { + param => { let res = new RegExp("foo").test("#foo#"); return { TAG: "Eq", _0: true, _1: res }; - }) + } ], tl: { hd: [ "fromStringWithFlags", - (function (param) { + param => { let res = new RegExp("foo", "g"); return { TAG: "Eq", _0: true, _1: res.global }; - }) + } ], tl: { hd: [ "result_index", - (function (param) { + param => { let res = new RegExp("zbar").exec("foobarbazbar"); if (res !== null) { return { @@ -128,12 +128,12 @@ let suites_1 = { _0: undefined }; } - }) + } ], tl: { hd: [ "result_input", - (function (param) { + param => { let input = "foobar"; let res = /foo/g.exec(input); if (res !== null) { @@ -148,45 +148,39 @@ let suites_1 = { _0: undefined }; } - }) + } ], tl: { hd: [ "t_flags", - (function (param) { - return { - TAG: "Eq", - _0: "gi", - _1: /./ig.flags - }; + param => ({ + TAG: "Eq", + _0: "gi", + _1: /./ig.flags }) ], tl: { hd: [ "t_global", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: /./ig.global - }; + param => ({ + TAG: "Eq", + _0: true, + _1: /./ig.global }) ], tl: { hd: [ "t_ignoreCase", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: /./ig.ignoreCase - }; + param => ({ + TAG: "Eq", + _0: true, + _1: /./ig.ignoreCase }) ], tl: { hd: [ "t_lastIndex", - (function (param) { + param => { let re = /na/g; re.exec("banana"); return { @@ -194,12 +188,12 @@ let suites_1 = { _0: 4, _1: re.lastIndex }; - }) + } ], tl: { hd: [ "t_setLastIndex", - (function (param) { + param => { let re = /na/g; let before = re.lastIndex; re.lastIndex = 42; @@ -215,50 +209,42 @@ let suites_1 = { after ] }; - }) + } ], tl: { hd: [ "t_multiline", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: /./ig.multiline - }; + param => ({ + TAG: "Eq", + _0: false, + _1: /./ig.multiline }) ], tl: { hd: [ "t_source", - (function (param) { - return { - TAG: "Eq", - _0: "f.+o", - _1: /f.+o/ig.source - }; + param => ({ + TAG: "Eq", + _0: "f.+o", + _1: /f.+o/ig.source }) ], tl: { hd: [ "t_sticky", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: /./yg.sticky - }; + param => ({ + TAG: "Eq", + _0: true, + _1: /./yg.sticky }) ], tl: { hd: [ "t_unicode", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: /./yg.unicode - }; + param => ({ + TAG: "Eq", + _0: false, + _1: /./yg.unicode }) ], tl: /* [] */0 diff --git a/jscomp/test/js_string_test.js b/jscomp/test/js_string_test.js index 5531abd586..47a498aede 100644 --- a/jscomp/test/js_string_test.js +++ b/jscomp/test/js_string_test.js @@ -7,347 +7,285 @@ let Caml_option = require("../../lib/js/caml_option.js"); let suites_0 = [ "make", - (function (param) { - return { - TAG: "Eq", - _0: "null", - _1: String(null).concat("") - }; + param => ({ + TAG: "Eq", + _0: "null", + _1: String(null).concat("") }) ]; let suites_1 = { hd: [ "fromCharCode", - (function (param) { - return { - TAG: "Eq", - _0: "a", - _1: String.fromCharCode(97) - }; + param => ({ + TAG: "Eq", + _0: "a", + _1: String.fromCharCode(97) }) ], tl: { hd: [ "fromCharCodeMany", - (function (param) { - return { - TAG: "Eq", - _0: "az", - _1: String.fromCharCode(97, 122) - }; + param => ({ + TAG: "Eq", + _0: "az", + _1: String.fromCharCode(97, 122) }) ], tl: { hd: [ "fromCodePoint", - (function (param) { - return { - TAG: "Eq", - _0: "a", - _1: String.fromCodePoint(97) - }; + param => ({ + TAG: "Eq", + _0: "a", + _1: String.fromCodePoint(97) }) ], tl: { hd: [ "fromCodePointMany", - (function (param) { - return { - TAG: "Eq", - _0: "az", - _1: String.fromCodePoint(97, 122) - }; + param => ({ + TAG: "Eq", + _0: "az", + _1: String.fromCodePoint(97, 122) }) ], tl: { hd: [ "length", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: "foo".length - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: "foo".length }) ], tl: { hd: [ "get", - (function (param) { - return { - TAG: "Eq", - _0: "a", - _1: "foobar"[4] - }; + param => ({ + TAG: "Eq", + _0: "a", + _1: "foobar"[4] }) ], tl: { hd: [ "charAt", - (function (param) { - return { - TAG: "Eq", - _0: "a", - _1: "foobar".charAt(4) - }; + param => ({ + TAG: "Eq", + _0: "a", + _1: "foobar".charAt(4) }) ], tl: { hd: [ "charCodeAt", - (function (param) { - return { - TAG: "Eq", - _0: 97, - _1: "foobar".charCodeAt(4) - }; + param => ({ + TAG: "Eq", + _0: 97, + _1: "foobar".charCodeAt(4) }) ], tl: { hd: [ "codePointAt", - (function (param) { - return { - TAG: "Eq", - _0: 97, - _1: "foobar".codePointAt(4) - }; + param => ({ + TAG: "Eq", + _0: 97, + _1: "foobar".codePointAt(4) }) ], tl: { hd: [ "codePointAt - out of bounds", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: "foobar".codePointAt(98) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: "foobar".codePointAt(98) }) ], tl: { hd: [ "concat", - (function (param) { - return { - TAG: "Eq", - _0: "foobar", - _1: "foo".concat("bar") - }; + param => ({ + TAG: "Eq", + _0: "foobar", + _1: "foo".concat("bar") }) ], tl: { hd: [ "concatMany", - (function (param) { - return { - TAG: "Eq", - _0: "foobarbaz", - _1: "foo".concat("bar", "baz") - }; + param => ({ + TAG: "Eq", + _0: "foobarbaz", + _1: "foo".concat("bar", "baz") }) ], tl: { hd: [ "endsWith", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: "foobar".endsWith("bar") - }; + param => ({ + TAG: "Eq", + _0: true, + _1: "foobar".endsWith("bar") }) ], tl: { hd: [ "endsWithFrom", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: "foobar".endsWith("bar", 1) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: "foobar".endsWith("bar", 1) }) ], tl: { hd: [ "includes", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: "foobarbaz".includes("bar") - }; + param => ({ + TAG: "Eq", + _0: true, + _1: "foobarbaz".includes("bar") }) ], tl: { hd: [ "includesFrom", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: "foobarbaz".includes("bar", 4) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: "foobarbaz".includes("bar", 4) }) ], tl: { hd: [ "indexOf", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: "foobarbaz".indexOf("bar") - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".indexOf("bar") }) ], tl: { hd: [ "indexOfFrom", - (function (param) { - return { - TAG: "Eq", - _0: -1, - _1: "foobarbaz".indexOf("bar", 4) - }; + param => ({ + TAG: "Eq", + _0: -1, + _1: "foobarbaz".indexOf("bar", 4) }) ], tl: { hd: [ "lastIndexOf", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: "foobarbaz".lastIndexOf("bar") - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".lastIndexOf("bar") }) ], tl: { hd: [ "lastIndexOfFrom", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: "foobarbaz".lastIndexOf("bar", 4) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".lastIndexOf("bar", 4) }) ], tl: { hd: [ "localeCompare", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: "foo".localeCompare("foo") - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: "foo".localeCompare("foo") }) ], tl: { hd: [ "match", - (function (param) { - return { - TAG: "Eq", - _0: [ - "na", - "na" - ], - _1: Caml_option.null_to_opt("banana".match(/na+/g)) - }; + param => ({ + TAG: "Eq", + _0: [ + "na", + "na" + ], + _1: Caml_option.null_to_opt("banana".match(/na+/g)) }) ], tl: { hd: [ "match - no match", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Caml_option.null_to_opt("banana".match(/nanana+/g)) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Caml_option.null_to_opt("banana".match(/nanana+/g)) }) ], tl: { hd: [ "match - not found capture groups", - (function (param) { - return { - TAG: "Eq", - _0: [ - "hello ", - undefined - ], - _1: Belt_Option.map(Caml_option.null_to_opt("hello word".match(/hello (world)?/)), (function (prim) { - return prim.slice(); - })) - }; + param => ({ + TAG: "Eq", + _0: [ + "hello ", + undefined + ], + _1: Belt_Option.map(Caml_option.null_to_opt("hello word".match(/hello (world)?/)), prim => prim.slice()) }) ], tl: { hd: [ "normalize", - (function (param) { - return { - TAG: "Eq", - _0: "foo", - _1: "foo".normalize() - }; + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".normalize() }) ], tl: { hd: [ "normalizeByForm", - (function (param) { - return { - TAG: "Eq", - _0: "foo", - _1: "foo".normalize("NFKD") - }; + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".normalize("NFKD") }) ], tl: { hd: [ "repeat", - (function (param) { - return { - TAG: "Eq", - _0: "foofoofoo", - _1: "foo".repeat(3) - }; + param => ({ + TAG: "Eq", + _0: "foofoofoo", + _1: "foo".repeat(3) }) ], tl: { hd: [ "replace", - (function (param) { - return { - TAG: "Eq", - _0: "fooBORKbaz", - _1: "foobarbaz".replace("bar", "BORK") - }; + param => ({ + TAG: "Eq", + _0: "fooBORKbaz", + _1: "foobarbaz".replace("bar", "BORK") }) ], tl: { hd: [ "replaceByRe", - (function (param) { - return { - TAG: "Eq", - _0: "fooBORKBORK", - _1: "foobarbaz".replace(/ba./g, "BORK") - }; + param => ({ + TAG: "Eq", + _0: "fooBORKBORK", + _1: "foobarbaz".replace(/ba./g, "BORK") }) ], tl: { hd: [ "unsafeReplaceBy0", - (function (param) { - let replace = function (whole, offset, s) { + param => { + let replace = (whole, offset, s) => { if (whole === "bar") { return "BORK"; } else { @@ -359,13 +297,13 @@ let suites_1 = { _0: "fooBORKDORK", _1: "foobarbaz".replace(/ba./g, replace) }; - }) + } ], tl: { hd: [ "unsafeReplaceBy1", - (function (param) { - let replace = function (whole, p1, offset, s) { + param => { + let replace = (whole, p1, offset, s) => { if (whole === "bar") { return "BORK"; } else { @@ -377,13 +315,13 @@ let suites_1 = { _0: "fooBORKDORK", _1: "foobarbaz".replace(/ba./g, replace) }; - }) + } ], tl: { hd: [ "unsafeReplaceBy2", - (function (param) { - let replace = function (whole, p1, p2, offset, s) { + param => { + let replace = (whole, p1, p2, offset, s) => { if (whole === "bar") { return "BORK"; } else { @@ -395,13 +333,13 @@ let suites_1 = { _0: "fooBORKDORK", _1: "foobarbaz".replace(/ba./g, replace) }; - }) + } ], tl: { hd: [ "unsafeReplaceBy3", - (function (param) { - let replace = function (whole, p1, p2, p3, offset, s) { + param => { + let replace = (whole, p1, p2, p3, offset, s) => { if (whole === "bar") { return "BORK"; } else { @@ -413,255 +351,213 @@ let suites_1 = { _0: "fooBORKDORK", _1: "foobarbaz".replace(/ba./g, replace) }; - }) + } ], tl: { hd: [ "search", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: "foobarbaz".search(/ba./g) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: "foobarbaz".search(/ba./g) }) ], tl: { hd: [ "slice", - (function (param) { - return { - TAG: "Eq", - _0: "bar", - _1: "foobarbaz".slice(3, 6) - }; + param => ({ + TAG: "Eq", + _0: "bar", + _1: "foobarbaz".slice(3, 6) }) ], tl: { hd: [ "sliceToEnd", - (function (param) { - return { - TAG: "Eq", - _0: "barbaz", - _1: "foobarbaz".slice(3) - }; + param => ({ + TAG: "Eq", + _0: "barbaz", + _1: "foobarbaz".slice(3) }) ], tl: { hd: [ "split", - (function (param) { - return { - TAG: "Eq", - _0: [ - "foo", - "bar", - "baz" - ], - _1: "foo bar baz".split(" ") - }; + param => ({ + TAG: "Eq", + _0: [ + "foo", + "bar", + "baz" + ], + _1: "foo bar baz".split(" ") }) ], tl: { hd: [ "splitAtMost", - (function (param) { - return { - TAG: "Eq", - _0: [ - "foo", - "bar" - ], - _1: "foo bar baz".split(" ", 2) - }; + param => ({ + TAG: "Eq", + _0: [ + "foo", + "bar" + ], + _1: "foo bar baz".split(" ", 2) }) ], tl: { hd: [ "splitByRe", - (function (param) { - return { - TAG: "Eq", - _0: [ - "a", - "#", - undefined, - "b", - "#", - ":", - "c" - ], - _1: "a#b#:c".split(/(#)(:)?/) - }; + param => ({ + TAG: "Eq", + _0: [ + "a", + "#", + undefined, + "b", + "#", + ":", + "c" + ], + _1: "a#b#:c".split(/(#)(:)?/) }) ], tl: { hd: [ "splitByReAtMost", - (function (param) { - return { - TAG: "Eq", - _0: [ - "a", - "#", - undefined - ], - _1: "a#b#:c".split(/(#)(:)?/, 3) - }; + param => ({ + TAG: "Eq", + _0: [ + "a", + "#", + undefined + ], + _1: "a#b#:c".split(/(#)(:)?/, 3) }) ], tl: { hd: [ "startsWith", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: "foobarbaz".startsWith("foo") - }; + param => ({ + TAG: "Eq", + _0: true, + _1: "foobarbaz".startsWith("foo") }) ], tl: { hd: [ "startsWithFrom", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: "foobarbaz".startsWith("foo", 1) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: "foobarbaz".startsWith("foo", 1) }) ], tl: { hd: [ "substr", - (function (param) { - return { - TAG: "Eq", - _0: "barbaz", - _1: "foobarbaz".substr(3) - }; + param => ({ + TAG: "Eq", + _0: "barbaz", + _1: "foobarbaz".substr(3) }) ], tl: { hd: [ "substrAtMost", - (function (param) { - return { - TAG: "Eq", - _0: "bar", - _1: "foobarbaz".substr(3, 3) - }; + param => ({ + TAG: "Eq", + _0: "bar", + _1: "foobarbaz".substr(3, 3) }) ], tl: { hd: [ "substring", - (function (param) { - return { - TAG: "Eq", - _0: "bar", - _1: "foobarbaz".substring(3, 6) - }; + param => ({ + TAG: "Eq", + _0: "bar", + _1: "foobarbaz".substring(3, 6) }) ], tl: { hd: [ "substringToEnd", - (function (param) { - return { - TAG: "Eq", - _0: "barbaz", - _1: "foobarbaz".substring(3) - }; + param => ({ + TAG: "Eq", + _0: "barbaz", + _1: "foobarbaz".substring(3) }) ], tl: { hd: [ "toLowerCase", - (function (param) { - return { - TAG: "Eq", - _0: "bork", - _1: "BORK".toLowerCase() - }; + param => ({ + TAG: "Eq", + _0: "bork", + _1: "BORK".toLowerCase() }) ], tl: { hd: [ "toLocaleLowerCase", - (function (param) { - return { - TAG: "Eq", - _0: "bork", - _1: "BORK".toLocaleLowerCase() - }; + param => ({ + TAG: "Eq", + _0: "bork", + _1: "BORK".toLocaleLowerCase() }) ], tl: { hd: [ "toUpperCase", - (function (param) { - return { - TAG: "Eq", - _0: "FUBAR", - _1: "fubar".toUpperCase() - }; + param => ({ + TAG: "Eq", + _0: "FUBAR", + _1: "fubar".toUpperCase() }) ], tl: { hd: [ "toLocaleUpperCase", - (function (param) { - return { - TAG: "Eq", - _0: "FUBAR", - _1: "fubar".toLocaleUpperCase() - }; + param => ({ + TAG: "Eq", + _0: "FUBAR", + _1: "fubar".toLocaleUpperCase() }) ], tl: { hd: [ "trim", - (function (param) { - return { - TAG: "Eq", - _0: "foo", - _1: " foo ".trim() - }; + param => ({ + TAG: "Eq", + _0: "foo", + _1: " foo ".trim() }) ], tl: { hd: [ "anchor", - (function (param) { - return { - TAG: "Eq", - _0: "foo", - _1: "foo".anchor("bar") - }; + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".anchor("bar") }) ], tl: { hd: [ "link", - (function (param) { - return { - TAG: "Eq", - _0: "foo", - _1: "foo".link("https://reason.ml") - }; + param => ({ + TAG: "Eq", + _0: "foo", + _1: "foo".link("https://reason.ml") }) ], tl: { hd: [ "File \"js_string_test.res\", line 138, characters 5-12", - (function (param) { - return { - TAG: "Ok", - _0: "ab".includes("a") - }; + param => ({ + TAG: "Ok", + _0: "ab".includes("a") }) ], tl: /* [] */0 diff --git a/jscomp/test/js_undefined_test.js b/jscomp/test/js_undefined_test.js index 317c5604b6..9f424779e2 100644 --- a/jscomp/test/js_undefined_test.js +++ b/jscomp/test/js_undefined_test.js @@ -7,139 +7,117 @@ let Js_undefined = require("../../lib/js/js_undefined.js"); let suites_0 = [ "toOption - empty", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ]; let suites_1 = { hd: [ "File \"js_undefined_test.res\", line 7, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ], tl: { hd: [ "return", - (function (param) { - return { - TAG: "Eq", - _0: "something", - _1: Caml_option.undefined_to_opt("something") - }; + param => ({ + TAG: "Eq", + _0: "something", + _1: Caml_option.undefined_to_opt("something") }) ], tl: { hd: [ "test - empty", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "File \"js_undefined_test.res\", line 10, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "bind - empty", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_undefined.bind(undefined, (function (v) { - return v; - })) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_undefined.bind(undefined, v => v) }) ], tl: { hd: [ "bind - 'a", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Js_undefined.bind(2, (function (n) { - return (n << 1); - })) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_undefined.bind(2, n => (n << 1)) }) ], tl: { hd: [ "iter - empty", - (function (param) { + param => { let hit = { contents: false }; - Js_undefined.iter(undefined, (function (param) { + Js_undefined.iter(undefined, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - 'a", - (function (param) { + param => { let hit = { contents: 0 }; - Js_undefined.iter(2, (function (v) { + Js_undefined.iter(2, v => { hit.contents = v; - })); + }); return { TAG: "Eq", _0: 2, _1: hit.contents }; - }) + } ], tl: { hd: [ "fromOption - None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_undefined.fromOption(undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_undefined.fromOption(undefined) }) ], tl: { hd: [ "fromOption - Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_undefined.fromOption(2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_undefined.fromOption(2) }) ], tl: /* [] */0 diff --git a/jscomp/test/jsoo_400_test.js b/jscomp/test/jsoo_400_test.js index 378d6d338c..12c78d9f5e 100644 --- a/jscomp/test/jsoo_400_test.js +++ b/jscomp/test/jsoo_400_test.js @@ -17,13 +17,11 @@ function u() { Mt.from_pair_suites("Jsoo_400_test", { hd: [ "File \"jsoo_400_test.res\", line 7, characters 38-45", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - u(); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + u(); + } }) ], tl: /* [] */0 diff --git a/jscomp/test/key_word_property_plus_test.js b/jscomp/test/key_word_property_plus_test.js index e8ab212a11..db5fb4114d 100644 --- a/jscomp/test/key_word_property_plus_test.js +++ b/jscomp/test/key_word_property_plus_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -34,9 +32,7 @@ eq("File \"key_word_property_plus_test.res\", line 10, characters 2-9", [ 2, 3, 4 -].reduce((function (prim0, prim1) { - return prim0 + prim1 | 0; -}), 0), ((Global_mangles.$$__dirname + Global_mangles.$$__filename | 0) + Global_mangles.$$exports | 0) + Global_mangles.$$require | 0); +].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), ((Global_mangles.$$__dirname + Global_mangles.$$__filename | 0) + Global_mangles.$$exports | 0) + Global_mangles.$$require | 0); Mt.from_pair_suites("Key_word_property_plus_test", suites.contents); diff --git a/jscomp/test/lazy_demo.js b/jscomp/test/lazy_demo.js index 1d4fa28466..03915b1d78 100644 --- a/jscomp/test/lazy_demo.js +++ b/jscomp/test/lazy_demo.js @@ -3,14 +3,12 @@ let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); -let lazy1 = CamlinternalLazy.from_fun(function () { +let lazy1 = CamlinternalLazy.from_fun(() => { console.log("Hello, lazy"); return 1; }); -let lazy2 = CamlinternalLazy.from_fun(function () { - return 3; -}); +let lazy2 = CamlinternalLazy.from_fun(() => 3); console.log(lazy1, lazy2); diff --git a/jscomp/test/lazy_test.js b/jscomp/test/lazy_test.js index 7d56dbcdeb..9e6b8ca8fe 100644 --- a/jscomp/test/lazy_test.js +++ b/jscomp/test/lazy_test.js @@ -9,7 +9,7 @@ let u = { contents: 3 }; -let v = CamlinternalLazy.from_fun(function () { +let v = CamlinternalLazy.from_fun(() => { u.contents = 32; }); @@ -27,7 +27,7 @@ let u_v = { contents: 0 }; -let u$1 = CamlinternalLazy.from_fun(function () { +let u$1 = CamlinternalLazy.from_fun(() => { u_v.contents = 2; }); @@ -35,9 +35,7 @@ CamlinternalLazy.force(u$1); let exotic = CamlinternalLazy.force; -let l_from_fun = CamlinternalLazy.from_fun(function () { - return 3; -}); +let l_from_fun = CamlinternalLazy.from_fun(() => 3); function f() { let u = 3; @@ -45,21 +43,13 @@ function f() { return u; } -let forward_test = CamlinternalLazy.from_fun(function () { - return f(); -}); +let forward_test = CamlinternalLazy.from_fun(() => f()); -let f005 = CamlinternalLazy.from_fun(function () { - return 6; -}); +let f005 = CamlinternalLazy.from_fun(() => 6); -let f006 = CamlinternalLazy.from_fun(function () { - return function () { - return 3; - }; -}); +let f006 = CamlinternalLazy.from_fun(() => (() => 3)); -let f007 = CamlinternalLazy.from_fun(function () { +let f007 = CamlinternalLazy.from_fun(() => { throw new Error("Not_found", { cause: { RE_EXN_ID: "Not_found" @@ -76,9 +66,7 @@ function f$1() { }); } -let f008 = CamlinternalLazy.from_fun(function () { - return f$1(); -}); +let f008 = CamlinternalLazy.from_fun(() => f$1()); let a2 = CamlinternalLazy.from_val; @@ -97,132 +85,110 @@ let a8 = CamlinternalLazy.force(a6); Mt.from_pair_suites("Lazy_test", { hd: [ "simple", - (function () { - return { - TAG: "Eq", - _0: lazy_test(), - _1: [ - 3, - 32 - ] - }; + () => ({ + TAG: "Eq", + _0: lazy_test(), + _1: [ + 3, + 32 + ] }) ], tl: { hd: [ "lazy_force", - (function () { - return { - TAG: "Eq", - _0: u_v.contents, - _1: 2 - }; + () => ({ + TAG: "Eq", + _0: u_v.contents, + _1: 2 }) ], tl: { hd: [ "lazy_from_fun", - (function () { - return { - TAG: "Eq", - _0: CamlinternalLazy.force(l_from_fun), - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: CamlinternalLazy.force(l_from_fun), + _1: 3 }) ], tl: { hd: [ "lazy_from_val", - (function () { - return { - TAG: "Eq", - _0: CamlinternalLazy.force(CamlinternalLazy.from_val(3)), - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: CamlinternalLazy.force(CamlinternalLazy.from_val(3)), + _1: 3 }) ], tl: { hd: [ "lazy_from_val2", - (function () { - return { - TAG: "Eq", - _0: CamlinternalLazy.force(CamlinternalLazy.force(CamlinternalLazy.from_val(CamlinternalLazy.from_fun(function () { - return 3; - })))), - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: CamlinternalLazy.force(CamlinternalLazy.force(CamlinternalLazy.from_val(CamlinternalLazy.from_fun(() => 3)))), + _1: 3 }) ], tl: { hd: [ "lazy_from_val3", - (function () { + () => { debugger; return { TAG: "Eq", _0: CamlinternalLazy.force(CamlinternalLazy.force(CamlinternalLazy.from_val(forward_test))), _1: 4 }; - }) + } ], tl: { hd: [ "lazy_test.res", - (function () { - return { - TAG: "Eq", - _0: a3, - _1: a4 - }; + () => ({ + TAG: "Eq", + _0: a3, + _1: a4 }) ], tl: { hd: [ "lazy_test.res", - (function () { - return { - TAG: "Eq", - _0: a7, - _1: undefined - }; + () => ({ + TAG: "Eq", + _0: a7, + _1: undefined }) ], tl: { hd: [ "lazy_test.res", - (function () { - return { - TAG: "Eq", - _0: a8, - _1: undefined - }; + () => ({ + TAG: "Eq", + _0: a8, + _1: undefined }) ], tl: { hd: [ "File \"lazy_test.res\", line 95, characters 7-14", - (function () { - return { - TAG: "Ok", - _0: Lazy.is_val(CamlinternalLazy.from_val(3)) - }; + () => ({ + TAG: "Ok", + _0: Lazy.is_val(CamlinternalLazy.from_val(3)) }) ], tl: { hd: [ "File \"lazy_test.res\", line 96, characters 7-14", - (function () { - return { - TAG: "Ok", - _0: !Lazy.is_val(CamlinternalLazy.from_fun(function () { - throw new Error("Not_found", { - cause: { - RE_EXN_ID: "Not_found" - } - }); - })) - }; + () => ({ + TAG: "Ok", + _0: !Lazy.is_val(CamlinternalLazy.from_fun(() => { + throw new Error("Not_found", { + cause: { + RE_EXN_ID: "Not_found" + } + }); + })) }) ], tl: /* [] */0 diff --git a/jscomp/test/lib_js_test.js b/jscomp/test/lib_js_test.js index b392b3d7c4..58a10c1f40 100644 --- a/jscomp/test/lib_js_test.js +++ b/jscomp/test/lib_js_test.js @@ -18,12 +18,10 @@ console.log("hey"); let suites_0 = [ "anything_to_string", - (function (param) { - return { - TAG: "Eq", - _0: "3", - _1: String(3) - }; + param => ({ + TAG: "Eq", + _0: "3", + _1: String(3) }) ]; diff --git a/jscomp/test/libarg_test.js b/jscomp/test/libarg_test.js index 9a26d50250..42a1457b86 100644 --- a/jscomp/test/libarg_test.js +++ b/jscomp/test/libarg_test.js @@ -365,7 +365,7 @@ function test(argv) { } }; if (Caml_obj.notequal(result, reference)) { - let f = function (x, y) { + let f = (x, y) => { console.log(x, y); }; List.iter2(f, result, reference); diff --git a/jscomp/test/libqueue_test.js b/jscomp/test/libqueue_test.js index d3db327772..693731383c 100644 --- a/jscomp/test/libqueue_test.js +++ b/jscomp/test/libqueue_test.js @@ -7,11 +7,9 @@ let Caml_obj = require("../../lib/js/caml_obj.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); function to_list(q) { - return List.rev(Queue.fold((function (l, x) { - return { - hd: x, - tl: l - }; + return List.rev(Queue.fold((l, x) => ({ + hd: x, + tl: l }), /* [] */0, q)); } @@ -865,7 +863,7 @@ let i$7 = { contents: 1 }; -Queue.iter((function (j) { +Queue.iter(j => { if (i$7.contents !== j) { throw new Error("Assert_failure", { cause: { @@ -879,7 +877,7 @@ Queue.iter((function (j) { }); } i$7.contents = i$7.contents + 1 | 0; -}), q$5); +}, q$5); let q1$1 = { length: 0, diff --git a/jscomp/test/limits_test.js b/jscomp/test/limits_test.js index bdf6c1e70d..f760da7ef1 100644 --- a/jscomp/test/limits_test.js +++ b/jscomp/test/limits_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/list_stack.js b/jscomp/test/list_stack.js index 33c026664a..23e5faacef 100644 --- a/jscomp/test/list_stack.js +++ b/jscomp/test/list_stack.js @@ -3,8 +3,6 @@ let List = require("../../lib/js/list.js"); -List.find((function (x) { - return x > 3; -}), /* [] */0); +List.find(x => x > 3, /* [] */0); /* Not a pure module */ diff --git a/jscomp/test/list_test.js b/jscomp/test/list_test.js index fb69b118b6..ac05021476 100644 --- a/jscomp/test/list_test.js +++ b/jscomp/test/list_test.js @@ -8,106 +8,113 @@ let $$Array = require("../../lib/js/array.js"); let list_suites_0 = [ "length", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: List.length({ - hd: [ - 0, - 1, - 2, - 3, - 4 - ], - tl: /* [] */0 - }) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: List.length({ + hd: [ + 0, + 1, + 2, + 3, + 4 + ], + tl: /* [] */0 + }) }) ]; let list_suites_1 = { hd: [ "length2", - (function (param) { - return { - TAG: "Eq", - _0: 5, - _1: List.length({ - hd: 0, + param => ({ + TAG: "Eq", + _0: 5, + _1: List.length({ + hd: 0, + tl: { + hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 3, tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } + hd: 4, + tl: /* [] */0 } } } - }) - }; + } + }) }) ], tl: { hd: [ "long_length", - (function (param) { - return { - TAG: "Eq", - _0: 30000, - _1: List.length($$Array.to_list($$Array.init(30000, (function (param) { - return 0; - })))) - }; + param => ({ + TAG: "Eq", + _0: 30000, + _1: List.length($$Array.to_list($$Array.init(30000, param => 0))) }) ], tl: { hd: [ "sort", - (function (param) { - return { - TAG: "Eq", - _0: List.sort(Caml.int_compare, { - hd: 4, + param => ({ + TAG: "Eq", + _0: List.sort(Caml.int_compare, { + hd: 4, + tl: { + hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } + hd: 3, + tl: /* [] */0 } } - }), - _1: { - hd: 1, + } + }), + _1: { + hd: 1, + tl: { + hd: 2, tl: { - hd: 2, + hd: 3, tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } + hd: 4, + tl: /* [] */0 } } } - }; + } }) ], tl: { hd: [ "File \"list_test.res\", line 20, characters 5-12", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: true, + _1: List.mem(3, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }) + }) + ], + tl: { + hd: [ + "File \"list_test.res\", line 21, characters 5-12", + param => ({ TAG: "Eq", - _0: true, - _1: List.mem(3, { + _0: false, + _1: List.mem(4, { hd: 1, tl: { hd: 2, @@ -117,50 +124,27 @@ let list_suites_1 = { } } }) - }; - }) - ], - tl: { - hd: [ - "File \"list_test.res\", line 21, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: List.mem(4, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }) - }; }) ], tl: { hd: [ "File \"list_test.res\", line 22, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: 9, - _1: List.assoc(4, { + param => ({ + TAG: "Eq", + _0: 9, + _1: List.assoc(4, { + hd: [ + 1, + 2 + ], + tl: { hd: [ - 1, - 2 + 4, + 9 ], - tl: { - hd: [ - 4, - 9 - ], - tl: /* [] */0 - } - }) - }; + tl: /* [] */0 + } + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/loop_regression_test.js b/jscomp/test/loop_regression_test.js index a539680a85..af40ea6875 100644 --- a/jscomp/test/loop_regression_test.js +++ b/jscomp/test/loop_regression_test.js @@ -23,12 +23,10 @@ function f() { let suites_0 = [ "sum", - (function (param) { - return { - TAG: "Eq", - _0: 55, - _1: f() - }; + param => ({ + TAG: "Eq", + _0: 55, + _1: f() }) ]; diff --git a/jscomp/test/map_find_test.js b/jscomp/test/map_find_test.js index c070c6c521..fd645f38c2 100644 --- a/jscomp/test/map_find_test.js +++ b/jscomp/test/map_find_test.js @@ -158,9 +158,7 @@ function find(x, _param) { }; } -let m = List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +let m = List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 @@ -339,9 +337,7 @@ function find$1(x, _param) { }; } -let s = List.fold_left((function (acc, param) { - return add$1(param[0], param[1], acc); -}), "Empty", { +let s = List.fold_left((acc, param) => add$1(param[0], param[1], acc), "Empty", { hd: [ "10", /* 'a' */97 @@ -370,23 +366,19 @@ let s = List.fold_left((function (acc, param) { Mt.from_pair_suites("Map_find_test", { hd: [ "int", - (function () { - return { - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 }) ], tl: { hd: [ "string", - (function () { - return { - TAG: "Eq", - _0: find$1("10", s), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find$1("10", s), + _1: /* 'a' */97 }) ], tl: /* [] */0 diff --git a/jscomp/test/map_test.js b/jscomp/test/map_test.js index defd198b77..bd37173302 100644 --- a/jscomp/test/map_test.js +++ b/jscomp/test/map_test.js @@ -2001,14 +2001,12 @@ let String_map = { }; function of_list(kvs) { - return List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); - }), "Empty", kvs); + return List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", kvs); } let int_map_suites_0 = [ "add", - (function (param) { + param => { let v = of_list({ hd: [ 1, @@ -2033,13 +2031,13 @@ let int_map_suites_0 = [ _0: cardinal(v), _1: 3 }; - }) + } ]; let int_map_suites_1 = { hd: [ "equal", - (function (param) { + param => { let v = of_list({ hd: [ 1, @@ -2083,12 +2081,12 @@ let int_map_suites_1 = { _0: compare$1(Caml.int_compare, u, v), _1: 0 }; - }) + } ], tl: { hd: [ "equal2", - (function (param) { + param => { let v = of_list({ hd: [ 1, @@ -2130,16 +2128,14 @@ let int_map_suites_1 = { return { TAG: "Eq", _0: true, - _1: equal((function (x, y) { - return x === y; - }), u, v) + _1: equal((x, y) => x === y, u, v) }; - }) + } ], tl: { hd: [ "iteration", - (function (param) { + param => { let m = "Empty"; for (let i = 0; i <= 10000; ++i) { m = add$1(String(i), String(i), m); @@ -2156,7 +2152,7 @@ let int_map_suites_1 = { _0: v, _1: -1 }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index 38059f9871..f1dc0788a9 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -948,7 +948,7 @@ function update_player(player, keys, context) { let prev_jumping = player.jumping; let prev_dir = player.dir; let prev_vx = Math.abs(player.vel.x); - List.iter((function (extra) { + List.iter(extra => { let lr_acc = player.vel.x * 0.2; switch (extra) { case "CLeft" : @@ -988,7 +988,7 @@ function update_player(player, keys, context) { return; } } - }), keys); + }, keys); let v = player.vel.x * 0.9; let vel_damped = Math.abs(v) < 0.1 ? 0 : v; player.vel.x = vel_damped; @@ -2085,13 +2085,13 @@ function process_collision(dir, c1, c2, state) { function broad_phase(collid, all_collids, state) { let obj = collid._2; - return List.filter((function (c) { + return List.filter(c => { if (in_viewport(state.vpt, obj.pos) || is_player(collid)) { return true; } else { return out_of_viewport_below(state.vpt, obj.pos.y); } - }), all_collids); + }, all_collids); } function check_collisions(collid, all_collids, state) { @@ -2205,7 +2205,7 @@ function translate_keys() { hd: ctrls_0, tl: ctrls_1 }; - return List.fold_left((function (a, x) { + return List.fold_left((a, x) => { if (x[0]) { return { hd: x[1], @@ -2214,7 +2214,7 @@ function translate_keys() { } else { return a; } - }), /* [] */0, ctrls); + }, /* [] */0, ctrls); } function run_update_collid(state, collid, all_collids) { @@ -2273,7 +2273,7 @@ function update_loop(canvas, param, map_dim) { game_over: false }; state.ctx.scale(1, 1); - let update_helper = function (time, state, player, objs, parts) { + let update_helper = (time, state, player, objs, parts) => { if (state.game_over === true) { return game_win(state.ctx); } @@ -2299,10 +2299,10 @@ function update_loop(canvas, param, map_dim) { multiplier: state.multiplier, game_over: state.game_over }; - List.iter((function (obj) { + List.iter(obj => { run_update_collid(state$1, obj, objs); - }), objs); - List.iter((function (part) { + }, objs); + List.iter(part => { process(part); let x = part.pos.x - state$1.vpt.pos.x; let y = part.pos.y - state$1.vpt.pos.y; @@ -2318,12 +2318,10 @@ function update_loop(canvas, param, map_dim) { return; } - }), parts); + }, parts); fps(canvas, fps$1); hud(canvas, state$1.score, state$1.coins); - requestAnimationFrame(function (t) { - update_helper(t, state$1, player$1, collid_objs.contents, particles.contents); - }); + requestAnimationFrame(t => update_helper(t, state$1, player$1, collid_objs.contents, particles.contents)); }; update_helper(0, state, player, param[1], /* [] */0); } @@ -3308,15 +3306,15 @@ function inc_counter(param) { } function preload(param) { - return List.map((function (img_src) { + return List.map(img_src => { let img_src$1 = "sprites/" + img_src; let img = document.createElement("img"); img.src = img_src$1; - img.addEventListener("load", (function (ev) { + img.addEventListener("load", ev => { inc_counter(); return true; - }), true); - }), { + }, true); + }, { hd: "blocks.png", tl: { hd: "items.png", @@ -3331,10 +3329,10 @@ function preload(param) { }); } -window.onload = (function (param) { +window.onload = param => { preload(); return true; -}); +}; let Main = { Html: undefined, diff --git a/jscomp/test/method_name_test.js b/jscomp/test/method_name_test.js index 3c0e9a5a9d..16e1e0db93 100644 --- a/jscomp/test/method_name_test.js +++ b/jscomp/test/method_name_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/mock_mt.js b/jscomp/test/mock_mt.js index e2d271f81b..0858be78e9 100644 --- a/jscomp/test/mock_mt.js +++ b/jscomp/test/mock_mt.js @@ -8,7 +8,7 @@ function from_pair_suites(name, suites) { name, "testing" ]); - List.iter((function (param) { + List.iter(param => { let name = param[0]; let fn = param[1](); switch (fn.TAG) { @@ -79,7 +79,7 @@ function from_pair_suites(name, suites) { console.log("failed: " + fn._0); return; } - }), suites); + }, suites); } exports.from_pair_suites = from_pair_suites; diff --git a/jscomp/test/module_alias_test.js b/jscomp/test/module_alias_test.js index ad1d061bc7..c65e0a81c6 100644 --- a/jscomp/test/module_alias_test.js +++ b/jscomp/test/module_alias_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/module_parameter_test.js b/jscomp/test/module_parameter_test.js index d4d7c5e122..aaab7e92b9 100644 --- a/jscomp/test/module_parameter_test.js +++ b/jscomp/test/module_parameter_test.js @@ -22,24 +22,20 @@ function v(x) { let suites_0 = [ "const", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: v0 - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: v0 }) ]; let suites_1 = { hd: [ "other", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: v("abc") - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: v("abc") }) ], tl: /* [] */0 diff --git a/jscomp/test/module_splice_test.js b/jscomp/test/module_splice_test.js index 1aafc543dc..2472d3f58b 100644 --- a/jscomp/test/module_splice_test.js +++ b/jscomp/test/module_splice_test.js @@ -20,12 +20,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/more_poly_variant_test.js b/jscomp/test/more_poly_variant_test.js index 7e9057076a..e21d0d4b5c 100644 --- a/jscomp/test/more_poly_variant_test.js +++ b/jscomp/test/more_poly_variant_test.js @@ -3,7 +3,7 @@ function map(f) { - return function (x) { + return x => { if (typeof x !== "object") { return "Nil"; } diff --git a/jscomp/test/mpr_6033_test.js b/jscomp/test/mpr_6033_test.js index 9c1d14ef49..d082011a65 100644 --- a/jscomp/test/mpr_6033_test.js +++ b/jscomp/test/mpr_6033_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -33,9 +31,7 @@ function f(x) { return CamlinternalLazy.force(x) + "abc"; } -let x = CamlinternalLazy.from_fun(function () { - return "def"; -}); +let x = CamlinternalLazy.from_fun(() => "def"); CamlinternalLazy.force(x); diff --git a/jscomp/test/mt.js b/jscomp/test/mt.js index 8f4c47e25f..39789af3cf 100644 --- a/jscomp/test/mt.js +++ b/jscomp/test/mt.js @@ -220,17 +220,13 @@ function old_from_promise_suites_donotuse(name, suites) { let match = $$Array.to_list(Process.argv); if (match) { if (is_mocha()) { - describe(name, (function () { - List.iter((function (param) { - let code = param[1]; - it(param[0], (function () { - return code.then(function (x) { - handleCode(x); - return val_unit; - }); - })); - }), suites); - })); + describe(name, () => List.iter(param => { + let code = param[1]; + it(param[0], () => code.then(x => { + handleCode(x); + return val_unit; + })); + }, suites)); } else { console.log("promise suites"); } @@ -244,12 +240,10 @@ function eq_suites(test_id, suites, loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Eq", - _0: x, - _1: y - }; + param => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -261,11 +255,9 @@ function bool_suites(test_id, suites, loc, x) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Ok", - _0: x - }; + param => ({ + TAG: "Ok", + _0: x }) ], tl: suites.contents @@ -277,11 +269,9 @@ function throw_suites(test_id, suites, loc, x) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "ThrowAny", - _0: x - }; + param => ({ + TAG: "ThrowAny", + _0: x }) ], tl: suites.contents diff --git a/jscomp/test/mt_global.js b/jscomp/test/mt_global.js index 7c2e5f1a68..77c1aa2db3 100644 --- a/jscomp/test/mt_global.js +++ b/jscomp/test/mt_global.js @@ -7,12 +7,10 @@ function collect_eq(test_id, suites, loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Eq", - _0: x, - _1: y - }; + param => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -24,12 +22,10 @@ function collect_neq(test_id, suites, loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Neq", - _0: x, - _1: y - }; + param => ({ + TAG: "Neq", + _0: x, + _1: y }) ], tl: suites.contents @@ -41,12 +37,10 @@ function collect_approx(test_id, suites, loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Approx", - _0: x, - _1: y - }; + param => ({ + TAG: "Approx", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/mutable_obj_test.js b/jscomp/test/mutable_obj_test.js index d8a8805455..19f7c687a9 100644 --- a/jscomp/test/mutable_obj_test.js +++ b/jscomp/test/mutable_obj_test.js @@ -3,11 +3,9 @@ function f(x) { - x.dec = (function (x) { - return { - x: x, - y: x - }; + x.dec = x => ({ + x: x, + y: x }); } diff --git a/jscomp/test/mutable_uncurry_test.js b/jscomp/test/mutable_uncurry_test.js index c5d12b79b5..8aa2107971 100644 --- a/jscomp/test/mutable_uncurry_test.js +++ b/jscomp/test/mutable_uncurry_test.js @@ -64,9 +64,9 @@ function t3(param, param$1, param$2) { function ut4(param, param$1, param$2, param$3) { let x0 = param.contents; let x1 = param$1.contents; - return (function (param) { + return (param => { let x2 = param.contents; - return function (param) { + return param => { let x3 = param.contents; return [ x0, @@ -81,9 +81,9 @@ function ut4(param, param$1, param$2, param$3) { function t4(param, param$1, param$2, param$3) { let x0 = param.contents; let x1 = param$1.contents; - return (function (param) { + return (param => { let x2 = param.contents; - return function (param) { + return param => { let x3 = param.contents; return [ x0, @@ -98,11 +98,11 @@ function t4(param, param$1, param$2, param$3) { function ut5(param, param$1, param$2, param$3, param$4) { let x0 = param.contents; let x1 = param$1.contents; - return (function (param) { + return (param => { let x2 = param.contents; - return function (param) { + return param => { let x3 = param.contents; - return function (param) { + return param => { let x4 = param.contents; return [ x0, @@ -119,11 +119,11 @@ function ut5(param, param$1, param$2, param$3, param$4) { function t5(param, param$1, param$2, param$3, param$4) { let x0 = param.contents; let x1 = param$1.contents; - return (function (param) { + return (param => { let x2 = param.contents; - return function (param) { + return param => { let x3 = param.contents; - return function (param) { + return param => { let x4 = param.contents; return [ x0, @@ -142,7 +142,7 @@ function nested0(param, param$1, param$2) { let x1 = param$1.contents; let x2 = param$2.contents; let a = (x0 + x1 | 0) + x2 | 0; - return function (param, param$1, param$2) { + return (param, param$1, param$2) => { let x0 = param.contents; let x1 = param$1.contents; let x2 = param$2.contents; @@ -155,7 +155,7 @@ function nested1(param, param$1, param$2) { let x1 = param$1.contents; let x2 = param$2.contents; let a = (x0 + x1 | 0) + x2 | 0; - return function (param, param$1, param$2) { + return (param, param$1, param$2) => { let x0 = param.contents; let x1 = param$1.contents; let x2 = param$2.contents; diff --git a/jscomp/test/name_mangle_test.js b/jscomp/test/name_mangle_test.js index 23d9221ab0..82e3e3bcb2 100644 --- a/jscomp/test/name_mangle_test.js +++ b/jscomp/test/name_mangle_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/obj_literal_ppx.js b/jscomp/test/obj_literal_ppx.js index c04893eba3..2d58df4583 100644 --- a/jscomp/test/obj_literal_ppx.js +++ b/jscomp/test/obj_literal_ppx.js @@ -11,9 +11,7 @@ let b = { x: 3, y: [1], z: 3, - u: (function (x, y) { - return x + y | 0; - }) + u: (x, y) => x + y | 0 }; function f(obj) { diff --git a/jscomp/test/obj_magic_test.js b/jscomp/test/obj_magic_test.js index 1f4ad65e35..7e6071f1f2 100644 --- a/jscomp/test/obj_magic_test.js +++ b/jscomp/test/obj_magic_test.js @@ -9,49 +9,41 @@ function is_block(x) { let suites_0 = [ "is_block_test1", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: "number" !== "number" - }; + param => ({ + TAG: "Eq", + _0: false, + _1: "number" !== "number" }) ]; let suites_1 = { hd: [ "is_block_test2", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: typeof ({ - hd: 3, - tl: /* [] */0 - }) !== "number" - }; + param => ({ + TAG: "Eq", + _0: true, + _1: typeof ({ + hd: 3, + tl: /* [] */0 + }) !== "number" }) ], tl: { hd: [ "is_block_test3", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: "string" !== "number" - }; + param => ({ + TAG: "Eq", + _0: true, + _1: "string" !== "number" }) ], tl: { hd: [ "is_block_test4", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: "number" !== "number" - }; + param => ({ + TAG: "Eq", + _0: false, + _1: "number" !== "number" }) ], tl: /* [] */0 diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 7bf28c6f0b..38aef77e7a 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -31,12 +31,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -790,9 +788,7 @@ function rename(ids, x) { case "Alt" : return mk_expr(ids, { TAG: "Alt", - _0: List.map((function (extra) { - return rename(ids, extra); - }), l._0) + _0: List.map(extra => rename(ids, extra), l._0) }); case "Seq" : return mk_expr(ids, { @@ -1001,24 +997,22 @@ function reset_table(a) { } function mark_used_indices(tbl) { - return function (extra) { - return List.iter((function (x) { - switch (x.TAG) { - case "TSeq" : - return mark_used_indices(tbl)(x._0); - case "TExp" : - case "TMatch" : - break; + return extra => List.iter(x => { + switch (x.TAG) { + case "TSeq" : + return mark_used_indices(tbl)(x._0); + case "TExp" : + case "TMatch" : + break; + } + List.iter(param => { + let i = param[1]; + if (i >= 0) { + return Caml_array.set(tbl, i, true); } - List.iter((function (param) { - let i = param[1]; - if (i >= 0) { - return Caml_array.set(tbl, i, true); - } - - }), x._0.marks); - }), extra); - }; + + }, x._0.marks); + }, extra); } function find_free(tbl, _idx, len) { @@ -1045,7 +1039,7 @@ function free_index(tbl_ref, l) { } function remove_matches(extra) { - return List.filter((function (x) { + return List.filter(x => { switch (x.TAG) { case "TSeq" : case "TExp" : @@ -1053,7 +1047,7 @@ function remove_matches(extra) { case "TMatch" : return false; } - }), extra); + }, extra); } function split_at_match_rec(_l$p, _x) { @@ -1198,14 +1192,14 @@ function set_idx(idx, x) { function filter_marks(b, e, marks) { return { - marks: List.filter((function (param) { + marks: List.filter(param => { let i = param[0]; if (i < b) { return true; } else { return i > e; } - }), marks.marks), + }, marks.marks), pmarks: marks.pmarks }; } @@ -1243,7 +1237,7 @@ function delta_1(marks, c, next_cat, prev_cat, x, rem) { case "Rep" : let kind = s._1; let y$p$1 = delta_1(marks, c, next_cat, prev_cat, s._2, /* [] */0); - let marks$p = first((function (x) { + let marks$p = first(x => { switch (x.TAG) { case "TSeq" : case "TExp" : @@ -1251,7 +1245,7 @@ function delta_1(marks, c, next_cat, prev_cat, x, rem) { case "TMatch" : return x._0; } - }), y$p$1); + }, y$p$1); let match = marks$p !== undefined ? [ remove_matches(y$p$1), marks$p @@ -1356,7 +1350,7 @@ function delta_2(marks, c, next_cat, prev_cat, l, rem) { } function delta_seq(c, next_cat, prev_cat, kind, y, z, rem) { - let marks = first((function (x) { + let marks = first(x => { switch (x.TAG) { case "TSeq" : case "TExp" : @@ -1364,7 +1358,7 @@ function delta_seq(c, next_cat, prev_cat, kind, y, z, rem) { case "TMatch" : return x._0; } - }), y); + }, y); if (marks === undefined) { return tseq(kind, y, z, rem); } @@ -1409,13 +1403,9 @@ function delta(tbl_ref, next_cat, char, st) { } function flatten_match(m) { - let ma = List.fold_left((function (ma, param) { - return Caml.int_max(ma, param[0]); - }), -1, m); + let ma = List.fold_left((ma, param) => Caml.int_max(ma, param[0]), -1, m); let res = Caml_array.make(ma + 1 | 0, -1); - List.iter((function (param) { - Caml_array.set(res, param[0], param[1]); - }), m); + List.iter(param => Caml_array.set(res, param[0], param[1]), m); return res; } @@ -1747,9 +1737,7 @@ 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 = List.fold_right((function (param, l) { - return union(seq(Caml_bytes.get(cm, param[0]), Caml_bytes.get(cm, param[1])), l); - }), s, /* [] */0); + let l = List.fold_right((param, l) => union(seq(Caml_bytes.get(cm, param[0]), Caml_bytes.get(cm, param[1])), l), s, /* [] */0); cache.contents = add(v, l, cache.contents); return l; } @@ -1795,7 +1783,7 @@ function is_charset(_x) { function split(s, cm) { let _t = s; - let f = function (i, j) { + let f = (i, j) => { Caml_bytes.set(cm, i, /* '\001' */1); Caml_bytes.set(cm, j + 1 | 0, /* '\001' */1); }; @@ -1848,7 +1836,7 @@ function colorize(c, regexp) { let lnl = { contents: false }; - let colorize$1 = function (_regexp) { + let colorize$1 = _regexp => { while (true) { let regexp = _regexp; if (typeof regexp !== "object") { @@ -2408,10 +2396,10 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _x) ]; } return [ - alt(ids, List.map((function (r$p) { + alt(ids, List.map(r$p => { let match = translate(ids, kind, ign_group, ign_case, greedy, pos, cache, c, r$p); return enforce_kind(ids, kind, match[1], match[0]); - }), merged_sequences)), + }, merged_sequences)), kind ]; case "Repeat" : @@ -2422,31 +2410,25 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _x) let cr = match$1[0]; let rem; if (j !== undefined) { - let f = greedy === "Non_greedy" ? (function (rem) { - return alt(ids, { - hd: mk_expr(ids, "Eps"), - tl: { - hd: seq$1(ids, kind$p, rename(ids, cr), rem), - tl: /* [] */0 - } - }); - }) : (function (rem) { - return alt(ids, { + let f = greedy === "Non_greedy" ? rem => alt(ids, { + hd: mk_expr(ids, "Eps"), + tl: { hd: seq$1(ids, kind$p, rename(ids, cr), rem), - tl: { - hd: mk_expr(ids, "Eps"), - tl: /* [] */0 - } - }); + tl: /* [] */0 + } + }) : rem => alt(ids, { + hd: seq$1(ids, kind$p, rename(ids, cr), rem), + tl: { + hd: mk_expr(ids, "Eps"), + tl: /* [] */0 + } }); rem = iter(j - i | 0, f, mk_expr(ids, "Eps")); } else { rem = rep(ids, greedy, kind$p, cr); } return [ - iter(i, (function (rem) { - return seq$1(ids, kind$p, rename(ids, cr), rem); - }), rem), + iter(i, rem => seq$1(ids, kind$p, rename(ids, cr), rem), rem), kind ]; case "Sem" : @@ -2596,23 +2578,17 @@ function handle_case(_ign_case, _x) { case "Sequence" : return { TAG: "Sequence", - _0: List.map((function (extra) { - return handle_case(ign_case, extra); - }), x._0) + _0: List.map(extra => handle_case(ign_case, extra), x._0) }; case "Alternative" : - let l$p = List.map((function (extra) { - return handle_case(ign_case, extra); - }), x._0); + let l$p = List.map(extra => handle_case(ign_case, extra), x._0); if (is_charset({ TAG: "Alternative", _0: l$p })) { return { TAG: "Set", - _0: List.fold_left((function (s, r) { - return union(s, as_set(r)); - }), /* [] */0, l$p) + _0: List.fold_left((s, r) => union(s, as_set(r)), /* [] */0, l$p) }; } else { return { @@ -2683,24 +2659,16 @@ function handle_case(_ign_case, _x) { _ign_case = true; continue; case "Intersection" : - let l$p$1 = List.map((function (r) { - return handle_case(ign_case, r); - }), x._0); + let l$p$1 = List.map(r => handle_case(ign_case, r), x._0); return { TAG: "Set", - _0: List.fold_left((function (s, r) { - return inter(s, as_set(r)); - }), cany, l$p$1) + _0: List.fold_left((s, r) => inter(s, as_set(r)), cany, l$p$1) }; case "Complement" : - let l$p$2 = List.map((function (r) { - return handle_case(ign_case, r); - }), x._0); + let l$p$2 = List.map(r => handle_case(ign_case, r), x._0); return { TAG: "Set", - _0: diff(cany, List.fold_left((function (s, r) { - return union(s, as_set(r)); - }), /* [] */0, l$p$2)) + _0: diff(cany, List.fold_left((s, r) => union(s, as_set(r)), /* [] */0, l$p$2)) }; case "Difference" : return { @@ -3332,21 +3300,21 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { contents: 0 }; let l = s.length; - let test = function (c) { + let test = c => { if (i.contents !== l) { return Caml_string.get(s, i.contents) === c; } else { return false; } }; - let accept = function (c) { + let accept = c => { let r = test(c); if (r) { i.contents = i.contents + 1 | 0; } return r; }; - let accept_s = function (s$p) { + let accept_s = s$p => { let len = s$p.length; try { for (let j = 0; j < len; ++j) { @@ -3379,12 +3347,12 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }); } }; - let get = function () { + let get = () => { let r = Caml_string.get(s, i.contents); i.contents = i.contents + 1 | 0; return r; }; - let greedy_mod = function (r) { + let greedy_mod = r => { let gr = accept(/* '?' */63); let gr$1 = ungreedy ? !gr : gr; if (gr$1) { @@ -3401,7 +3369,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - let regexp$p = function (_left) { + let regexp$p = _left => { while (true) { let left = _left; if (!accept(/* '|' */124)) { @@ -3417,7 +3385,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue; }; }; - let branch$p = function (_left) { + let branch$p = _left => { while (true) { let left = _left; if (i.contents === l || test(/* '|' */124) || test(/* ')' */41)) { @@ -3430,7 +3398,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue; }; }; - let atom = function () { + let atom = () => { if (accept(/* '.' */46)) { if (dotall) { return any; @@ -3693,7 +3661,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - let integer = function () { + let integer = () => { if (i.contents === l) { return; } @@ -3726,7 +3694,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - let piece = function () { + let piece = () => { let r = atom(); if (accept(/* '*' */42)) { return greedy_mod(repn(r, 0, undefined)); @@ -3762,7 +3730,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { i.contents = i.contents - 1 | 0; return r; }; - let char = function () { + let char = () => { if (i.contents === l) { throw new Error(Parse_error, { cause: { @@ -4066,7 +4034,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } }; - let bracket = function (_s) { + let bracket = _s => { while (true) { let s = _s; if (s !== /* [] */0 && accept(/* ']' */93)) { @@ -4147,10 +4115,8 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue; }; }; - let branch = function () { - return branch$p(/* [] */0); - }; - let comment = function () { + let branch = () => branch$p(/* [] */0); + let comment = () => { while (true) { if (accept(/* ')' */41)) { return epsilon; @@ -4172,7 +4138,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { function re(flagsOpt, pat) { let flags = flagsOpt !== undefined ? flagsOpt : /* [] */0; - let opts = List.map((function (x) { + let opts = List.map(x => { if (x === "CASELESS") { return "Caseless"; } else if (x === "ANCHORED") { @@ -4180,7 +4146,7 @@ function re(flagsOpt, pat) { } else { return "Multiline"; } - }), flags); + }, flags); let optsOpt = opts; let opts$1 = optsOpt !== undefined ? optsOpt : /* [] */0; let r = parse(List.memq("Multiline", opts$1), List.memq("Dollar_endonly", opts$1), List.memq("Dotall", opts$1), List.memq("Ungreedy", opts$1), pat); diff --git a/jscomp/test/of_string_test.js b/jscomp/test/of_string_test.js index fffd6400b2..4eaffc2f4a 100644 --- a/jscomp/test/of_string_test.js +++ b/jscomp/test/of_string_test.js @@ -6,35 +6,29 @@ let Pervasives = require("../../lib/js/pervasives.js"); let suites_0 = [ "string_of_float_1", - (function (param) { - return { - TAG: "Eq", - _0: "10.", - _1: Pervasives.string_of_float(10) - }; + param => ({ + TAG: "Eq", + _0: "10.", + _1: Pervasives.string_of_float(10) }) ]; let suites_1 = { hd: [ "string_of_int", - (function (param) { - return { - TAG: "Eq", - _0: "10", - _1: String(10) - }; + param => ({ + TAG: "Eq", + _0: "10", + _1: String(10) }) ], tl: { hd: [ "valid_float_lexem", - (function (param) { - return { - TAG: "Eq", - _0: "10.", - _1: Pervasives.valid_float_lexem("10") - }; + param => ({ + TAG: "Eq", + _0: "10.", + _1: Pervasives.valid_float_lexem("10") }) ], tl: /* [] */0 diff --git a/jscomp/test/offset.js b/jscomp/test/offset.js index 07958cb021..478ed2bf19 100644 --- a/jscomp/test/offset.js +++ b/jscomp/test/offset.js @@ -865,7 +865,7 @@ function of_list(l) { if (match$3) { if (match$3.tl) { let l$1 = List.sort_uniq($$String.compare, l); - let sub = function (n, l) { + let sub = (n, l) => { switch (n) { case 0 : return [ diff --git a/jscomp/test/option_repr_test.js b/jscomp/test/option_repr_test.js index d11f4a8f4b..b4435fe07e 100644 --- a/jscomp/test/option_repr_test.js +++ b/jscomp/test/option_repr_test.js @@ -104,13 +104,9 @@ function f12(x) { return x; } -let length_8_id = Belt_List.makeBy(8, (function (x) { - return x; -})); +let length_8_id = Belt_List.makeBy(8, x => x); -let length_10_id = Belt_List.makeBy(10, (function (x) { - return x; -})); +let length_10_id = Belt_List.makeBy(10, x => x); function f13$1() { return Caml_obj.equal(Belt_List.take(length_10_id, 8), { @@ -170,9 +166,7 @@ function neqx(a, b) { } function all_true(xs) { - return Belt_List.every(xs, (function (x) { - return x; - })); + return Belt_List.every(xs, x => x); } let xs_0 = gtx(Caml_option.some(null), Caml_option.some(undefined)); @@ -182,9 +176,7 @@ let xs = { tl: /* [] */0 }; -b("File \"option_repr_test.res\", line 125, characters 8-15", Belt_List.every(xs, (function (x) { - return x; -}))); +b("File \"option_repr_test.res\", line 125, characters 8-15", Belt_List.every(xs, x => x)); let xs_0$1 = ltx(Caml_option.some(undefined), 3); @@ -205,9 +197,7 @@ let xs_1 = { tl: { hd: ltx(undefined, null), tl: { - hd: ltx(undefined, (function (x) { - return x; - })), + hd: ltx(undefined, x => x), tl: { hd: ltx(null, 3), tl: /* [] */0 @@ -227,9 +217,7 @@ let xs$1 = { tl: xs_1 }; -b("File \"option_repr_test.res\", line 128, characters 4-11", Belt_List.every(xs$1, (function (x) { - return x; -}))); +b("File \"option_repr_test.res\", line 128, characters 4-11", Belt_List.every(xs$1, x => x)); let xs_0$2 = eqx(undefined, undefined); @@ -252,9 +240,7 @@ let xs$2 = { tl: xs_1$1 }; -b("File \"option_repr_test.res\", line 145, characters 4-11", Belt_List.every(xs$2, (function (x) { - return x; -}))); +b("File \"option_repr_test.res\", line 145, characters 4-11", Belt_List.every(xs$2, x => x)); function v(x) { return x; diff --git a/jscomp/test/optional_ffi_test.js b/jscomp/test/optional_ffi_test.js index ee8af83093..9b6651b5cc 100644 --- a/jscomp/test/optional_ffi_test.js +++ b/jscomp/test/optional_ffi_test.js @@ -19,12 +19,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/pipe_send_readline.js b/jscomp/test/pipe_send_readline.js index 0e1ec13fd6..5d450e7f9e 100644 --- a/jscomp/test/pipe_send_readline.js +++ b/jscomp/test/pipe_send_readline.js @@ -3,11 +3,11 @@ function u(rl) { - return rl.on("line", (function (x) { + return rl.on("line", x => { console.log(x); - })).on("close", (function () { + }).on("close", () => { console.log("finished"); - })); + }); } function xx(h) { diff --git a/jscomp/test/poly_variant_test.js b/jscomp/test/poly_variant_test.js index be1b53951c..a52acfbb73 100644 --- a/jscomp/test/poly_variant_test.js +++ b/jscomp/test/poly_variant_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/polymorphic_raw_test.js b/jscomp/test/polymorphic_raw_test.js index 47e63d1f48..063688f618 100644 --- a/jscomp/test/polymorphic_raw_test.js +++ b/jscomp/test/polymorphic_raw_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/ppx_apply_test.js b/jscomp/test/ppx_apply_test.js index c8d27383ce..43e26e376d 100644 --- a/jscomp/test/ppx_apply_test.js +++ b/jscomp/test/ppx_apply_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/prepend_data_ffi.js b/jscomp/test/prepend_data_ffi.js index 3da0ea93e7..a2b0584725 100644 --- a/jscomp/test/prepend_data_ffi.js +++ b/jscomp/test/prepend_data_ffi.js @@ -12,21 +12,13 @@ let v2 = { v: 2 }; -process.on("exit", (function (exit_code) { - return String(exit_code); -})); +process.on("exit", exit_code => String(exit_code)); -process.on(1, (function (param) { - -})); +process.on(1, param => {}); -process.on((function (i) { - return String(i); -}), "exit"); +process.on(i => String(i), "exit"); -process.on((function (i) { - return String(i); -}), 1); +process.on(i => String(i), 1); xx(3, 3, "xxx", "a", "b"); @@ -46,14 +38,14 @@ function f(x) { x.xx(76, 3, true, false, "你好", ["你好",1,2,3] , [{ "arr" : ["你好",1,2,3], "encoding" : "utf8"}] , [{ "arr" : ["你好",1,2,3], "encoding" : "utf8"}] , "xxx", 0, "yyy", "b", 1, 2, 3, 4, 5); } -process.on("exit", (function (exit_code) { +process.on("exit", exit_code => { console.log("error code: " + String(exit_code)); -})); +}); function register(p) { - p.on("exit", (function (i) { + p.on("exit", i => { console.log(i); - })); + }); } let config = { diff --git a/jscomp/test/print_alpha_test.js b/jscomp/test/print_alpha_test.js index e9f3efb844..36dc07f707 100644 --- a/jscomp/test/print_alpha_test.js +++ b/jscomp/test/print_alpha_test.js @@ -5,22 +5,16 @@ let Mt = require("./mt.js"); function f(h, param) { console.log(3); - return function (x, y) { - return h(x, y); - }; + return (x, y) => h(x, y); } Mt.from_pair_suites("Print_alpha_test", { hd: [ "File \"print_alpha_test.res\", line 16, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: f((function (prim0, prim1) { - return prim0 + prim1 | 0; - }), undefined)(1, 2), - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: f((prim0, prim1) => prim0 + prim1 | 0, undefined)(1, 2), + _1: 3 }) ], tl: /* [] */0 diff --git a/jscomp/test/queue_402.js b/jscomp/test/queue_402.js index 2e37b1eba6..c40c62a0f9 100644 --- a/jscomp/test/queue_402.js +++ b/jscomp/test/queue_402.js @@ -81,7 +81,7 @@ function copy(q) { content: tail.content, next: tail$p }); - let copy$1 = function (_prev, _cell) { + let copy$1 = (_prev, _cell) => { while (true) { let cell = _cell; let prev = _prev; diff --git a/jscomp/test/queue_test.js b/jscomp/test/queue_test.js index a13947853a..f27062e419 100644 --- a/jscomp/test/queue_test.js +++ b/jscomp/test/queue_test.js @@ -8,19 +8,17 @@ 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 to_array = q => { let v = Caml_array.make(Queue.length(q), 0); - Queue.fold((function (i, e) { + Queue.fold((i, e) => { Caml_array.set(v, i, e); return i + 1 | 0; - }), 0, q); + }, 0, q); return v; }; - let queue_1 = function (x) { + let queue_1 = x => { let q = Queue.create(); - $$Array.iter((function (x) { - Queue.add(x, q); - }), x); + $$Array.iter(x => Queue.add(x, q), x); return to_array(q); }; return { @@ -31,10 +29,10 @@ function Test(Queue) { function to_array(q) { let v = Caml_array.make(q.length, 0); - Queue.fold((function (i, e) { + Queue.fold((i, e) => { Caml_array.set(v, i, e); return i + 1 | 0; - }), 0, q); + }, 0, q); return v; } @@ -44,9 +42,7 @@ function queue_1(x) { first: "Nil", last: "Nil" }; - $$Array.iter((function (x) { - Queue.add(x, q); - }), x); + $$Array.iter(x => Queue.add(x, q), x); return to_array(q); } @@ -57,10 +53,10 @@ let T1 = { function to_array$1(q) { let v = Caml_array.make(q.length, 0); - Queue_402.fold((function (i, e) { + Queue_402.fold((i, e) => { Caml_array.set(v, i, e); return i + 1 | 0; - }), 0, q); + }, 0, q); return v; } @@ -69,9 +65,7 @@ function queue_1$1(x) { length: 0, tail: undefined }; - $$Array.iter((function (x) { - Queue_402.add(x, q); - }), x); + $$Array.iter(x => Queue_402.add(x, q), x); return to_array$1(q); } @@ -82,7 +76,7 @@ let T2 = { let suites_0 = [ "File \"queue_test.res\", line 34, characters 6-13", - (function (param) { + param => { let x = [ 3, 4, @@ -94,13 +88,13 @@ let suites_0 = [ _0: x, _1: queue_1(x) }; - }) + } ]; let suites_1 = { hd: [ "File \"queue_test.res\", line 41, characters 6-13", - (function (param) { + param => { let x = [ 3, 4, @@ -112,7 +106,7 @@ let suites_1 = { _0: x, _1: queue_1$1(x) }; - }) + } ], tl: /* [] */0 }; diff --git a/jscomp/test/random_test.js b/jscomp/test/random_test.js index f1460f1e59..1e59086117 100644 --- a/jscomp/test/random_test.js +++ b/jscomp/test/random_test.js @@ -16,21 +16,15 @@ let suites = { }; function eq(f) { - return function (extra, extra$1) { - return Mt_global.collect_eq(id, suites, f, extra, extra$1); - }; + return (extra, extra$1) => Mt_global.collect_eq(id, suites, f, extra, extra$1); } function neq(f) { - return function (extra, extra$1) { - return Mt_global.collect_neq(id, suites, f, extra, extra$1); - }; + return (extra, extra$1) => Mt_global.collect_neq(id, suites, f, extra, extra$1); } function approx(f) { - return function (extra, extra$1) { - return Mt_global.collect_approx(id, suites, f, extra, extra$1); - }; + return (extra, extra$1) => Mt_global.collect_approx(id, suites, f, extra, extra$1); } Mt_global.collect_neq(id, suites, "File \"random_test.res\", line 9, characters 2-9", (Random.self_init(), Random.int(10000)), (Random.self_init(), Random.int(1000))); diff --git a/jscomp/test/reactTestUtils.js b/jscomp/test/reactTestUtils.js index 05a3759b7c..946b17773f 100644 --- a/jscomp/test/reactTestUtils.js +++ b/jscomp/test/reactTestUtils.js @@ -7,16 +7,14 @@ let Caml_option = require("../../lib/js/caml_option.js"); let TestUtils = require("react-dom/test-utils"); function act(func) { - let reactFunc = function () { + let reactFunc = () => { func(); }; TestUtils.act(reactFunc); } function actAsync(func) { - return TestUtils.act(function () { - return func(); - }); + return TestUtils.act(() => func()); } function changeWithValue(element, value) { @@ -51,15 +49,11 @@ function findByAllSelector(element, selector) { } function findBySelectorAndTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), (function (node) { - return node.textContent === content; - })); + return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), node => node.textContent === content); } function findBySelectorAndPartialTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), (function (node) { - return node.textContent.includes(content); - })); + return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), node => node.textContent.includes(content)); } let DOM = { @@ -71,16 +65,14 @@ let DOM = { function prepareContainer(container, param) { let containerElement = document.createElement("div"); - Belt_Option.map(document.body, (function (body) { - return body.appendChild(containerElement); - })); + Belt_Option.map(document.body, body => body.appendChild(containerElement)); container.contents = Caml_option.some(containerElement); } function cleanupContainer(container, param) { - Belt_Option.map(container.contents, (function (prim) { + Belt_Option.map(container.contents, prim => { prim.remove(); - })); + }); container.contents = undefined; } diff --git a/jscomp/test/reasonReact.js b/jscomp/test/reasonReact.js index 49bd1161a1..afbce1d035 100644 --- a/jscomp/test/reasonReact.js +++ b/jscomp/test/reasonReact.js @@ -84,9 +84,7 @@ function element(keyOpt, refOpt, component) { } function wrapReasonForJs(component, jsPropsToReason) { - let uncurriedJsPropsToReason = function (jsProps) { - return jsPropsToReason(jsProps); - }; + let uncurriedJsPropsToReason = jsProps => jsPropsToReason(jsProps); component.reactClassInternal.prototype.jsPropsToReason = uncurriedJsPropsToReason; return component.reactClassInternal; } @@ -94,7 +92,7 @@ function wrapReasonForJs(component, jsPropsToReason) { let dummyInteropComponent = basicComponent("interop"); function wrapJsForReason(reactClass, props, children) { - let jsElementWrapped = (function (extra, extra$1) { + let jsElementWrapped = (extra, extra$1) => { let props$1 = Object.assign(Object.assign({}, props), { ref: extra$1, key: extra @@ -104,7 +102,7 @@ function wrapJsForReason(reactClass, props, children) { props$1 ].concat(children); return React.createElement.apply(null, varargs); - }); + }; return { debugName: dummyInteropComponent.debugName, reactClassInternal: dummyInteropComponent.reactClassInternal, diff --git a/jscomp/test/reasonReactRouter.js b/jscomp/test/reasonReactRouter.js index bc95545c7d..0c2e3102bc 100644 --- a/jscomp/test/reasonReactRouter.js +++ b/jscomp/test/reasonReactRouter.js @@ -138,13 +138,9 @@ function url() { function watchUrl(callback) { let window = globalThis.window; if (window === undefined) { - return function () { - - }; + return () => {}; } - let watcherID = function () { - callback(url()); - }; + let watcherID = () => callback(url()); Caml_option.valFromOption(window).addEventListener("popstate", watcherID); return watcherID; } @@ -159,7 +155,7 @@ function unwatchUrl(watcherID) { } function useUrl(serverUrl, param) { - let match = React.useState(function () { + let match = React.useState(() => { if (serverUrl !== undefined) { return serverUrl; } else { @@ -168,22 +164,14 @@ function useUrl(serverUrl, param) { }); let setUrl = match[1]; let url$1 = match[0]; - React.useEffect((function () { - let watcherId = watchUrl(function (url) { - setUrl(function (param) { - return url; - }); - }); + React.useEffect(() => { + let watcherId = watchUrl(url => setUrl(param => url)); let newUrl = url(); if (urlNotEqual(newUrl, url$1)) { - setUrl(function (param) { - return newUrl; - }); + setUrl(param => newUrl); } - return (function () { - unwatchUrl(watcherId); - }); - }), []); + return () => unwatchUrl(watcherId); + }, []); return url$1; } diff --git a/jscomp/test/rec_fun_test.js b/jscomp/test/rec_fun_test.js index 43b6b52903..c29dad5067 100644 --- a/jscomp/test/rec_fun_test.js +++ b/jscomp/test/rec_fun_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -35,7 +33,7 @@ let called = { function g() { let v = {}; - let next = function (i, b) { + let next = (i, b) => { called.contents = called.contents + 1 | 0; if (b) { v.contents(i, false); diff --git a/jscomp/test/rec_module_test.js b/jscomp/test/rec_module_test.js index 44fec3d4c3..eeeeb1eb4c 100644 --- a/jscomp/test/rec_module_test.js +++ b/jscomp/test/rec_module_test.js @@ -1044,7 +1044,7 @@ function of_list(l) { if (match$3) { if (match$3.tl) { let l$1 = List.sort_uniq(AAA.compare, l); - let sub = function (n, l) { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -1218,107 +1218,93 @@ Caml_module.update_mod({ let suites_0 = [ "test1", - (function (param) { - return { - TAG: "Eq", - _0: [ - true, - true, - false, - false - ], - _1: [ - A.even(2), - AA.even(4), - B.odd(2), - BB.odd(4) - ] - }; + param => ({ + TAG: "Eq", + _0: [ + true, + true, + false, + false + ], + _1: [ + A.even(2), + AA.even(4), + B.odd(2), + BB.odd(4) + ] }) ]; let suites_1 = { hd: [ "test2", - (function (param) { - return { - TAG: "Eq", - _0: BB.y(), - _1: 32 - }; + param => ({ + TAG: "Eq", + _0: BB.y(), + _1: 32 }) ], tl: { hd: [ "test3", - (function (param) { - return { - TAG: "Eq", - _0: AA.x(), - _1: 35 - }; + param => ({ + TAG: "Eq", + _0: AA.x(), + _1: 35 }) ], tl: { hd: [ "test4", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: A.even(2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: A.even(2) }) ], tl: { hd: [ "test4", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: AA.even(4) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: AA.even(4) }) ], tl: { hd: [ "test5", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: B.odd(2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: B.odd(2) }) ], tl: { hd: [ "test6", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: cardinal(of_list({ + param => ({ + TAG: "Eq", + _0: 2, + _1: cardinal(of_list({ + hd: { + TAG: "Leaf", + _0: "a" + }, + tl: { hd: { TAG: "Leaf", - _0: "a" + _0: "b" }, tl: { hd: { TAG: "Leaf", - _0: "b" + _0: "a" }, - tl: { - hd: { - TAG: "Leaf", - _0: "a" - }, - tl: /* [] */0 - } + tl: /* [] */0 } - })) - }; + } + })) }) ], tl: /* [] */0 diff --git a/jscomp/test/recmodule.js b/jscomp/test/recmodule.js index c1dd92c6ed..c940c8ea14 100644 --- a/jscomp/test/recmodule.js +++ b/jscomp/test/recmodule.js @@ -6,12 +6,10 @@ let Caml_module = require("../../lib/js/caml_module.js"); let Entity = {}; function MakeLayer(Deps) { - let getLight = function (id) { - return Deps.presentLight({ - id: id, - name: "Light 1" - }); - }; + let getLight = id => Deps.presentLight({ + id: id, + name: "Light 1" + }); return { getLight: getLight }; @@ -22,12 +20,8 @@ let UseCase = { }; function MakeLayer$1(Deps, UC) { - let presentLight = function (light) { - return Deps.presentJson(light, 200); - }; - let handleGetLight = function (req) { - return UC.getLight(req.params.id); - }; + let presentLight = light => Deps.presentJson(light, 200); + let handleGetLight = req => UC.getLight(req.params.id); return { handleGetLight: handleGetLight, presentLight: presentLight @@ -39,7 +33,7 @@ let Adapter = { }; function MakeLayer$2(Deps) { - let presentJson = function (json, status) { + let presentJson = (json, status) => { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -51,12 +45,10 @@ function MakeLayer$2(Deps) { } }); }; - let routes = function () { - return [[ - "/lights", - Deps.handleGetLight - ]]; - }; + let routes = () => [[ + "/lights", + Deps.handleGetLight + ]]; return { presentJson: presentJson, routes: routes diff --git a/jscomp/test/record_with_test.js b/jscomp/test/record_with_test.js index 045fc38e5b..174a4a9d9d 100644 --- a/jscomp/test/record_with_test.js +++ b/jscomp/test/record_with_test.js @@ -38,12 +38,10 @@ function f(g, h) { let suites_0 = [ "eq_with", - (function (param) { - return { - TAG: "Eq", - _0: v, - _1: u_v - }; + param => ({ + TAG: "Eq", + _0: v, + _1: u_v }) ]; diff --git a/jscomp/test/recursive_module.js b/jscomp/test/recursive_module.js index e3c0df5885..70ee5b42ee 100644 --- a/jscomp/test/recursive_module.js +++ b/jscomp/test/recursive_module.js @@ -20,9 +20,7 @@ function eq(loc, x, y) { } let Xx = { - f: (function (prim0, prim1) { - return hfiehi(prim0, prim1); - }) + f: (prim0, prim1) => hfiehi(prim0, prim1) }; let Int3 = Caml_module.init_mod([ @@ -69,9 +67,7 @@ let Intb = Caml_module.init_mod([ ]] }); -let a = CamlinternalLazy.from_fun(function () { - return CamlinternalLazy.force(Intb.a); -}); +let a = CamlinternalLazy.from_fun(() => CamlinternalLazy.force(Intb.a)); Caml_module.update_mod({ TAG: "Module", @@ -83,9 +79,7 @@ Caml_module.update_mod({ a: a }); -let a$1 = CamlinternalLazy.from_fun(function () { - return CamlinternalLazy.force(Inta.a) + 1 | 0; -}); +let a$1 = CamlinternalLazy.from_fun(() => CamlinternalLazy.force(Inta.a) + 1 | 0); Caml_module.update_mod({ TAG: "Module", @@ -138,9 +132,7 @@ let Intb$1 = Caml_module.init_mod([ ]] }); -let a$2 = CamlinternalLazy.from_fun(function () { - return CamlinternalLazy.force(Intb$1.a) + 1 | 0; -}); +let a$2 = CamlinternalLazy.from_fun(() => CamlinternalLazy.force(Intb$1.a) + 1 | 0); Caml_module.update_mod({ TAG: "Module", @@ -152,9 +144,7 @@ Caml_module.update_mod({ a: a$2 }); -let a$3 = CamlinternalLazy.from_fun(function () { - return 2; -}); +let a$3 = CamlinternalLazy.from_fun(() => 2); Caml_module.update_mod({ TAG: "Module", diff --git a/jscomp/test/recursive_module_test.js b/jscomp/test/recursive_module_test.js index 6edee60332..e6360c3055 100644 --- a/jscomp/test/recursive_module_test.js +++ b/jscomp/test/recursive_module_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -97,13 +95,11 @@ eq("File \"recursive_module_test.res\", line 29, characters 12-19", 120, fact$1( add([ "File \"recursive_module_test.res\", line 31, characters 14-21", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Int3.u(3); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Int3.u(3); + } }) ]); diff --git a/jscomp/test/recursive_unbound_module_test.js b/jscomp/test/recursive_unbound_module_test.js index 380e3aa408..333345ada6 100644 --- a/jscomp/test/recursive_unbound_module_test.js +++ b/jscomp/test/recursive_unbound_module_test.js @@ -4,9 +4,7 @@ let Caml_module = require("../../lib/js/caml_module.js"); function Make(X) { - let f = function () { - - }; + let f = () => {}; let M = { f: f }; diff --git a/jscomp/test/res_debug.js b/jscomp/test/res_debug.js index da1289ce18..d4b4fe2ee9 100644 --- a/jscomp/test/res_debug.js +++ b/jscomp/test/res_debug.js @@ -33,17 +33,13 @@ function optionMap(x, f) { } -let ok_name = optionMap(undefined, (function (x) { - return x; -})); +let ok_name = optionMap(undefined, x => x); let ok = { name: ok_name }; -let bad_name = optionMap(undefined, (function (x) { - return x; -})); +let bad_name = optionMap(undefined, x => x); let bad = { name: bad_name diff --git a/jscomp/test/return_check.js b/jscomp/test/return_check.js index 06b689c120..ab7805940a 100644 --- a/jscomp/test/return_check.js +++ b/jscomp/test/return_check.js @@ -42,7 +42,7 @@ function f_escaped_not(xs, i) { function f_escaped_1(xs, i) { let x = xs[i]; - return function () { + return () => { if (x !== undefined) { return x; } else { diff --git a/jscomp/test/set_gen.js b/jscomp/test/set_gen.js index 56131cc7bb..d5e26c887a 100644 --- a/jscomp/test/set_gen.js +++ b/jscomp/test/set_gen.js @@ -448,7 +448,7 @@ function partition(p, x) { } function of_sorted_list(l) { - let sub = function (n, l) { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -553,7 +553,7 @@ function of_sorted_list(l) { } function of_sorted_array(l) { - let sub = function (start, n, l) { + let sub = (start, n, l) => { if (n === 0) { return "Empty"; } @@ -619,7 +619,7 @@ function of_sorted_array(l) { } function is_ordered(cmp, tree) { - let is_ordered_min_max = function (tree) { + let is_ordered_min_max = tree => { if (typeof tree !== "object") { return "Empty"; } diff --git a/jscomp/test/sexp.js b/jscomp/test/sexp.js index 6f1601514f..3ad3c16eae 100644 --- a/jscomp/test/sexp.js +++ b/jscomp/test/sexp.js @@ -136,9 +136,7 @@ function of_field(name, t) { function of_record(l) { return { NAME: "List", - VAL: List.map((function (param) { - return of_field(param[0], param[1]); - }), l) + VAL: List.map(param => of_field(param[0], param[1]), l) }; } @@ -253,9 +251,7 @@ function to_float(e) { } function to_string(e) { - return _try_atom(e, (function (x) { - return x; - })); + return _try_atom(e, x => x); } function to_pair(e) { @@ -280,19 +276,13 @@ function to_pair(e) { } 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 [ - x, - y - ]; - })); - })); - })); - }; + return e => $great$great$eq(to_pair(e), param => { + let y = param[1]; + return $great$great$eq(f1(param[0]), x => $great$great$eq(f2(y), y => [ + x, + y + ])); + }); } function to_triple(e) { @@ -322,23 +312,15 @@ function to_triple(e) { } function to_triple_with(f1, f2, f3) { - return function (e) { - 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 [ - x, - y, - z - ]; - })); - })); - })); - })); - }; + return e => $great$great$eq(to_triple(e), param => { + let z = param[2]; + let y = param[1]; + return $great$great$eq(f1(param[0]), x => $great$great$eq(f2(y), y => $great$great$eq(f3(z), z => [ + x, + y, + z + ]))); + }); } function to_list(e) { @@ -349,7 +331,7 @@ function to_list(e) { } function to_list_with(f) { - return function (e) { + return e => { if (e.NAME === "List") { return map_opt(f, e.VAL); } @@ -358,7 +340,7 @@ function to_list_with(f) { } function get_field(name) { - return function (e) { + return e => { if (e.NAME === "List") { let _l = e.VAL; while (true) { @@ -410,9 +392,7 @@ function get_field(name) { } function field(name, f) { - return function (e) { - return $great$great$eq(get_field(name)(e), f); - }; + return e => $great$great$eq(get_field(name)(e), f); } function _get_field_list(name, _l) { @@ -453,7 +433,7 @@ function _get_field_list(name, _l) { } function field_list(name, f) { - return function (e) { + return e => { if (e.NAME === "List") { return $great$great$eq(_get_field_list(name, e.VAL), f); } @@ -477,7 +457,7 @@ function _get_variant(s, args, _l) { } function get_variant(l) { - return function (e) { + return e => { if (e.NAME !== "List") { return _get_variant(e.VAL, /* [] */0, l); } diff --git a/jscomp/test/sexpm.js b/jscomp/test/sexpm.js index bf9221f37e..ee81d710c7 100644 --- a/jscomp/test/sexpm.js +++ b/jscomp/test/sexpm.js @@ -96,12 +96,12 @@ function to_buf(b, t) { if (l) { if (l.tl) { Buffer.add_char(b, /* '(' */40); - List.iteri((function (i, t$p) { + List.iteri((i, t$p) => { if (i > 0) { Buffer.add_char(b, /* ' ' */32); } to_buf(b, t$p); - }), l); + }, l); return Buffer.add_char(b, /* ')' */41); } else { Buffer.add_string(b, "("); @@ -203,9 +203,7 @@ function _error_eof(t) { function expr(k, t) { while (true) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return expr(k, extra); - }), _error_eof); + return _refill(t, extra => expr(k, extra), _error_eof); } let c = _get(t); if (c >= 11) { @@ -224,9 +222,7 @@ function expr(k, t) { function expr_starting_with(c, k, t) { if (c >= 42) { if (c === 59) { - return skip_comment((function (param, param$1) { - return expr(k, t); - }), t); + return skip_comment((param, param$1) => expr(k, t), t); } if (c === 92) { return _error(t, "unexpected '\\'"); @@ -281,9 +277,7 @@ function expr_starting_with(c, k, t) { function expr_list(acc, k, t) { while (true) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return expr_list(acc, k, extra); - }), _error_eof); + return _refill(t, extra => expr_list(acc, k, extra), _error_eof); } let c = _get(t); if (c > 32 || c < 9) { @@ -297,7 +291,7 @@ function expr_list(acc, k, t) { } else if (c > 31 || c < 11) { continue; } - return expr_starting_with(c, (function (last, e) { + return expr_starting_with(c, (last, e) => { if (last !== undefined) { if (last !== 40) { if (last !== 41) { @@ -315,12 +309,10 @@ function expr_list(acc, k, t) { }); } } else { - return expr_list(/* [] */0, (function (param, l) { - return expr_list({ - hd: l, - tl: acc - }, k, t); - }), t); + return expr_list(/* [] */0, (param, l) => expr_list({ + hd: l, + tl: acc + }, k, t), t); } } else { return expr_list({ @@ -328,7 +320,7 @@ function expr_list(acc, k, t) { tl: acc }, k, t); } - }), t); + }, t); }; } @@ -344,11 +336,7 @@ function _return_atom(last, k, t) { function atom(k, t) { while (true) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return atom(k, extra); - }), (function (extra) { - return _return_atom(undefined, k, extra); - })); + return _refill(t, extra => atom(k, extra), extra => _return_atom(undefined, k, extra)); } let c = _get(t); let exit = 0; @@ -392,19 +380,17 @@ function atom(k, t) { function quoted(k, t) { while (true) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return quoted(k, extra); - }), _error_eof); + return _refill(t, extra => quoted(k, extra), _error_eof); } let c = _get(t); if (c === 34) { return _return_atom(undefined, k, t); } if (c === 92) { - return escaped((function (c) { + return escaped(c => { Buffer.add_char(t.atom, c); return quoted(k, t); - }), t); + }, t); } Buffer.add_char(t.atom, c); continue; @@ -413,9 +399,7 @@ function quoted(k, t) { function escaped(k, t) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return escaped(k, extra); - }), _error_eof); + return _refill(t, extra => escaped(k, extra), _error_eof); } let c = _get(t); if (c >= 92) { @@ -459,9 +443,7 @@ function escaped(k, t) { return k(/* '"' */34); } if (_is_digit(c)) { - return read2int(c - /* '0' */48 | 0, (function (n) { - return k(Char.chr(n)); - }), t); + return read2int(c - /* '0' */48 | 0, n => k(Char.chr(n)), t); } else { return _error(t, "unexpected escaped char '" + (c + "'")); } @@ -469,9 +451,7 @@ function escaped(k, t) { function read2int(i, k, t) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return read2int(i, k, extra); - }), _error_eof); + return _refill(t, extra => read2int(i, k, extra), _error_eof); } let c = _get(t); if (_is_digit(c)) { @@ -483,9 +463,7 @@ function read2int(i, k, t) { function read1int(i, k, t) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return read1int(i, k, extra); - }), _error_eof); + return _refill(t, extra => read1int(i, k, extra), _error_eof); } let c = _get(t); if (_is_digit(c)) { @@ -498,9 +476,7 @@ function read1int(i, k, t) { function skip_comment(k, t) { while (true) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return skip_comment(k, extra); - }), _error_eof); + return _refill(t, extra => skip_comment(k, extra), _error_eof); } let match = _get(t); if (match === 10) { @@ -513,11 +489,7 @@ function skip_comment(k, t) { function expr_or_end(k, t) { while (true) { if (t.i === t.len) { - return _refill(t, (function (extra) { - return expr_or_end(k, extra); - }), (function (param) { - return "End"; - })); + return _refill(t, extra => expr_or_end(k, extra), param => "End"); } let c = _get(t); if (c >= 11) { @@ -534,11 +506,9 @@ function expr_or_end(k, t) { } function next(t) { - return expr_or_end((function (param, x) { - return { - NAME: "Ok", - VAL: x - }; + return expr_or_end((param, x) => ({ + NAME: "Ok", + VAL: x }), t); } @@ -547,7 +517,7 @@ function parse_string(s) { let stop = { contents: false }; - let refill = function (bytes, i, _len) { + let refill = (bytes, i, _len) => { if (stop.contents) { return 0; } else { diff --git a/jscomp/test/sexpm_test.js b/jscomp/test/sexpm_test.js index 2183f46fb3..073a85ff9e 100644 --- a/jscomp/test/sexpm_test.js +++ b/jscomp/test/sexpm_test.js @@ -19,12 +19,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/side_effect2.js b/jscomp/test/side_effect2.js index cfedadb3f9..575c6b65a6 100644 --- a/jscomp/test/side_effect2.js +++ b/jscomp/test/side_effect2.js @@ -3,9 +3,7 @@ let Belt_Array = require("../../lib/js/belt_Array.js"); -let a = Belt_Array.map([1], (function (x) { - return x; -})); +let a = Belt_Array.map([1], x => x); exports.a = a; /* a Not a pure module */ diff --git a/jscomp/test/stack_comp_test.js b/jscomp/test/stack_comp_test.js index 915fafeb4c..e48789bbee 100644 --- a/jscomp/test/stack_comp_test.js +++ b/jscomp/test/stack_comp_test.js @@ -31,12 +31,12 @@ function to_list(s) { let l = { contents: /* [] */0 }; - List.iter((function (x) { + List.iter(x => { l.contents = { hd: x, tl: l.contents }; - }), s.c); + }, s.c); return l.contents; } @@ -358,10 +358,10 @@ let i$7 = { contents: 1 }; -List.iter((function (j) { +List.iter(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.c); +}, s$5.c); let s1$1 = { c: /* [] */0, diff --git a/jscomp/test/stack_test.js b/jscomp/test/stack_test.js index d6368ae6c8..2dc90165f6 100644 --- a/jscomp/test/stack_test.js +++ b/jscomp/test/stack_test.js @@ -29,21 +29,19 @@ function v() { let suites_0 = [ "push_test", - (function (param) { - return { - TAG: "Eq", - _0: { - hd: 1, + param => ({ + TAG: "Eq", + _0: { + hd: 1, + tl: { + hd: 4, tl: { - hd: 4, - tl: { - hd: 3, - tl: /* [] */0 - } + hd: 3, + tl: /* [] */0 } - }, - _1: v() - }; + } + }, + _1: v() }) ]; diff --git a/jscomp/test/stream_parser_test.js b/jscomp/test/stream_parser_test.js index c79f09df72..2c52c45039 100644 --- a/jscomp/test/stream_parser_test.js +++ b/jscomp/test/stream_parser_test.js @@ -16,7 +16,7 @@ function parse(token) { first: "Nil", last: "Nil" }; - let token$1 = function () { + let token$1 = () => { if (look_ahead.length !== 0) { return Queue.pop(look_ahead); } @@ -29,7 +29,7 @@ function parse(token) { }; } }; - let parse_atom = function () { + let parse_atom = () => { let n = token$1(); switch (n.TAG) { case "Kwd" : @@ -73,10 +73,8 @@ function parse(token) { }); } }; - let parse_term = function () { - return parse_term_aux(parse_atom()); - }; - let parse_expr_aux = function (e1) { + let parse_term = () => parse_term_aux(parse_atom()); + let parse_expr_aux = e1 => { let e = token$1(); if (e.TAG === "Kwd") { switch (e._0) { @@ -93,7 +91,7 @@ function parse(token) { return e1; } }; - let parse_term_aux = function (e1) { + let parse_term_aux = e1 => { let e = token$1(); if (e.TAG === "Kwd") { switch (e._0) { @@ -113,11 +111,9 @@ function parse(token) { let r = parse_expr_aux(parse_term()); return [ r, - Queue.fold((function (acc, x) { - return { - hd: x, - tl: acc - }; + Queue.fold((acc, x) => ({ + hd: x, + tl: acc }), /* [] */0, look_ahead) ]; } @@ -144,9 +140,7 @@ let lexer = Genlex.make_lexer({ function token(chars) { let strm = lexer(chars); - return function () { - return Stream.next(strm); - }; + return () => Stream.next(strm); } function l_parse(token) { @@ -155,7 +149,7 @@ function l_parse(token) { first: "Nil", last: "Nil" }; - let token$1 = function () { + let token$1 = () => { if (look_ahead.length !== 0) { return Queue.pop(look_ahead); } @@ -168,7 +162,7 @@ function l_parse(token) { }; } }; - let parse_f = function () { + let parse_f = () => { let i = token$1(); switch (i.TAG) { case "Kwd" : @@ -210,7 +204,7 @@ function l_parse(token) { }); } }; - let parse_f_aux = function (_a) { + let parse_f_aux = _a => { while (true) { let a = _a; let t = token$1(); @@ -232,7 +226,7 @@ function l_parse(token) { } }; }; - let parse_t_aux = function (_a) { + let parse_t_aux = _a => { while (true) { let a = _a; let t = token$1(); @@ -254,17 +248,13 @@ function l_parse(token) { } }; }; - let parse_t = function () { - return parse_f_aux(parse_f()); - }; + let parse_t = () => parse_f_aux(parse_f()); let r = parse_t_aux(parse_t()); return [ r, - Queue.fold((function (acc, x) { - return { - hd: x, - tl: acc - }; + Queue.fold((acc, x) => ({ + hd: x, + tl: acc }), /* [] */0, look_ahead) ]; } @@ -282,12 +272,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/string_get_set_test.js b/jscomp/test/string_get_set_test.js index c2281c7193..11516e7225 100644 --- a/jscomp/test/string_get_set_test.js +++ b/jscomp/test/string_get_set_test.js @@ -7,12 +7,10 @@ let Caml_string = require("../../lib/js/caml_string.js"); Mt.from_pair_suites("string_get_set_test.res", { hd: [ "File \"string_get_set_test.res\", line 4, characters 36-43", - (function () { - return { - TAG: "Eq", - _0: Caml_string.get("h", 0), - _1: /* 'h' */104 - }; + () => ({ + TAG: "Eq", + _0: Caml_string.get("h", 0), + _1: /* 'h' */104 }) ], tl: /* [] */0 diff --git a/jscomp/test/string_runtime_test.js b/jscomp/test/string_runtime_test.js index f63935b895..29e44751c3 100644 --- a/jscomp/test/string_runtime_test.js +++ b/jscomp/test/string_runtime_test.js @@ -9,29 +9,25 @@ let Caml_bytes = require("../../lib/js/caml_bytes.js"); let suites_0 = [ "?is_printable", - (function (param) { - return { - TAG: "Eq", - _0: Test_char.caml_is_printable(/* 'a' */97), - _1: true - }; + param => ({ + TAG: "Eq", + _0: Test_char.caml_is_printable(/* 'a' */97), + _1: true }) ]; let suites_1 = { hd: [ "?string_of_bytes", - (function (param) { - let match = List.split(List.map((function (x) { + param => { + let match = List.split(List.map(x => { let b = Caml_bytes.create(x); Bytes.fill(b, 0, x, /* 'c' */99); return [ Bytes.to_string(b), - Bytes.unsafe_to_string(Bytes.init(x, (function (param) { - return /* 'c' */99; - }))) + Bytes.unsafe_to_string(Bytes.init(x, param => /* 'c' */99)) ]; - }), { + }, { hd: 1000, tl: { hd: 1024, @@ -58,7 +54,7 @@ let suites_1 = { _0: match[0], _1: match[1] }; - }) + } ], tl: /* [] */0 }; diff --git a/jscomp/test/string_set.js b/jscomp/test/string_set.js index 437b01483c..75578cd7f2 100644 --- a/jscomp/test/string_set.js +++ b/jscomp/test/string_set.js @@ -272,9 +272,7 @@ function of_list(l) { } function of_array(l) { - return $$Array.fold_left((function (acc, x) { - return add(x, acc); - }), "Empty", l); + return $$Array.fold_left((acc, x) => add(x, acc), "Empty", l); } function invariant(t) { diff --git a/jscomp/test/string_set_test.js b/jscomp/test/string_set_test.js index b4c2594891..09ef35775c 100644 --- a/jscomp/test/string_set_test.js +++ b/jscomp/test/string_set_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/string_test.js b/jscomp/test/string_test.js index 7d8042cada..ecfd814856 100644 --- a/jscomp/test/string_test.js +++ b/jscomp/test/string_test.js @@ -56,7 +56,7 @@ function gg(x) { } function rev_split_by_char(c, s) { - let loop = function (i, l) { + let loop = (i, l) => { try { let i$p = $$String.index_from(s, i, c); let s$p = $$String.sub(s, i, i$p - i | 0); @@ -125,241 +125,203 @@ function xsplit(delim, s) { } function string_of_chars(x) { - let xs = List.map((function (prim) { - return String.fromCharCode(prim); - }), x); + let xs = List.map(prim => String.fromCharCode(prim), x); return $$Array.of_list(xs).join(""); } Mt.from_pair_suites("String_test", { hd: [ "mutliple switch", - (function () { - return { - TAG: "Eq", - _0: 9, - _1: ff("4") - }; + () => ({ + TAG: "Eq", + _0: 9, + _1: ff("4") }) ], tl: { hd: [ "int switch", - (function () { - return { - TAG: "Eq", - _0: 9, - _1: gg(4) - }; + () => ({ + TAG: "Eq", + _0: 9, + _1: gg(4) }) ], tl: { hd: [ "escape_normal", - (function () { - return { - TAG: "Eq", - _0: "haha", - _1: $$String.escaped("haha") - }; + () => ({ + TAG: "Eq", + _0: "haha", + _1: $$String.escaped("haha") }) ], tl: { hd: [ "escape_bytes", - (function () { - return { - TAG: "Eq", - _0: Bytes.of_string("haha"), - _1: Bytes.escaped(Bytes.of_string("haha")) - }; + () => ({ + TAG: "Eq", + _0: Bytes.of_string("haha"), + _1: Bytes.escaped(Bytes.of_string("haha")) }) ], tl: { hd: [ "escape_quote", - (function () { - return { - TAG: "Eq", - _0: "\\\"\\\"", - _1: $$String.escaped("\"\"") - }; + () => ({ + TAG: "Eq", + _0: "\\\"\\\"", + _1: $$String.escaped("\"\"") }) ], tl: { hd: [ "rev_split_by_char", - (function () { - return { - TAG: "Eq", - _0: { - hd: "", + () => ({ + TAG: "Eq", + _0: { + hd: "", + tl: { + hd: "bbbb", tl: { hd: "bbbb", - tl: { - hd: "bbbb", - tl: /* [] */0 - } + tl: /* [] */0 } - }, - _1: rev_split_by_char(/* 'a' */97, "bbbbabbbba") - }; + } + }, + _1: rev_split_by_char(/* 'a' */97, "bbbbabbbba") }) ], tl: { hd: [ "File \"string_test.res\", line 86, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: { - hd: "aaaa", - tl: /* [] */0 - }, - _1: rev_split_by_char(/* ',' */44, "aaaa") - }; + () => ({ + TAG: "Eq", + _0: { + hd: "aaaa", + tl: /* [] */0 + }, + _1: rev_split_by_char(/* ',' */44, "aaaa") }) ], tl: { hd: [ "xsplit", - (function () { - return { - TAG: "Eq", - _0: { - hd: "a", + () => ({ + TAG: "Eq", + _0: { + hd: "a", + tl: { + hd: "b", tl: { - hd: "b", - tl: { - hd: "c", - tl: /* [] */0 - } + hd: "c", + tl: /* [] */0 } - }, - _1: xsplit(/* '.' */46, "a.b.c") - }; + } + }, + _1: xsplit(/* '.' */46, "a.b.c") }) ], tl: { hd: [ "split_empty", - (function () { - return { - TAG: "Eq", - _0: /* [] */0, - _1: Ext_string_test.split(undefined, "", /* '_' */95) - }; + () => ({ + TAG: "Eq", + _0: /* [] */0, + _1: Ext_string_test.split(undefined, "", /* '_' */95) }) ], tl: { hd: [ "split_empty2", - (function () { - return { - TAG: "Eq", - _0: { - hd: "test_unsafe_obj_ffi_ppx.cmi", - tl: /* [] */0 - }, - _1: Ext_string_test.split(false, " test_unsafe_obj_ffi_ppx.cmi", /* ' ' */32) - }; + () => ({ + TAG: "Eq", + _0: { + hd: "test_unsafe_obj_ffi_ppx.cmi", + tl: /* [] */0 + }, + _1: Ext_string_test.split(false, " test_unsafe_obj_ffi_ppx.cmi", /* ' ' */32) }) ], tl: { hd: [ "rfind", - (function () { - return { - TAG: "Eq", - _0: 7, - _1: Ext_string_test.rfind("__", "__index__js") - }; + () => ({ + TAG: "Eq", + _0: 7, + _1: Ext_string_test.rfind("__", "__index__js") }) ], tl: { hd: [ "rfind_2", - (function () { - return { - TAG: "Eq", - _0: 0, - _1: Ext_string_test.rfind("__", "__index_js") - }; + () => ({ + TAG: "Eq", + _0: 0, + _1: Ext_string_test.rfind("__", "__index_js") }) ], tl: { hd: [ "rfind_3", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: Ext_string_test.rfind("__", "_index_js") - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: Ext_string_test.rfind("__", "_index_js") }) ], tl: { hd: [ "find", - (function () { - return { - TAG: "Eq", - _0: 0, - _1: Ext_string_test.find(undefined, "__", "__index__js") - }; + () => ({ + TAG: "Eq", + _0: 0, + _1: Ext_string_test.find(undefined, "__", "__index__js") }) ], tl: { hd: [ "find_2", - (function () { - return { - TAG: "Eq", - _0: 6, - _1: Ext_string_test.find(undefined, "__", "_index__js") - }; + () => ({ + TAG: "Eq", + _0: 6, + _1: Ext_string_test.find(undefined, "__", "_index__js") }) ], tl: { hd: [ "find_3", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: Ext_string_test.find(undefined, "__", "_index_js") - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: Ext_string_test.find(undefined, "__", "_index_js") }) ], tl: { hd: [ "of_char", - (function () { - return { - TAG: "Eq", - _0: String.fromCharCode(/* '0' */48), - _1: "0" - }; + () => ({ + TAG: "Eq", + _0: String.fromCharCode(/* '0' */48), + _1: "0" }) ], tl: { hd: [ "of_chars", - (function () { - return { - TAG: "Eq", - _0: string_of_chars({ - hd: /* '0' */48, + () => ({ + TAG: "Eq", + _0: string_of_chars({ + hd: /* '0' */48, + tl: { + hd: /* '1' */49, tl: { - hd: /* '1' */49, - tl: { - hd: /* '2' */50, - tl: /* [] */0 - } + hd: /* '2' */50, + tl: /* [] */0 } - }), - _1: "012" - }; + } + }), + _1: "012" }) ], tl: /* [] */0 diff --git a/jscomp/test/string_unicode_test.js b/jscomp/test/string_unicode_test.js index aadbe7c0f7..9f37cd91b2 100644 --- a/jscomp/test/string_unicode_test.js +++ b/jscomp/test/string_unicode_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/switch_case_test.js b/jscomp/test/switch_case_test.js index 6990bc227c..3dfead52d6 100644 --- a/jscomp/test/switch_case_test.js +++ b/jscomp/test/switch_case_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/tagged_template_test.js b/jscomp/test/tagged_template_test.js index 9fc3b9c2f4..f4537c3b6c 100644 --- a/jscomp/test/tagged_template_test.js +++ b/jscomp/test/tagged_template_test.js @@ -44,67 +44,55 @@ let res = foo([ Mt.from_pair_suites("tagged templates", { hd: [ "with externals, it should return a string with the correct interpolations", - (function () { - return { - TAG: "Eq", - _0: query, - _1: "SELECT * FROM 'users' WHERE id = '5'" - }; + () => ({ + TAG: "Eq", + _0: query, + _1: "SELECT * FROM 'users' WHERE id = '5'" }) ], tl: { hd: [ "with module scoped externals, it should also return a string with the correct interpolations", - (function () { - return { - TAG: "Eq", - _0: queryWithModule, - _1: "SELECT * FROM 'users' WHERE id = '5'" - }; + () => ({ + TAG: "Eq", + _0: queryWithModule, + _1: "SELECT * FROM 'users' WHERE id = '5'" }) ], tl: { hd: [ "with externals, it should return the result of the function", - (function () { - return { - TAG: "Eq", - _0: length, - _1: 52 - }; + () => ({ + TAG: "Eq", + _0: length, + _1: 52 }) ], tl: { hd: [ "with rescript function, it should return a string with the correct encoding and interpolations", - (function () { - return { - TAG: "Eq", - _0: res, - _1: "| 5 × 10 = 50 |" - }; + () => ({ + TAG: "Eq", + _0: res, + _1: "| 5 × 10 = 50 |" }) ], tl: { hd: [ "a template literal tagged with json should generate a regular string interpolation for now", - (function () { - return { - TAG: "Eq", - _0: "some random " + "string", - _1: "some random string" - }; + () => ({ + TAG: "Eq", + _0: "some random " + "string", + _1: "some random string" }) ], tl: { hd: [ "a regular string interpolation should continue working", - (function () { - return { - TAG: "Eq", - _0: "some random string interpolation", - _1: "some random string interpolation" - }; + () => ({ + TAG: "Eq", + _0: "some random string interpolation", + _1: "some random string interpolation" }) ], tl: /* [] */0 diff --git a/jscomp/test/tailcall_inline_test.js b/jscomp/test/tailcall_inline_test.js index c419a6d6b1..7308fc182e 100644 --- a/jscomp/test/tailcall_inline_test.js +++ b/jscomp/test/tailcall_inline_test.js @@ -6,7 +6,7 @@ let $$Array = require("../../lib/js/array.js"); let Caml_array = require("../../lib/js/caml_array.js"); function f() { - let f$1 = function (_acc, _n) { + let f$1 = (_acc, _n) => { while (true) { let n = _n; let acc = _acc; @@ -27,48 +27,44 @@ function f() { let suites_0 = [ "acc", - (function (param) { - return { - TAG: "Eq", - _0: f(), - _1: [ - 0, - 1, - 3, - 6, - 10, - 15, - 21, - 28, - 36, - 45 - ] - }; + param => ({ + TAG: "Eq", + _0: f(), + _1: [ + 0, + 1, + 3, + 6, + 10, + 15, + 21, + 28, + 36, + 45 + ] }) ]; let suites_1 = { hd: [ "array_to_list", - (function (param) { - return { - TAG: "Eq", - _0: { - hd: 1, + param => ({ + TAG: "Eq", + _0: { + hd: 1, + tl: { + hd: 2, tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } + hd: 3, + tl: /* [] */0 } - }, - _1: $$Array.to_list([ - 1, - 2, - 3 - ]) - }; + } + }, + _1: $$Array.to_list([ + 1, + 2, + 3 + ]) }) ], tl: /* [] */0 diff --git a/jscomp/test/test_bs_this.js b/jscomp/test/test_bs_this.js index a2890643aa..0edc78d137 100644 --- a/jscomp/test/test_bs_this.js +++ b/jscomp/test/test_bs_this.js @@ -27,22 +27,22 @@ function bark() { } let js_obj = { - bark: (function (x, y) { + bark: function (x, y) { let o = this ; console.log(o); return x + y | 0; - }) + } }; function f(x) { - x.onload = (function () { + x.onload = function () { let o = this ; console.log(o); - }); - return x.addEventListener("onload", (function () { + }; + return x.addEventListener("onload", function () { let o = this ; console.log(o.response); - })); + }); } function u(x) { diff --git a/jscomp/test/test_closure.js b/jscomp/test/test_closure.js index ebef4942f9..50cf48ad0a 100644 --- a/jscomp/test/test_closure.js +++ b/jscomp/test/test_closure.js @@ -9,22 +9,18 @@ let v = { }; function f() { - let arr = Caml_array.make(10, (function (param) { - - })); + let arr = Caml_array.make(10, param => {}); for (let i = 0; i <= 9; ++i) { - Caml_array.set(arr, i, (function (param) { + Caml_array.set(arr, i, param => { v.contents = v.contents + i | 0; - })); + }); } return arr; } let u = f(); -$$Array.iter((function (x) { - x(); -}), u); +$$Array.iter(x => x(), u); if (v.contents !== 45) { throw new Error("Assert_failure", { diff --git a/jscomp/test/test_cps.js b/jscomp/test/test_cps.js index 351f2d4edd..89fb5b1893 100644 --- a/jscomp/test/test_cps.js +++ b/jscomp/test/test_cps.js @@ -10,30 +10,24 @@ function f(_n, _acc) { if (n === 0) { return acc(); } - _acc = (function () { + _acc = () => { console.log(String(n)); return acc(); - }); + }; _n = n - 1 | 0; continue; }; } function test_closure() { - let arr = Caml_array.make(6, (function (x) { - return x; - })); + let arr = Caml_array.make(6, x => x); for (let i = 0; i <= 6; ++i) { - Caml_array.set(arr, i, (function (param) { - return i; - })); + Caml_array.set(arr, i, param => i); } return arr; } -f(10, (function () { - -})); +f(10, () => {}); exports.f = f; exports.test_closure = test_closure; diff --git a/jscomp/test/test_demo.js b/jscomp/test/test_demo.js index 4fb912cfb3..f3100bae74 100644 --- a/jscomp/test/test_demo.js +++ b/jscomp/test/test_demo.js @@ -45,16 +45,12 @@ function f(x, y, z) { function g(x, y) { let u = x + y | 0; - return function (z) { - return u + z | 0; - }; + return z => u + z | 0; } function g1(x, y) { let u = x + y | 0; - return function (xx, yy) { - return (xx + yy | 0) + u | 0; - }; + return (xx, yy) => (xx + yy | 0) + u | 0; } let u = 8; diff --git a/jscomp/test/test_for_loop.js b/jscomp/test/test_for_loop.js index 23a212f718..0f6d8cfd28 100644 --- a/jscomp/test/test_for_loop.js +++ b/jscomp/test/test_for_loop.js @@ -20,20 +20,14 @@ function for_3(x) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { let j = (i << 1); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + j | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -41,21 +35,15 @@ function for_4(x) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { let j = (i << 1); let k = (j << 1); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + k | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -63,20 +51,14 @@ function for_5(x, u) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { let k = Math.imul((u << 1), u); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + k | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -84,11 +66,7 @@ function for_6(x, u) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); let v4 = { contents: 0 }; @@ -105,14 +83,12 @@ function for_6(x, u) { let k = Math.imul((u << 1), u); let h = (v5.contents << 1); v2.contents = v2.contents + 1 | 0; - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = (((((v.contents + k | 0) + v2.contents | 0) + u | 0) + v4.contents | 0) + v5.contents | 0) + h | 0; - })); + }); } } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } diff --git a/jscomp/test/test_google_closure.js b/jscomp/test/test_google_closure.js index 55fd61de0f..7bcdc1a2f9 100644 --- a/jscomp/test/test_google_closure.js +++ b/jscomp/test/test_google_closure.js @@ -9,9 +9,7 @@ function f(a, b, param) { } function f2(a) { - return function (extra) { - return a + 1 | 0; - }; + return extra => a + 1 | 0; } let a = String(3); @@ -22,14 +20,10 @@ function f3(extra) { let b = f3(2); -let arr = $$Array.init(2, (function (param) { - return 0; -})); +let arr = $$Array.init(2, param => 0); for (let i = 0; i <= 1; ++i) { - let f3$1 = function (extra) { - return i + 1 | 0; - }; + let f3$1 = extra => i + 1 | 0; Caml_array.set(arr, i, f3$1(2)); } diff --git a/jscomp/test/test_int_map_find.js b/jscomp/test/test_int_map_find.js index b5de86fa27..8accca8abe 100644 --- a/jscomp/test/test_int_map_find.js +++ b/jscomp/test/test_int_map_find.js @@ -138,9 +138,7 @@ function add(x, data, param) { } } -List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 diff --git a/jscomp/test/test_list.js b/jscomp/test/test_list.js index 3f5818641f..c40fc0b557 100644 --- a/jscomp/test/test_list.js +++ b/jscomp/test/test_list.js @@ -584,7 +584,7 @@ function find(p, _x) { } function find_all(p) { - return function (__x) { + return __x => { let _accu = /* [] */0; let _x = __x; while (true) { @@ -740,7 +740,7 @@ function chop(_k, _l) { } function stable_sort(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -886,7 +886,7 @@ function stable_sort(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1041,7 +1041,7 @@ function stable_sort(cmp, l) { } function sort_uniq(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1272,7 +1272,7 @@ function sort_uniq(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; diff --git a/jscomp/test/test_react.js b/jscomp/test/test_react.js index 445d1d00ab..ef127b3487 100644 --- a/jscomp/test/test_react.js +++ b/jscomp/test/test_react.js @@ -11,11 +11,9 @@ let ReactDom = require("react-dom"); console.log(32); ReactDom.render(React.createClass({ - render: (function () { - return React.DOM.div({ - alt: "pic" - }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!"), React.DOM.h3(undefined, "type safe!")); - }) + render: () => React.DOM.div({ + alt: "pic" + }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!"), React.DOM.h3(undefined, "type safe!")) }), document.getElementById("hi")); function f() { diff --git a/jscomp/test/test_set.js b/jscomp/test/test_set.js index a8fbcc1f3f..ff3dca7cfa 100644 --- a/jscomp/test/test_set.js +++ b/jscomp/test/test_set.js @@ -4,14 +4,14 @@ let List = require("../../lib/js/list.js"); function Make(Ord) { - let height = function (x) { + let height = x => { if (typeof x !== "object") { return 0; } else { return x._3; } }; - let create = function (l, v, r) { + let create = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l._3; let hr; @@ -24,7 +24,7 @@ function Make(Ord) { _3: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let bal = function (l, v, r) { + let bal = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l._3; let hr; @@ -87,7 +87,7 @@ function Make(Ord) { } }); }; - let add = function (x, x_) { + let add = (x, x_) => { if (typeof x_ !== "object") { return { TAG: "Node", @@ -109,30 +109,28 @@ function Make(Ord) { return bal(l, v, add(x, r)); } }; - let singleton = function (x) { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: "Empty", - _3: 1 - }; - }; - let add_min_element = function (v, x) { + let singleton = x => ({ + TAG: "Node", + _0: "Empty", + _1: x, + _2: "Empty", + _3: 1 + }); + let add_min_element = (v, x) => { if (typeof x !== "object") { return singleton(v); } else { return bal(add_min_element(v, x._0), x._1, x._2); } }; - let add_max_element = function (v, x) { + let add_max_element = (v, x) => { if (typeof x !== "object") { return singleton(v); } else { return bal(x._0, x._1, add_max_element(v, x._2)); } }; - let join = function (l, v, r) { + let join = (l, v, r) => { if (typeof l !== "object") { return add_min_element(v, r); } @@ -149,7 +147,7 @@ function Make(Ord) { return create(l, v, r); } }; - let min_elt = function (_x) { + let min_elt = _x => { while (true) { let x = _x; if (typeof x !== "object") { @@ -167,7 +165,7 @@ function Make(Ord) { continue; }; }; - let max_elt = function (_x) { + let max_elt = _x => { while (true) { let x = _x; if (typeof x !== "object") { @@ -185,7 +183,7 @@ function Make(Ord) { continue; }; }; - let remove_min_elt = function (x) { + let remove_min_elt = x => { if (typeof x !== "object") { throw new Error("Invalid_argument", { cause: { @@ -201,7 +199,7 @@ function Make(Ord) { return bal(remove_min_elt(l), x._1, x._2); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -210,7 +208,7 @@ function Make(Ord) { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -219,7 +217,7 @@ function Make(Ord) { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; - let split = function (x, x_) { + let split = (x, x_) => { if (typeof x_ !== "object") { return [ "Empty", @@ -253,14 +251,14 @@ function Make(Ord) { match$1[2] ]; }; - let is_empty = function (x) { + let is_empty = x => { if (typeof x !== "object") { return true; } else { return false; } }; - let mem = function (x, _x_) { + let mem = (x, _x_) => { while (true) { let x_ = _x_; if (typeof x_ !== "object") { @@ -274,7 +272,7 @@ function Make(Ord) { continue; }; }; - let remove = function (x, x_) { + let remove = (x, x_) => { if (typeof x_ !== "object") { return "Empty"; } @@ -290,7 +288,7 @@ function Make(Ord) { return bal(l, v, remove(x, r)); } }; - let union = function (s1, s2) { + let union = (s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -314,7 +312,7 @@ function Make(Ord) { let match$1 = split(v2, s1); return join(union(match$1[0], s2._0), v2, union(match$1[2], s2._2)); }; - let inter = function (s1, s2) { + let inter = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -332,7 +330,7 @@ function Make(Ord) { return concat(inter(l1, l2), inter(r1, match[2])); } }; - let diff = function (s1, s2) { + let diff = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -350,7 +348,7 @@ function Make(Ord) { return join(diff(l1, l2), v1, diff(r1, match[2])); } }; - let cons_enum = function (_s, _e) { + let cons_enum = (_s, _e) => { while (true) { let e = _e; let s = _s; @@ -367,7 +365,7 @@ function Make(Ord) { continue; }; }; - let compare_aux = function (_e1, _e2) { + let compare_aux = (_e1, _e2) => { while (true) { let e2 = _e2; let e1 = _e1; @@ -390,13 +388,9 @@ function Make(Ord) { continue; }; }; - let compare = function (s1, s2) { - return compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); - }; - let equal = function (s1, s2) { - return compare(s1, s2) === 0; - }; - let subset = function (_s1, _s2) { + let compare = (s1, s2) => compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { while (true) { let s2 = _s2; let s1 = _s1; @@ -446,7 +440,7 @@ function Make(Ord) { continue; }; }; - let iter = function (f, _x_) { + let iter = (f, _x_) => { while (true) { let x_ = _x_; if (typeof x_ !== "object") { @@ -458,7 +452,7 @@ function Make(Ord) { continue; }; }; - let fold = function (f, _s, _accu) { + let fold = (f, _s, _accu) => { while (true) { let accu = _accu; let s = _s; @@ -470,7 +464,7 @@ function Make(Ord) { continue; }; }; - let for_all = function (p, _x) { + let for_all = (p, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -486,7 +480,7 @@ function Make(Ord) { continue; }; }; - let exists = function (p, _x) { + let exists = (p, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -502,7 +496,7 @@ function Make(Ord) { continue; }; }; - let filter = function (p, x) { + let filter = (p, x) => { if (typeof x !== "object") { return "Empty"; } @@ -516,7 +510,7 @@ function Make(Ord) { return concat(l$p, r$p); } }; - let partition = function (p, x) { + let partition = (p, x) => { if (typeof x !== "object") { return [ "Empty", @@ -543,14 +537,14 @@ function Make(Ord) { ]; } }; - let cardinal = function (x) { + let cardinal = x => { if (typeof x !== "object") { return 0; } else { return (cardinal(x._0) + 1 | 0) + cardinal(x._2) | 0; } }; - let elements_aux = function (_accu, _x) { + let elements_aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -565,10 +559,8 @@ function Make(Ord) { continue; }; }; - let elements = function (s) { - return elements_aux(/* [] */0, s); - }; - let find = function (x, _x_) { + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _x_) => { while (true) { let x_ = _x_; if (typeof x_ !== "object") { @@ -587,8 +579,8 @@ function Make(Ord) { continue; }; }; - let of_sorted_list = function (l) { - let sub = function (n, l) { + let of_sorted_list = l => { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -691,7 +683,7 @@ function Make(Ord) { }; return sub(List.length(l), l)[0]; }; - let of_list = function (l) { + let of_list = l => { if (!l) { return "Empty"; } diff --git a/jscomp/test/test_string_map.js b/jscomp/test/test_string_map.js index b8bc888cf3..21d8f1df73 100644 --- a/jscomp/test/test_string_map.js +++ b/jscomp/test/test_string_map.js @@ -166,16 +166,16 @@ function assertion_test() { let m = { contents: "Empty" }; - timing("building", (function () { + timing("building", () => { for (let i = 0; i <= 1000000; ++i) { m.contents = add(String(i), String(i), m.contents); } - })); - timing("querying", (function () { + }); + timing("querying", () => { for (let i = 0; i <= 1000000; ++i) { find(String(i), m.contents); } - })); + }); } exports.assertion_test = assertion_test; diff --git a/jscomp/test/test_while_closure.js b/jscomp/test/test_while_closure.js index 1378a7ded1..7235c903b0 100644 --- a/jscomp/test/test_while_closure.js +++ b/jscomp/test/test_while_closure.js @@ -8,26 +8,22 @@ let v = { contents: 0 }; -let arr = Caml_array.make(10, (function () { - -})); +let arr = Caml_array.make(10, () => {}); function f() { let n = 0; while (n < 10) { let j = n; - Caml_array.set(arr, j, (function () { + Caml_array.set(arr, j, () => { v.contents = v.contents + j | 0; - })); + }); n = n + 1 | 0; }; } f(); -$$Array.iter((function (x) { - x(); -}), arr); +$$Array.iter(x => x(), arr); console.log(String(v.contents)); diff --git a/jscomp/test/test_while_side_effect.js b/jscomp/test/test_while_side_effect.js index 10dcf19579..abea782887 100644 --- a/jscomp/test/test_while_side_effect.js +++ b/jscomp/test/test_while_side_effect.js @@ -22,7 +22,7 @@ let x = { contents: 3 }; -while ((function () { +while ((() => { let y = 3; console.log(String(x.contents)); y = y + 1 | 0; diff --git a/jscomp/test/test_zero_nullable.js b/jscomp/test/test_zero_nullable.js index 72737d80b0..cdb2f1b2a5 100644 --- a/jscomp/test/test_zero_nullable.js +++ b/jscomp/test/test_zero_nullable.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/ticker.js b/jscomp/test/ticker.js index adb9217fd2..8f8c2e3a23 100644 --- a/jscomp/test/ticker.js +++ b/jscomp/test/ticker.js @@ -80,19 +80,17 @@ function string_of_rank(x) { } function find_ticker_by_name(all_tickers, ticker) { - return List.find((function (param) { - return param.ticker_name === ticker; - }), all_tickers); + return List.find(param => param.ticker_name === ticker, all_tickers); } function print_all_composite(all_tickers) { - List.iter((function (x) { + List.iter(x => { let tmp = x.type_; if (typeof tmp !== "object") { return; } console.log(x.ticker_name); - }), all_tickers); + }, all_tickers); } function height(param) { @@ -1090,8 +1088,8 @@ let Ticker_map = { }; function compute_update_sequences(all_tickers) { - List.fold_left((function (counter, ticker) { - let loop = function (counter, ticker) { + List.fold_left((counter, ticker) => { + let loop = (counter, ticker) => { let rank = ticker.rank; if (typeof rank === "object") { return counter; @@ -1120,8 +1118,8 @@ function compute_update_sequences(all_tickers) { return counter$4; }; return loop(counter, ticker); - }), 0, all_tickers); - let map = List.fold_left((function (map, ticker) { + }, 0, all_tickers); + let map = List.fold_left((map, ticker) => { let tmp = ticker.type_; if (typeof tmp !== "object") { return add(ticker.ticker_name, { @@ -1129,7 +1127,7 @@ function compute_update_sequences(all_tickers) { tl: /* [] */0 }, map); } - let loop = function (_up, _map, _ticker) { + let loop = (_up, _map, _ticker) => { while (true) { let ticker = _ticker; let map = _map; @@ -1155,9 +1153,9 @@ function compute_update_sequences(all_tickers) { }; }; return loop(/* [] */0, map, ticker); - }), "Empty", List.rev(all_tickers)); - return fold((function (k, l, map) { - let l$1 = List.sort_uniq((function (lhs, rhs) { + }, "Empty", List.rev(all_tickers)); + return fold((k, l, map) => { + let l$1 = List.sort_uniq((lhs, rhs) => { let x = lhs.rank; if (typeof x !== "object") { if (x === "Uninitialized") { @@ -1194,14 +1192,14 @@ function compute_update_sequences(all_tickers) { } }); } - }), l); + }, l); return add(k, l$1, map); - }), map, map); + }, map, map); } function process_quote(ticker_map, new_ticker, new_value) { let update_sequence = find(new_ticker, ticker_map); - List.iter((function (ticker) { + List.iter(ticker => { let match = ticker.type_; if (typeof match !== "object") { if (ticker.ticker_name === new_ticker) { @@ -1222,11 +1220,11 @@ function process_quote(ticker_map, new_ticker, new_value) { match$1.op === "PLUS" ? match$2 + match$3 : match$2 - match$3 ) : undefined; ticker.value = value; - }), update_sequence); + }, update_sequence); } function process_input_line(ticker_map, all_tickers, line) { - let make_binary_op = function (ticker_name, lhs, rhs, op) { + let make_binary_op = (ticker_name, lhs, rhs, op) => { let lhs$1 = find_ticker_by_name(all_tickers, lhs); let rhs$1 = find_ticker_by_name(all_tickers, rhs); return { diff --git a/jscomp/test/to_string_test.js b/jscomp/test/to_string_test.js index 1e2099db17..3d3f92b325 100644 --- a/jscomp/test/to_string_test.js +++ b/jscomp/test/to_string_test.js @@ -13,23 +13,19 @@ function f(v) { Mt.from_pair_suites("To_string_test", { hd: [ "File \"to_string_test.res\", line 6, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Pervasives.string_of_float(Pervasives.infinity), - _1: "inf" - }; + () => ({ + TAG: "Eq", + _0: Pervasives.string_of_float(Pervasives.infinity), + _1: "inf" }) ], tl: { hd: [ "File \"to_string_test.res\", line 6, characters 49-56", - (function () { - return { - TAG: "Eq", - _0: Pervasives.string_of_float(Pervasives.neg_infinity), - _1: "-inf" - }; + () => ({ + TAG: "Eq", + _0: Pervasives.string_of_float(Pervasives.neg_infinity), + _1: "-inf" }) ], tl: /* [] */0 diff --git a/jscomp/test/topsort_test.js b/jscomp/test/topsort_test.js index c1af12c84e..286b48e805 100644 --- a/jscomp/test/topsort_test.js +++ b/jscomp/test/topsort_test.js @@ -61,7 +61,7 @@ let graph = { }; function nexts(x, g) { - return List.fold_left((function (acc, param) { + return List.fold_left((acc, param) => { if (param[0] === x) { return { hd: param[1], @@ -70,7 +70,7 @@ function nexts(x, g) { } else { return acc; } - }), /* [] */0, g); + }, /* [] */0, g); } function dfs1(_nodes, graph, _visited) { @@ -173,7 +173,7 @@ if (!Caml_obj.equal(dfs1({ } function dfs2(nodes, graph, visited) { - let aux = function (_nodes, graph, _visited) { + let aux = (_nodes, graph, _visited) => { while (true) { let visited = _visited; let nodes = _nodes; @@ -275,21 +275,17 @@ function dfs3(nodes, graph) { let visited = { contents: /* [] */0 }; - let aux = function (node, graph) { + let aux = (node, graph) => { if (!List.mem(node, visited.contents)) { visited.contents = { hd: node, tl: visited.contents }; - return List.iter((function (x) { - aux(x, graph); - }), nexts(node, graph)); + return List.iter(x => aux(x, graph), nexts(node, graph)); } }; - List.iter((function (node) { - aux(node, graph); - }), nodes); + List.iter(node => aux(node, graph), nodes); return List.rev(visited.contents); } @@ -409,7 +405,7 @@ function unsafe_topsort(graph) { let visited = { contents: /* [] */0 }; - let sort_node = function (node) { + let sort_node = node => { if (List.mem(node, visited.contents)) { return; } @@ -420,9 +416,7 @@ function unsafe_topsort(graph) { tl: visited.contents }; }; - List.iter((function (param) { - sort_node(param[0]); - }), graph); + List.iter(param => sort_node(param[0]), graph); return visited.contents; } @@ -1316,7 +1310,7 @@ function of_list(l) { if (match$3) { if (match$3.tl) { let l$1 = List.sort_uniq($$String.compare, l); - let sub = function (n, l) { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -1474,7 +1468,7 @@ function pathsort(graph) { "Empty", /* [] */0 ]; - let $plus$great = function (node, param) { + let $plus$great = (node, param) => { let stack = param[1]; let set = param[0]; if (mem(node, set)) { @@ -1496,12 +1490,8 @@ function pathsort(graph) { } ]; }; - let sort_nodes = function (path, nodes) { - List.iter((function (node) { - sort_node(path, node); - }), nodes); - }; - let sort_node = function (path, node) { + let sort_nodes = (path, nodes) => List.iter(node => sort_node(path, node), nodes); + let sort_node = (path, node) => { if (!List.mem(node, visited.contents)) { sort_nodes($plus$great(node, path), nexts(node, graph)); visited.contents = { @@ -1512,9 +1502,7 @@ function pathsort(graph) { } }; - List.iter((function (param) { - sort_node(empty_path, param[0]); - }), graph); + List.iter(param => sort_node(empty_path, param[0]), graph); return visited.contents; } diff --git a/jscomp/test/tramp_fib.js b/jscomp/test/tramp_fib.js index 1f9cd58ab4..e1b4d77b91 100644 --- a/jscomp/test/tramp_fib.js +++ b/jscomp/test/tramp_fib.js @@ -21,22 +21,14 @@ function fib(n, k) { } 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); - })); - })); - }) + _0: () => fib(n - 1 | 0, v0 => fib(n - 2 | 0, v1 => k(v0 + v1 | 0))) }; } } -let u = fib(10, (function (x) { - return { - TAG: "Continue", - _0: x - }; +let u = fib(10, x => ({ + TAG: "Continue", + _0: x })); function iter(_bounce) { @@ -55,9 +47,7 @@ function isEven(n) { if (n !== 1) { return { TAG: "Suspend", - _0: (function () { - return isOdd(n - 1 | 0); - }) + _0: () => isOdd(n - 1 | 0) }; } else { return { diff --git a/jscomp/test/tuple_alloc.js b/jscomp/test/tuple_alloc.js index 412bddc78b..2e63775eeb 100644 --- a/jscomp/test/tuple_alloc.js +++ b/jscomp/test/tuple_alloc.js @@ -39,9 +39,7 @@ function kf(cb, v) { } function ikf(v) { - return kf((function (prim) { - - }), v); + return kf(prim => {}, v); } exports.v = v; diff --git a/jscomp/test/typeof_test.js b/jscomp/test/typeof_test.js index ea671ac58b..3fd9ae2998 100644 --- a/jscomp/test/typeof_test.js +++ b/jscomp/test/typeof_test.js @@ -33,140 +33,112 @@ function string_or_number(x) { let suites_0 = [ "int_type", - (function (param) { - return { - TAG: "Eq", - _0: "number", - _1: "number" - }; + param => ({ + TAG: "Eq", + _0: "number", + _1: "number" }) ]; let suites_1 = { hd: [ "string_type", - (function (param) { - return { - TAG: "Eq", - _0: "string", - _1: "string" - }; + param => ({ + TAG: "Eq", + _0: "string", + _1: "string" }) ], tl: { hd: [ "number_gadt_test", - (function (param) { - return { - TAG: "Eq", - _0: Js_types.test(3, "Number"), - _1: true - }; + param => ({ + TAG: "Eq", + _0: Js_types.test(3, "Number"), + _1: true }) ], tl: { hd: [ "boolean_gadt_test", - (function (param) { - return { - TAG: "Eq", - _0: Js_types.test(true, "Boolean"), - _1: true - }; + param => ({ + TAG: "Eq", + _0: Js_types.test(true, "Boolean"), + _1: true }) ], tl: { hd: [ "undefined_gadt_test", - (function (param) { - return { - TAG: "Eq", - _0: Js_types.test(undefined, "Undefined"), - _1: true - }; + param => ({ + TAG: "Eq", + _0: Js_types.test(undefined, "Undefined"), + _1: true }) ], tl: { hd: [ "string_on_number1", - (function (param) { - return { - TAG: "Eq", - _0: string_or_number("xx"), - _1: true - }; + param => ({ + TAG: "Eq", + _0: string_or_number("xx"), + _1: true }) ], tl: { hd: [ "string_on_number2", - (function (param) { - return { - TAG: "Eq", - _0: string_or_number(3.02), - _1: true - }; + param => ({ + TAG: "Eq", + _0: string_or_number(3.02), + _1: true }) ], tl: { hd: [ "string_on_number3", - (function (param) { - return { - TAG: "Eq", - _0: string_or_number(function (x) { - return x; - }), - _1: false - }; + param => ({ + TAG: "Eq", + _0: string_or_number(x => x), + _1: false }) ], tl: { hd: [ "string_gadt_test", - (function (param) { - return { - TAG: "Eq", - _0: Js_types.test("3", "String"), - _1: true - }; + param => ({ + TAG: "Eq", + _0: Js_types.test("3", "String"), + _1: true }) ], tl: { hd: [ "string_gadt_test_neg", - (function (param) { - return { - TAG: "Eq", - _0: Js_types.test(3, "String"), - _1: false - }; + param => ({ + TAG: "Eq", + _0: Js_types.test(3, "String"), + _1: false }) ], tl: { hd: [ "function_gadt_test", - (function (param) { - return { - TAG: "Eq", - _0: Js_types.test((function (x) { - return x; - }), "Function"), - _1: true - }; + param => ({ + TAG: "Eq", + _0: Js_types.test(x => x, "Function"), + _1: true }) ], tl: { hd: [ "object_gadt_test", - (function (param) { - return { - TAG: "Eq", - _0: Js_types.test({ - x: 3 - }, "Object"), - _1: true - }; + param => ({ + TAG: "Eq", + _0: Js_types.test({ + x: 3 + }, "Object"), + _1: true }) ], tl: /* [] */0 diff --git a/jscomp/test/uncurried_cast.js b/jscomp/test/uncurried_cast.js index 7eff9f3f97..5ed7b4c208 100644 --- a/jscomp/test/uncurried_cast.js +++ b/jscomp/test/uncurried_cast.js @@ -37,9 +37,7 @@ let l = Belt_List.map({ hd: 2, tl: /* [] */0 } -}, (function (x) { - return x + 1 | 0; -})); +}, x => x + 1 | 0); function partial(x) { return Belt_List.map({ @@ -51,9 +49,7 @@ function partial(x) { }, x); } -let ll = partial(function (x) { - return x + 1 | 0; -}); +let ll = partial(x => x + 1 | 0); function withOpts(xOpt, y, zOpt, w) { let x = xOpt !== undefined ? xOpt : 3; @@ -83,9 +79,7 @@ let l$1 = Belt_List.map({ hd: 2, tl: /* [] */0 } -}, (function (x) { - return x + 1 | 0; -})); +}, x => x + 1 | 0); function partial$1(extra) { return Belt_List.map({ @@ -97,9 +91,7 @@ function partial$1(extra) { }, extra); } -let ll$1 = partial$1(function (x) { - return x + 1 | 0; -}); +let ll$1 = partial$1(x => x + 1 | 0); function withOpts$1(xOpt, y, zOpt, w) { let x = xOpt !== undefined ? xOpt : 3; diff --git a/jscomp/test/uncurried_default.args.js b/jscomp/test/uncurried_default.args.js index 21822c00fe..3cf995aa9b 100644 --- a/jscomp/test/uncurried_default.args.js +++ b/jscomp/test/uncurried_default.args.js @@ -4,7 +4,7 @@ function withOpt(xOpt, y) { let x = xOpt !== undefined ? xOpt : 1; - return function (zOpt, w) { + return (zOpt, w) => { let z = zOpt !== undefined ? zOpt : 1; return ((x + y | 0) + z | 0) + w | 0; }; @@ -56,7 +56,7 @@ let StandardNotation = { function withOpt$1(xOpt, y) { let x = xOpt !== undefined ? xOpt : 1; - return function (zOpt, w) { + return (zOpt, w) => { let z = zOpt !== undefined ? zOpt : 1; return ((x + y | 0) + z | 0) + w | 0; }; diff --git a/jscomp/test/uncurry_external_test.js b/jscomp/test/uncurry_external_test.js index 85094358a6..cb3e10f486 100644 --- a/jscomp/test/uncurry_external_test.js +++ b/jscomp/test/uncurry_external_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/unit_undefined_test.js b/jscomp/test/unit_undefined_test.js index 255d5ff4c1..6c5ea46ed6 100644 --- a/jscomp/test/unit_undefined_test.js +++ b/jscomp/test/unit_undefined_test.js @@ -17,7 +17,7 @@ function eq(loc, x, y) { } function f_01() { - return hi(function (x) { + return hi(x => { if (x === undefined) { console.log("x"); return; diff --git a/jscomp/test/unsafe_ppx_test.js b/jscomp/test/unsafe_ppx_test.js index f0e9d4a747..df95ed722f 100644 --- a/jscomp/test/unsafe_ppx_test.js +++ b/jscomp/test/unsafe_ppx_test.js @@ -26,9 +26,7 @@ function g(a) { regression(a, Pervasives.failwith); regression2(3, 2); regression3(3, 2); - regression4(3, (function (x) { - return x; - })); + regression4(3, x => x); } let max2 = Math.max; @@ -54,45 +52,37 @@ let v = $$test(1, 2); Mt.from_pair_suites("Unsafe_ppx_test", { hd: [ "unsafe_max", - (function () { - return { - TAG: "Eq", - _0: 2, - _1: max(1, 2) - }; + () => ({ + TAG: "Eq", + _0: 2, + _1: max(1, 2) }) ], tl: { hd: [ "unsafe_test", - (function () { - return { - TAG: "Eq", - _0: 3, - _1: v - }; + () => ({ + TAG: "Eq", + _0: 3, + _1: v }) ], tl: { hd: [ "unsafe_max2", - (function () { - return { - TAG: "Eq", - _0: 2, - _1: Math.max(1, 2) - }; + () => ({ + TAG: "Eq", + _0: 2, + _1: Math.max(1, 2) }) ], tl: { hd: [ "ffi_keys", - (function () { - return { - TAG: "Eq", - _0: ["a"], - _1: Ffi_js_test.keys({a : 3}) - }; + () => ({ + TAG: "Eq", + _0: ["a"], + _1: Ffi_js_test.keys({a : 3}) }) ], tl: /* [] */0 diff --git a/jscomp/test/update_record_test.js b/jscomp/test/update_record_test.js index c81dfc91d6..075e04543b 100644 --- a/jscomp/test/update_record_test.js +++ b/jscomp/test/update_record_test.js @@ -21,12 +21,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/variant.js b/jscomp/test/variant.js index d288abaca6..d184ff6061 100644 --- a/jscomp/test/variant.js +++ b/jscomp/test/variant.js @@ -63,9 +63,7 @@ let Path = { }; function Make(M) { - let find = function (x) { - - }; + let find = x => {}; return { find: find }; diff --git a/jscomp/test/webpack_config.js b/jscomp/test/webpack_config.js index 132cb37835..dacb56068a 100644 --- a/jscomp/test/webpack_config.js +++ b/jscomp/test/webpack_config.js @@ -39,18 +39,18 @@ let B = {}; function f() { return [ - (function (prim) { + prim => { List$3.ff(); - }), - (function (prim) { + }, + prim => { List$3.ff2(); - }), - (function (prim) { + }, + prim => { List$2.ff(); - }), - (function (prim) { + }, + prim => { List$2.ff2(); - }) + } ]; } diff --git a/lib/es6/arg.js b/lib/es6/arg.js index bd24d4e8e7..865ef5a72a 100644 --- a/lib/es6/arg.js +++ b/lib/es6/arg.js @@ -50,9 +50,7 @@ function split(s) { function make_symlist(prefix, sep, suffix, l) { if (l) { - return List.fold_left((function (x, y) { - return x + (sep + y); - }), prefix + l.hd, l.tl) + suffix; + return List.fold_left((x, y) => x + (sep + y), prefix + l.hd, l.tl) + suffix; } else { return ""; } @@ -124,7 +122,7 @@ function add_help(speclist) { function usage_b(buf, speclist, errmsg) { Buffer.add_string(buf, errmsg + "\n"); - List.iter((function (x) { + List.iter(x => { let doc = x[2]; if (doc.length === 0) { return; @@ -136,7 +134,7 @@ function usage_b(buf, speclist, errmsg) { } let sym = make_symlist("{", "|", "}", spec._0); Buffer.add_string(buf, " " + key + " " + sym + doc + "\n"); - }), add_help(speclist)); + }, add_help(speclist)); } function usage_string(speclist, errmsg) { @@ -197,7 +195,7 @@ function float_of_string_opt(x) { function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist, anonfun, errmsg) { let initpos = current.contents; - let convert_error = function (error) { + let convert_error = error => { let b = Buffer.create(200); let progname = initpos < argv.contents.length ? Caml_array.get(argv.contents, initpos) : "(?)"; switch (error.TAG) { @@ -284,7 +282,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist } } let follow = match[1]; - let no_arg = function () { + let no_arg = () => { if (follow === undefined) { return; } @@ -300,7 +298,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist } }); }; - let get_arg = function () { + let get_arg = () => { if (follow !== undefined) { return follow; } @@ -317,7 +315,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist } }); }; - let consume_arg = function () { + let consume_arg = () => { if (follow !== undefined) { return; } else { @@ -325,7 +323,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist return; } }; - let treat_action = function (f) { + let treat_action = f => { switch (f.TAG) { case "Unit" : return f._0(); @@ -609,7 +607,7 @@ function parse_expand(l, f, msg) { function second_word(s) { let len = s.length; - let loop = function (_n) { + let loop = _n => { while (true) { let n = _n; if (n >= len) { @@ -668,14 +666,14 @@ function replace_leading_tab(s) { let seen = { contents: false }; - return $$String.map((function (c) { + return $$String.map(c => { if (c !== 9 || seen.contents) { return c; } else { seen.contents = true; return /* ' ' */32; } - }), s); + }, s); } function align(limitOpt, speclist) { @@ -683,7 +681,7 @@ function align(limitOpt, speclist) { let completed = add_help(speclist); let len = List.fold_left(max_arg_len, 0, completed); let len$1 = len < limit ? len : limit; - return List.map((function (x) { + return List.map(x => { let spec = x[1]; let kwd = x[0]; if (x[2] === "") { @@ -718,7 +716,7 @@ function align(limitOpt, speclist) { spec, prefix + (spaces$1 + suffix) ]; - }), completed); + }, completed); } export { diff --git a/lib/es6/array.js b/lib/es6/array.js index badec4a0e5..e53c2c06d2 100644 --- a/lib/es6/array.js +++ b/lib/es6/array.js @@ -299,7 +299,7 @@ function memq(x, a) { let Bottom = /* @__PURE__ */Caml_exceptions.create("Array.Bottom"); function sort(cmp, a) { - let maxson = function (l, i) { + let maxson = (l, i) => { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { @@ -324,7 +324,7 @@ function sort(cmp, a) { } }); }; - let trickle = function (l, i, e) { + let trickle = (l, i, e) => { try { let _i = i; while (true) { @@ -347,7 +347,7 @@ function sort(cmp, a) { }); } }; - let bubble = function (l, i) { + let bubble = (l, i) => { try { let _i = i; while (true) { @@ -367,7 +367,7 @@ function sort(cmp, a) { }); } }; - let trickleup = function (_i, e) { + let trickleup = (_i, e) => { while (true) { let i = _i; let father = (i - 1 | 0) / 3 | 0; @@ -412,7 +412,7 @@ function sort(cmp, a) { } function stable_sort(cmp, a) { - let merge = function (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { let src1r = src1ofs + src1len | 0; let src2r = src2ofs + src2len | 0; let _i1 = src1ofs; @@ -448,7 +448,7 @@ function stable_sort(cmp, a) { continue; }; }; - let isortto = function (srcofs, dst, dstofs, len) { + let isortto = (srcofs, dst, dstofs, len) => { for (let i = 0; i < len; ++i) { let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; @@ -459,7 +459,7 @@ function stable_sort(cmp, a) { Caml_array.set(dst, j + 1 | 0, e); } }; - let sortto = function (srcofs, dst, dstofs, len) { + let sortto = (srcofs, dst, dstofs, len) => { if (len <= 5) { return isortto(srcofs, dst, dstofs, len); } diff --git a/lib/es6/arrayLabels.js b/lib/es6/arrayLabels.js index db8c5e22db..4952c602c5 100644 --- a/lib/es6/arrayLabels.js +++ b/lib/es6/arrayLabels.js @@ -299,7 +299,7 @@ function memq(x, a) { let Bottom = /* @__PURE__ */Caml_exceptions.create("ArrayLabels.Bottom"); function sort(cmp, a) { - let maxson = function (l, i) { + let maxson = (l, i) => { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { @@ -324,7 +324,7 @@ function sort(cmp, a) { } }); }; - let trickle = function (l, i, e) { + let trickle = (l, i, e) => { try { let _i = i; while (true) { @@ -347,7 +347,7 @@ function sort(cmp, a) { }); } }; - let bubble = function (l, i) { + let bubble = (l, i) => { try { let _i = i; while (true) { @@ -367,7 +367,7 @@ function sort(cmp, a) { }); } }; - let trickleup = function (_i, e) { + let trickleup = (_i, e) => { while (true) { let i = _i; let father = (i - 1 | 0) / 3 | 0; @@ -412,7 +412,7 @@ function sort(cmp, a) { } function stable_sort(cmp, a) { - let merge = function (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { let src1r = src1ofs + src1len | 0; let src2r = src2ofs + src2len | 0; let _i1 = src1ofs; @@ -448,7 +448,7 @@ function stable_sort(cmp, a) { continue; }; }; - let isortto = function (srcofs, dst, dstofs, len) { + let isortto = (srcofs, dst, dstofs, len) => { for (let i = 0; i < len; ++i) { let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; @@ -459,7 +459,7 @@ function stable_sort(cmp, a) { Caml_array.set(dst, j + 1 | 0, e); } }; - let sortto = function (srcofs, dst, dstofs, len) { + let sortto = (srcofs, dst, dstofs, len) => { if (len <= 5) { return isortto(srcofs, dst, dstofs, len); } diff --git a/lib/es6/belt_Array.js b/lib/es6/belt_Array.js index 2f6861be87..c3d940cbf5 100644 --- a/lib/es6/belt_Array.js +++ b/lib/es6/belt_Array.js @@ -59,9 +59,7 @@ function swapUnsafe(xs, i, j) { function shuffleInPlace(xs) { let len = xs.length; - let random_int = function (min, max) { - return Math.floor(Math.random() * (max - min | 0)) + min | 0; - }; + let random_int = (min, max) => Math.floor(Math.random() * (max - min | 0)) + min | 0; for (let i = 0; i < len; ++i) { swapUnsafe(xs, i, random_int(i, len)); } diff --git a/lib/es6/belt_MapDict.js b/lib/es6/belt_MapDict.js index 13f4eee8d0..9326d3fd62 100644 --- a/lib/es6/belt_MapDict.js +++ b/lib/es6/belt_MapDict.js @@ -196,17 +196,13 @@ function split(n, x, cmp) { function merge(s1, s2, f, cmp) { if (s1 === undefined) { if (s2 !== undefined) { - return Belt_internalAVLtree.keepMap(s2, (function (k, v) { - return f(k, undefined, Caml_option.some(v)); - })); + return Belt_internalAVLtree.keepMap(s2, (k, v) => f(k, undefined, Caml_option.some(v))); } else { return; } } if (s2 === undefined) { - return Belt_internalAVLtree.keepMap(s1, (function (k, v) { - return f(k, Caml_option.some(v), undefined); - })); + return Belt_internalAVLtree.keepMap(s1, (k, v) => f(k, Caml_option.some(v), undefined)); } if (s1.h >= s2.h) { let v1 = s1.k; diff --git a/lib/es6/belt_internalAVLset.js b/lib/es6/belt_internalAVLset.js index 94c81e95e7..3e680658a9 100644 --- a/lib/es6/belt_internalAVLset.js +++ b/lib/es6/belt_internalAVLset.js @@ -827,9 +827,7 @@ function fromArray(xs, cmp) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (x, y) { - return cmp(x, y) < 0; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (x, y) => cmp(x, y) < 0); let result; if (next >= 0) { result = fromSortedArrayAux(xs, 0, next); diff --git a/lib/es6/belt_internalAVLtree.js b/lib/es6/belt_internalAVLtree.js index 190a8d150c..dcbd04e32e 100644 --- a/lib/es6/belt_internalAVLtree.js +++ b/lib/es6/belt_internalAVLtree.js @@ -1001,9 +1001,7 @@ function fromArray(xs, cmp) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (param, param$1) { - return cmp(param[0], param$1[0]) < 0; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (param, param$1) => cmp(param[0], param$1[0]) < 0); let result; if (next >= 0) { result = fromSortedArrayAux(xs, 0, next); diff --git a/lib/es6/belt_internalBuckets.js b/lib/es6/belt_internalBuckets.js index bc3aaf29c3..6d6027ff47 100644 --- a/lib/es6/belt_internalBuckets.js +++ b/lib/es6/belt_internalBuckets.js @@ -108,25 +108,23 @@ function reduce(h, init, f) { } function getMaxBucketLength(h) { - return Belt_Array.reduce(h.buckets, 0, (function (m, b) { + return Belt_Array.reduce(h.buckets, 0, (m, b) => { let len = bucketLength(0, b); if (m > len) { return m; } else { return len; } - })); + }); } function getBucketHistogram(h) { let mbl = getMaxBucketLength(h); - let histo = Belt_Array.makeBy(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEach(h.buckets, (function (b) { + let histo = Belt_Array.makeBy(mbl + 1 | 0, param => 0); + Belt_Array.forEach(h.buckets, b => { let l = bucketLength(0, b); histo[l] = histo[l] + 1 | 0; - })); + }); return histo; } @@ -233,24 +231,18 @@ function linear(h, f) { } function keysToArray(h) { - return linear(h, (function (x) { - return x.key; - })); + return linear(h, x => x.key); } function valuesToArray(h) { - return linear(h, (function (x) { - return x.value; - })); + return linear(h, x => x.value); } function toArray(h) { - return linear(h, (function (x) { - return [ - x.key, - x.value - ]; - })); + return linear(h, x => [ + x.key, + x.value + ]); } let C; diff --git a/lib/es6/belt_internalMapInt.js b/lib/es6/belt_internalMapInt.js index 54b4477a66..7f54f84751 100644 --- a/lib/es6/belt_internalMapInt.js +++ b/lib/es6/belt_internalMapInt.js @@ -303,9 +303,7 @@ function fromArray(xs) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (param, param$1) => param[0] < param$1[0]); let result; if (next >= 0) { result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); diff --git a/lib/es6/belt_internalMapString.js b/lib/es6/belt_internalMapString.js index 0529dbd1fa..d048bcc96f 100644 --- a/lib/es6/belt_internalMapString.js +++ b/lib/es6/belt_internalMapString.js @@ -303,9 +303,7 @@ function fromArray(xs) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (param, param$1) => param[0] < param$1[0]); let result; if (next >= 0) { result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); diff --git a/lib/es6/belt_internalSetBuckets.js b/lib/es6/belt_internalSetBuckets.js index 8a6100c2d5..f98cc4c595 100644 --- a/lib/es6/belt_internalSetBuckets.js +++ b/lib/es6/belt_internalSetBuckets.js @@ -134,25 +134,23 @@ function reduce(h, init, f) { } function getMaxBucketLength(h) { - return Belt_Array.reduce(h.buckets, 0, (function (m, b) { + return Belt_Array.reduce(h.buckets, 0, (m, b) => { let len = bucketLength(0, b); if (m > len) { return m; } else { return len; } - })); + }); } function getBucketHistogram(h) { let mbl = getMaxBucketLength(h); - let histo = Belt_Array.makeBy(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEach(h.buckets, (function (b) { + let histo = Belt_Array.makeBy(mbl + 1 | 0, param => 0); + Belt_Array.forEach(h.buckets, b => { let l = bucketLength(0, b); histo[l] = histo[l] + 1 | 0; - })); + }); return histo; } diff --git a/lib/es6/caml_format.js b/lib/es6/caml_format.js index debf240abf..e0441baf86 100644 --- a/lib/es6/caml_format.js +++ b/lib/es6/caml_format.js @@ -136,7 +136,7 @@ function int_of_string(s) { } }); } - let aux = function (_acc, _k) { + let aux = (_acc, _k) => { while (true) { let k = _k; let acc = _acc; @@ -225,7 +225,7 @@ function int64_of_string(s) { } }); } - let aux = function (_acc, _k) { + let aux = (_acc, _k) => { while (true) { let k = _k; let acc = _acc; @@ -404,7 +404,7 @@ function parse_format(fmt) { case 46 : f.prec = 0; let j = i + 1 | 0; - while ((function () { + while ((() => { let w = fmt.codePointAt(j) - 48 | 0; return w >= 0 && w <= 9; })()) { @@ -443,7 +443,7 @@ function parse_format(fmt) { case 3 : f.width = 0; let j$1 = i; - while ((function () { + while ((() => { let w = fmt.codePointAt(j$1) - 48 | 0; return w >= 0 && w <= 9; })()) { @@ -676,7 +676,7 @@ function format_float(fmt, x) { p = p - (exp + 1 | 0) | 0; s = x$1.toFixed(p); } else { - while ((function () { + while ((() => { s = x$1.toFixed(p); return s.length > (prec$1 + 1 | 0); })()) { diff --git a/lib/es6/caml_hash.js b/lib/es6/caml_hash.js index 054d821630..c238fbd048 100644 --- a/lib/es6/caml_hash.js +++ b/lib/es6/caml_hash.js @@ -84,9 +84,7 @@ function hash(count, _limit, seed, obj) { ++ size } return size - })(obj$1, (function (v) { - push_back(queue, v); - })); + })(obj$1, v => push_back(queue, v)); s = Caml_hash_primitive.hash_mix_int(s, (size$1 << 10) | 0); } } diff --git a/lib/es6/caml_int64.js b/lib/es6/caml_int64.js index 14bae1175a..7e0be85c45 100644 --- a/lib/es6/caml_int64.js +++ b/lib/es6/caml_int64.js @@ -527,9 +527,7 @@ function to_int32(x) { function to_hex(x) { let x_lo = x[1]; let x_hi = x[0]; - let aux = function (v) { - return (v >>> 0).toString(16); - }; + let aux = v => (v >>> 0).toString(16); if (x_hi === 0 && x_lo === 0) { return "0"; } diff --git a/lib/es6/caml_module.js b/lib/es6/caml_module.js index 55a5dc88d5..51988ea254 100644 --- a/lib/es6/caml_module.js +++ b/lib/es6/caml_module.js @@ -3,7 +3,7 @@ import * as Caml_obj from "./caml_obj.js"; function init_mod(loc, shape) { - let undef_module = function (param) { + let undef_module = param => { throw new Error("Undefined_recursive_module", { cause: { RE_EXN_ID: "Undefined_recursive_module", @@ -11,7 +11,7 @@ function init_mod(loc, shape) { } }); }; - let loop = function (shape, struct_, idx) { + let loop = (shape, struct_, idx) => { if (typeof shape !== "object") { switch (shape) { case "Function" : @@ -50,7 +50,7 @@ function init_mod(loc, shape) { } function update_mod(shape, o, n) { - let aux = function (shape, o, n, parent, i) { + let aux = (shape, o, n, parent, i) => { if (typeof shape !== "object") { switch (shape) { case "Function" : diff --git a/lib/es6/caml_obj.js b/lib/es6/caml_obj.js index 8fc4b04320..9d025bf517 100644 --- a/lib/es6/caml_obj.js +++ b/lib/es6/caml_obj.js @@ -211,7 +211,7 @@ function aux_obj_compare(a, b) { let min_key_rhs = { contents: undefined }; - let do_key = function (param, key) { + let do_key = (param, key) => { let min_key = param[2]; let b = param[1]; if (!(!Object.prototype.hasOwnProperty.call(b, key) || compare(param[0][key], b[key]) > 0)) { @@ -225,20 +225,16 @@ function aux_obj_compare(a, b) { return; } }; - let do_key_a = function (key) { - do_key([ - a, - b, - min_key_rhs - ], key); - }; - let do_key_b = function (key) { - do_key([ - b, - a, - min_key_lhs - ], key); - }; + let do_key_a = key => do_key([ + a, + b, + min_key_rhs + ], key); + let do_key_b = key => do_key([ + b, + a, + min_key_lhs + ], key); for_in(a, do_key_a); for_in(b, do_key_b); let match = min_key_lhs.contents; @@ -314,14 +310,14 @@ function equal(a, b) { let result = { contents: true }; - let do_key_a = function (key) { + let do_key_a = key => { if (!Object.prototype.hasOwnProperty.call(b, key)) { result.contents = false; return; } }; - let do_key_b = function (key) { + let do_key_b = key => { if (!Object.prototype.hasOwnProperty.call(a, key) || !equal(b[key], a[key])) { result.contents = false; return; diff --git a/lib/es6/camlinternalLazy.js b/lib/es6/camlinternalLazy.js index 4e8978398a..59fa0b914d 100644 --- a/lib/es6/camlinternalLazy.js +++ b/lib/es6/camlinternalLazy.js @@ -32,11 +32,11 @@ function force(lzv) { try { return forward_with_closure(lzv, closure); } catch (e) { - lzv.VAL = (function () { + lzv.VAL = () => { throw new Error(e.RE_EXN_ID, { cause: e }); - }); + }; throw new Error(e.RE_EXN_ID, { cause: e }); diff --git a/lib/es6/curry.js b/lib/es6/curry.js index 00af2a55d5..793b2d7f9a 100644 --- a/lib/es6/curry.js +++ b/lib/es6/curry.js @@ -14,9 +14,7 @@ function app(_f, _args) { return f.apply(null, args); } if (d >= 0) { - return function (x) { - return app(f, args.concat([x])); - }; + return x => app(f, args.concat([x])); } _args = Caml_array.sub(args, arity, -d | 0); _f = f.apply(null, Caml_array.sub(args, 0, arity)); @@ -33,29 +31,17 @@ function _1(o, a0) { case 1 : return o(a0); case 2 : - return function (param) { - return o(a0, param); - }; + return param => o(a0, param); case 3 : - return function (param, param$1) { - return o(a0, param, param$1); - }; + return (param, param$1) => o(a0, param, param$1); case 4 : - return function (param, param$1, param$2) { - return o(a0, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, param, param$1, param$2); case 5 : - return function (param, param$1, param$2, param$3) { - return o(a0, param, param$1, param$2, param$3); - }; + return (param, param$1, param$2, param$3) => o(a0, param, param$1, param$2, param$3); case 6 : - return function (param, param$1, param$2, param$3, param$4) { - return o(a0, param, param$1, param$2, param$3, param$4); - }; + return (param, param$1, param$2, param$3, param$4) => o(a0, param, param$1, param$2, param$3, param$4); case 7 : - return function (param, param$1, param$2, param$3, param$4, param$5) { - return o(a0, param, param$1, param$2, param$3, param$4, param$5); - }; + return (param, param$1, param$2, param$3, param$4, param$5) => o(a0, param, param$1, param$2, param$3, param$4, param$5); default: return app(o, [a0]); } @@ -67,9 +53,7 @@ function __1(o) { if (arity === 1) { return o; } else { - return function (a0) { - return _1(o, a0); - }; + return a0 => _1(o, a0); } } @@ -84,25 +68,15 @@ function _2(o, a0, a1) { case 2 : return o(a0, a1); case 3 : - return function (param) { - return o(a0, a1, param); - }; + return param => o(a0, a1, param); case 4 : - return function (param, param$1) { - return o(a0, a1, param, param$1); - }; + return (param, param$1) => o(a0, a1, param, param$1); case 5 : - return function (param, param$1, param$2) { - return o(a0, a1, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, a1, param, param$1, param$2); case 6 : - return function (param, param$1, param$2, param$3) { - return o(a0, a1, param, param$1, param$2, param$3); - }; + return (param, param$1, param$2, param$3) => o(a0, a1, param, param$1, param$2, param$3); case 7 : - return function (param, param$1, param$2, param$3, param$4) { - return o(a0, a1, param, param$1, param$2, param$3, param$4); - }; + return (param, param$1, param$2, param$3, param$4) => o(a0, a1, param, param$1, param$2, param$3, param$4); default: return app(o, [ a0, @@ -117,9 +91,7 @@ function __2(o) { if (arity === 2) { return o; } else { - return function (a0, a1) { - return _2(o, a0, a1); - }; + return (a0, a1) => _2(o, a0, a1); } } @@ -139,21 +111,13 @@ function _3(o, a0, a1, a2) { case 3 : return o(a0, a1, a2); case 4 : - return function (param) { - return o(a0, a1, a2, param); - }; + return param => o(a0, a1, a2, param); case 5 : - return function (param, param$1) { - return o(a0, a1, a2, param, param$1); - }; + return (param, param$1) => o(a0, a1, a2, param, param$1); case 6 : - return function (param, param$1, param$2) { - return o(a0, a1, a2, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, a1, a2, param, param$1, param$2); case 7 : - return function (param, param$1, param$2, param$3) { - return o(a0, a1, a2, param, param$1, param$2, param$3); - }; + return (param, param$1, param$2, param$3) => o(a0, a1, a2, param, param$1, param$2, param$3); default: return app(o, [ a0, @@ -169,9 +133,7 @@ function __3(o) { if (arity === 3) { return o; } else { - return function (a0, a1, a2) { - return _3(o, a0, a1, a2); - }; + return (a0, a1, a2) => _3(o, a0, a1, a2); } } @@ -197,17 +159,11 @@ function _4(o, a0, a1, a2, a3) { case 4 : return o(a0, a1, a2, a3); case 5 : - return function (param) { - return o(a0, a1, a2, a3, param); - }; + return param => o(a0, a1, a2, a3, param); case 6 : - return function (param, param$1) { - return o(a0, a1, a2, a3, param, param$1); - }; + return (param, param$1) => o(a0, a1, a2, a3, param, param$1); case 7 : - return function (param, param$1, param$2) { - return o(a0, a1, a2, a3, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, a1, a2, a3, param, param$1, param$2); default: return app(o, [ a0, @@ -224,9 +180,7 @@ function __4(o) { if (arity === 4) { return o; } else { - return function (a0, a1, a2, a3) { - return _4(o, a0, a1, a2, a3); - }; + return (a0, a1, a2, a3) => _4(o, a0, a1, a2, a3); } } @@ -259,13 +213,9 @@ function _5(o, a0, a1, a2, a3, a4) { case 5 : return o(a0, a1, a2, a3, a4); case 6 : - return function (param) { - return o(a0, a1, a2, a3, a4, param); - }; + return param => o(a0, a1, a2, a3, a4, param); case 7 : - return function (param, param$1) { - return o(a0, a1, a2, a3, a4, param, param$1); - }; + return (param, param$1) => o(a0, a1, a2, a3, a4, param, param$1); default: return app(o, [ a0, @@ -283,9 +233,7 @@ function __5(o) { if (arity === 5) { return o; } else { - return function (a0, a1, a2, a3, a4) { - return _5(o, a0, a1, a2, a3, a4); - }; + return (a0, a1, a2, a3, a4) => _5(o, a0, a1, a2, a3, a4); } } @@ -326,9 +274,7 @@ function _6(o, a0, a1, a2, a3, a4, a5) { case 6 : return o(a0, a1, a2, a3, a4, a5); case 7 : - return function (param) { - return o(a0, a1, a2, a3, a4, a5, param); - }; + return param => o(a0, a1, a2, a3, a4, a5, param); default: return app(o, [ a0, @@ -347,9 +293,7 @@ function __6(o) { if (arity === 6) { return o; } else { - return function (a0, a1, a2, a3, a4, a5) { - return _6(o, a0, a1, a2, a3, a4, a5); - }; + return (a0, a1, a2, a3, a4, a5) => _6(o, a0, a1, a2, a3, a4, a5); } } @@ -417,9 +361,7 @@ function __7(o) { if (arity === 7) { return o; } else { - return function (a0, a1, a2, a3, a4, a5, a6) { - return _7(o, a0, a1, a2, a3, a4, a5, a6); - }; + return (a0, a1, a2, a3, a4, a5, a6) => _7(o, a0, a1, a2, a3, a4, a5, a6); } } @@ -496,9 +438,7 @@ function __8(o) { if (arity === 8) { return o; } else { - return function (a0, a1, a2, a3, a4, a5, a6, a7) { - return _8(o, a0, a1, a2, a3, a4, a5, a6, a7); - }; + return (a0, a1, a2, a3, a4, a5, a6, a7) => _8(o, a0, a1, a2, a3, a4, a5, a6, a7); } } diff --git a/lib/es6/digest.js b/lib/es6/digest.js index b5a203d3d8..1eded13e8a 100644 --- a/lib/es6/digest.js +++ b/lib/es6/digest.js @@ -64,7 +64,7 @@ function from_hex(s) { } }); } - let digit = function (c) { + let digit = c => { if (c >= 65) { if (c >= 97) { if (c >= 103) { @@ -97,9 +97,7 @@ function from_hex(s) { } return c - /* '0' */48 | 0; }; - let byte = function (i) { - return (digit(Caml_string.get(s, i)) << 4) + digit(Caml_string.get(s, i + 1 | 0)) | 0; - }; + let byte = i => (digit(Caml_string.get(s, i)) << 4) + digit(Caml_string.get(s, i + 1 | 0)) | 0; let result = Caml_bytes.create(16); for (let i = 0; i <= 15; ++i) { Caml_bytes.set(result, i, Char.chr(byte((i << 1)))); diff --git a/lib/es6/filename.js b/lib/es6/filename.js index 7eff32f9f3..38a8258878 100644 --- a/lib/es6/filename.js +++ b/lib/es6/filename.js @@ -215,7 +215,7 @@ function quote$1(s) { let l = s.length; let b = Buffer.create(l + 20 | 0); Buffer.add_char(b, /* '"' */34); - let loop = function (_i) { + let loop = _i => { while (true) { let i = _i; if (i === l) { @@ -233,7 +233,7 @@ function quote$1(s) { continue; }; }; - let loop_bs = function (_n, _i) { + let loop_bs = (_n, _i) => { while (true) { let i = _i; let n = _n; @@ -256,7 +256,7 @@ function quote$1(s) { return loop(i + 1 | 0); }; }; - let add_bs = function (n) { + let add_bs = n => { for (let _j = 1; _j <= n; ++_j) { Buffer.add_char(b, /* '\\' */92); } @@ -266,7 +266,7 @@ function quote$1(s) { } function has_drive(s) { - let is_letter = function (param) { + let is_letter = param => { if (param >= 91) { return !(param > 122 || param < 97); } else { diff --git a/lib/es6/genlex.js b/lib/es6/genlex.js index 9e2005ad19..d3d551a979 100644 --- a/lib/es6/genlex.js +++ b/lib/es6/genlex.js @@ -43,13 +43,11 @@ function get_string() { function make_lexer(keywords) { let kwd_table = Hashtbl.create(undefined, 17); - List.iter((function (s) { - Hashtbl.add(kwd_table, s, { - TAG: "Kwd", - _0: s - }); + List.iter(s => Hashtbl.add(kwd_table, s, { + TAG: "Kwd", + _0: s }), keywords); - let ident_or_keyword = function (id) { + let ident_or_keyword = id => { try { return Hashtbl.find(kwd_table, id); } catch (raw_exn) { @@ -65,7 +63,7 @@ function make_lexer(keywords) { }); } }; - let keyword_or_error = function (c) { + let keyword_or_error = c => { let s = Caml_string.make(1, c); try { return Hashtbl.find(kwd_table, s); @@ -84,7 +82,7 @@ function make_lexer(keywords) { }); } }; - let next_token = function (strm__) { + let next_token = strm__ => { while (true) { let c = Stream.peek(strm__); if (c === undefined) { @@ -310,7 +308,7 @@ function make_lexer(keywords) { } }; }; - let ident2 = function (strm__) { + let ident2 = strm__ => { while (true) { let c = Stream.peek(strm__); if (c === undefined) { @@ -377,7 +375,7 @@ function make_lexer(keywords) { continue; }; }; - let number = function (strm__) { + let number = strm__ => { while (true) { let c = Stream.peek(strm__); if (c !== undefined) { @@ -428,7 +426,7 @@ function make_lexer(keywords) { }; }; }; - let exponent_part = function (strm__) { + let exponent_part = strm__ => { let c = Stream.peek(strm__); if (c !== undefined && !(c !== 43 && c !== 45)) { Stream.junk(strm__); @@ -438,7 +436,7 @@ function make_lexer(keywords) { return end_exponent_part(strm__); } }; - let end_exponent_part = function (strm__) { + let end_exponent_part = strm__ => { while (true) { let c = Stream.peek(strm__); if (c === undefined) { @@ -458,7 +456,7 @@ function make_lexer(keywords) { continue; }; }; - let string = function (strm__) { + let string = strm__ => { while (true) { let c = Stream.peek(strm__); if (c !== undefined) { @@ -499,7 +497,7 @@ function make_lexer(keywords) { }); }; }; - let char = function (strm__) { + let char = strm__ => { let c = Stream.peek(strm__); if (c !== undefined) { if (c !== 92) { @@ -531,7 +529,7 @@ function make_lexer(keywords) { }); } }; - let escape = function (strm__) { + let escape = strm__ => { let c1 = Stream.peek(strm__); if (c1 !== undefined) { if (c1 >= 58) { @@ -601,7 +599,7 @@ function make_lexer(keywords) { }); } }; - let comment = function (strm__) { + let comment = strm__ => { while (true) { let match = Stream.peek(strm__); if (match !== undefined) { @@ -659,11 +657,7 @@ function make_lexer(keywords) { } }; }; - return function (input) { - return Stream.from(function (_count) { - return next_token(input); - }); - }; + return input => Stream.from(_count => next_token(input)); } export { diff --git a/lib/es6/hashtbl.js b/lib/es6/hashtbl.js index 6a8a0e8b92..4337892b11 100644 --- a/lib/es6/hashtbl.js +++ b/lib/es6/hashtbl.js @@ -38,9 +38,7 @@ function is_randomized() { return randomized.contents; } -let prng = CamlinternalLazy.from_fun(function () { - return Random.State.make_self_init(); -}); +let prng = CamlinternalLazy.from_fun(() => Random.State.make_self_init()); function power_2_above(_x, n) { while (true) { @@ -94,7 +92,7 @@ function copy_bucketlist(param) { let key = param.key; let data = param.data; let next = param.next; - let loop = function (_prec, _param) { + let loop = (_prec, _param) => { while (true) { let param = _param; let prec = _prec; @@ -162,7 +160,7 @@ function resize(indexfun, h) { let ndata_tail = Caml_array.make(nsize, "Empty"); let inplace = h.initial_size >= 0; h.data = ndata; - let insert_bucket = function (_param) { + let insert_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -362,7 +360,7 @@ function find_opt(h, key) { } function find_all(h, key) { - let find_in_bucket = function (_param) { + let find_in_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -440,7 +438,7 @@ function mem(h, key) { } function iter(f, h) { - let do_bucket = function (_param) { + let do_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -539,7 +537,7 @@ function filter_map_inplace(f, h) { } function fold(f, h, init) { - let do_bucket = function (_b, _accu) { + let do_bucket = (_b, _accu) => { while (true) { let accu = _accu; let b = _b; @@ -596,14 +594,12 @@ function bucket_length(_accu, _param) { } function stats(h) { - let mbl = $$Array.fold_left((function (m, b) { - return Caml.int_max(m, bucket_length(0, b)); - }), 0, h.data); + let mbl = $$Array.fold_left((m, b) => Caml.int_max(m, bucket_length(0, b)), 0, h.data); let histo = Caml_array.make(mbl + 1 | 0, 0); - $$Array.iter((function (b) { + $$Array.iter(b => { let l = bucket_length(0, b); Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); - }), h.data); + }, h.data); return { num_bindings: h.size, num_buckets: h.data.length, @@ -613,10 +609,8 @@ function stats(h) { } function MakeSeeded(H) { - let key_index = function (h, key) { - return H.hash(h.seed, key) & (h.data.length - 1 | 0); - }; - let add = function (h, key, data) { + let key_index = (h, key) => H.hash(h.seed, key) & (h.data.length - 1 | 0); + let add = (h, key, data) => { let i = key_index(h, key); let bucket = { TAG: "Cons", @@ -631,7 +625,7 @@ function MakeSeeded(H) { } }; - let remove = function (h, key) { + let remove = (h, key) => { let i = key_index(h, key); let _prec = "Empty"; let _param = Caml_array.get(h.data, i); @@ -657,7 +651,7 @@ function MakeSeeded(H) { continue; }; }; - let find = function (h, key) { + let find = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { throw new Error("Not_found", { @@ -719,7 +713,7 @@ function MakeSeeded(H) { }; } }; - let find_opt = function (h, key) { + let find_opt = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { return; @@ -765,8 +759,8 @@ function MakeSeeded(H) { }; } }; - let find_all = function (h, key) { - let find_in_bucket = function (_param) { + let find_all = (h, key) => { + let find_in_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -787,7 +781,7 @@ function MakeSeeded(H) { }; return find_in_bucket(Caml_array.get(h.data, key_index(h, key))); }; - let replace_bucket = function (key, data, _param) { + let replace_bucket = (key, data, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -804,7 +798,7 @@ function MakeSeeded(H) { continue; }; }; - let replace = function (h, key, data) { + let replace = (h, key, data) => { let i = key_index(h, key); let l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { @@ -823,7 +817,7 @@ function MakeSeeded(H) { } }; - let mem = function (h, key) { + let mem = (h, key) => { let _param = Caml_array.get(h.data, key_index(h, key)); while (true) { let param = _param; @@ -861,10 +855,8 @@ 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); - }; - let add = function (h, key, data) { + let key_index = (h, key) => H.hash(key) & (h.data.length - 1 | 0); + let add = (h, key, data) => { let i = key_index(h, key); let bucket = { TAG: "Cons", @@ -879,7 +871,7 @@ function Make(H) { } }; - let remove = function (h, key) { + let remove = (h, key) => { let i = key_index(h, key); let _prec = "Empty"; let _param = Caml_array.get(h.data, i); @@ -905,7 +897,7 @@ function Make(H) { continue; }; }; - let find = function (h, key) { + let find = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { throw new Error("Not_found", { @@ -967,7 +959,7 @@ function Make(H) { }; } }; - let find_opt = function (h, key) { + let find_opt = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { return; @@ -1013,8 +1005,8 @@ function Make(H) { }; } }; - let find_all = function (h, key) { - let find_in_bucket = function (_param) { + let find_all = (h, key) => { + let find_in_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1035,7 +1027,7 @@ function Make(H) { }; return find_in_bucket(Caml_array.get(h.data, key_index(h, key))); }; - let replace_bucket = function (key, data, _param) { + let replace_bucket = (key, data, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1052,7 +1044,7 @@ function Make(H) { continue; }; }; - let replace = function (h, key, data) { + let replace = (h, key, data) => { let i = key_index(h, key); let l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { @@ -1071,7 +1063,7 @@ function Make(H) { } }; - let mem = function (h, key) { + let mem = (h, key) => { let _param = Caml_array.get(h.data, key_index(h, key)); while (true) { let param = _param; @@ -1087,9 +1079,7 @@ function Make(H) { continue; }; }; - let create$1 = function (sz) { - return create(false, sz); - }; + let create$1 = sz => create(false, sz); return { create: create$1, clear: clear, diff --git a/lib/es6/hashtblLabels.js b/lib/es6/hashtblLabels.js index 7c623f7274..830e53d19f 100644 --- a/lib/es6/hashtblLabels.js +++ b/lib/es6/hashtblLabels.js @@ -11,21 +11,15 @@ function replace(tbl, key, data) { } function iter(f, tbl) { - Hashtbl.iter((function (key, data) { - f(key, data); - }), tbl); + Hashtbl.iter((key, data) => f(key, data), tbl); } function filter_map_inplace(f, tbl) { - Hashtbl.filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Hashtbl.filter_map_inplace((key, data) => f(key, data), tbl); } function fold(f, tbl, init) { - return Hashtbl.fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Hashtbl.fold((key, data, acc) => f(key, data, acc), tbl, init); } function MakeSeeded(H) { @@ -35,27 +29,11 @@ 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 iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); - }; - let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); - }; - let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); - }; + let add$1 = (tbl, key, data) => add(tbl, key, data); + let replace$1 = (tbl, key, data) => replace(tbl, key, data); + let iter$1 = (f, tbl) => iter((key, data) => f(key, data), tbl); + let filter_map_inplace$1 = (f, tbl) => filter_map_inplace((key, data) => f(key, data), tbl); + let fold$1 = (f, tbl, init) => fold((key, data, acc) => f(key, data, acc), tbl, init); return { create: include.create, clear: include.clear, @@ -77,9 +55,7 @@ function MakeSeeded(H) { } function Make(H) { - let hash = function (_seed, x) { - return H.hash(x); - }; + let hash = (_seed, x) => H.hash(x); let H_equal = H.equal; let H$1 = { equal: H_equal, @@ -92,30 +68,12 @@ 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 iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); - }; - let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); - }; - let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); - }; - let create$1 = function (sz) { - return create(false, sz); - }; + let add$1 = (tbl, key, data) => add(tbl, key, data); + let replace$1 = (tbl, key, data) => replace(tbl, key, data); + let iter$1 = (f, tbl) => iter((key, data) => f(key, data), tbl); + let filter_map_inplace$1 = (f, tbl) => filter_map_inplace((key, data) => f(key, data), tbl); + let fold$1 = (f, tbl, init) => fold((key, data, acc) => f(key, data, acc), tbl, init); + let create$1 = sz => create(false, sz); return { create: create$1, clear: include.clear, diff --git a/lib/es6/lazy.js b/lib/es6/lazy.js index 14e2ebd88b..e858dde9b2 100644 --- a/lib/es6/lazy.js +++ b/lib/es6/lazy.js @@ -3,9 +3,7 @@ import * as CamlinternalLazy from "./camlinternalLazy.js"; function from_fun(f) { - return CamlinternalLazy.from_fun(function () { - return f(); - }); + return CamlinternalLazy.from_fun(() => f()); } let from_val = CamlinternalLazy.from_val; diff --git a/lib/es6/lexing.js b/lib/es6/lexing.js index ab69f5bfac..cb6ad1c864 100644 --- a/lib/es6/lexing.js +++ b/lib/es6/lexing.js @@ -44,7 +44,7 @@ let zero_pos = { function from_function(f) { return { - refill_buff: (function (x) { + refill_buff: x => { let aux_buffer = Caml_bytes.create(512); let read = f(aux_buffer, aux_buffer.length); let n = read > 0 ? read : (x.lex_eof_reached = true, 0); @@ -82,7 +82,7 @@ function from_function(f) { } Bytes.blit(aux_buffer, 0, x.lex_buffer, x.lex_buffer_len, n); x.lex_buffer_len = x.lex_buffer_len + n | 0; - }), + }, lex_buffer: Caml_bytes.create(1024), lex_buffer_len: 0, lex_abs_pos: 0, @@ -99,9 +99,9 @@ function from_function(f) { function from_string(s) { return { - refill_buff: (function (lexbuf) { + refill_buff: lexbuf => { lexbuf.lex_eof_reached = true; - }), + }, lex_buffer: Bytes.of_string(s), lex_buffer_len: s.length, lex_abs_pos: 0, diff --git a/lib/es6/list.js b/lib/es6/list.js index 27207c1d45..09ebf99bde 100644 --- a/lib/es6/list.js +++ b/lib/es6/list.js @@ -856,7 +856,7 @@ function chop(_k, _l) { } function stable_sort(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1002,7 +1002,7 @@ function stable_sort(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1157,7 +1157,7 @@ function stable_sort(cmp, l) { } function sort_uniq(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1388,7 +1388,7 @@ function sort_uniq(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; diff --git a/lib/es6/listLabels.js b/lib/es6/listLabels.js index 46744d700a..b614cbfc27 100644 --- a/lib/es6/listLabels.js +++ b/lib/es6/listLabels.js @@ -856,7 +856,7 @@ function chop(_k, _l) { } function stable_sort(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1002,7 +1002,7 @@ function stable_sort(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1157,7 +1157,7 @@ function stable_sort(cmp, l) { } function sort_uniq(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1388,7 +1388,7 @@ function sort_uniq(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; diff --git a/lib/es6/map.js b/lib/es6/map.js index 1204bf6025..2052415d99 100644 --- a/lib/es6/map.js +++ b/lib/es6/map.js @@ -3,14 +3,14 @@ import * as Caml_option from "./caml_option.js"; function Make(funarg) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -22,17 +22,15 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - l: "Empty", - v: x, - d: d, - r: "Empty", - h: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + l: "Empty", + v: x, + d: d, + r: "Empty", + h: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -98,14 +96,14 @@ function Make(funarg) { } }); }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let add = function (x, data, param) { + let add = (x, data, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -150,7 +148,7 @@ function Make(funarg) { return bal(l, v, d, rr); } }; - let find = function (x, _param) { + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -168,7 +166,7 @@ function Make(funarg) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -208,7 +206,7 @@ function Make(funarg) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -244,7 +242,7 @@ function Make(funarg) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -284,7 +282,7 @@ function Make(funarg) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -320,7 +318,7 @@ function Make(funarg) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -334,7 +332,7 @@ function Make(funarg) { continue; }; }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -348,7 +346,7 @@ function Make(funarg) { continue; }; }; - let min_binding = function (_param) { + let min_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -369,7 +367,7 @@ function Make(funarg) { continue; }; }; - let min_binding_opt = function (_param) { + let min_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -386,7 +384,7 @@ function Make(funarg) { continue; }; }; - let max_binding = function (_param) { + let max_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -407,7 +405,7 @@ function Make(funarg) { continue; }; }; - let max_binding_opt = function (_param) { + let max_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -424,7 +422,7 @@ function Make(funarg) { continue; }; }; - let remove_min_binding = function (param) { + let remove_min_binding = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -440,7 +438,7 @@ function Make(funarg) { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -450,7 +448,7 @@ function Make(funarg) { let match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -477,7 +475,7 @@ function Make(funarg) { return bal(l, v, d, rr); } }; - let update = function (x, f, param) { + let update = (x, f, param) => { if (typeof param !== "object") { let data = f(undefined); if (data !== undefined) { @@ -532,7 +530,7 @@ function Make(funarg) { return bal(l, v, d, rr); } }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -544,7 +542,7 @@ function Make(funarg) { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -560,7 +558,7 @@ function Make(funarg) { h: param.h }; }; - let mapi = function (f, param) { + let mapi = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -577,7 +575,7 @@ function Make(funarg) { h: param.h }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -589,7 +587,7 @@ function Make(funarg) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -605,7 +603,7 @@ function Make(funarg) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -621,21 +619,21 @@ function Make(funarg) { continue; }; }; - let add_min_binding = function (k, x, param) { + let add_min_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; - let add_max_binding = function (k, x, param) { + let add_max_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -652,7 +650,7 @@ function Make(funarg) { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -662,14 +660,14 @@ function Make(funarg) { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -704,7 +702,7 @@ function Make(funarg) { match$1[2] ]; }; - let merge$1 = function (f, s1, s2) { + let merge$1 = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -734,7 +732,7 @@ function Make(funarg) { 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)); }; - let union = function (f, s1, s2) { + let union = (f, s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -766,7 +764,7 @@ function Make(funarg) { return join(l$1, v2, d2, r$1); } }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -787,7 +785,7 @@ function Make(funarg) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -815,7 +813,7 @@ function Make(funarg) { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -833,7 +831,7 @@ function Make(funarg) { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -862,7 +860,7 @@ function Make(funarg) { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -889,14 +887,14 @@ function Make(funarg) { continue; }; }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let bindings_aux = function (_accu, _param) { + let bindings_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -914,9 +912,7 @@ function Make(funarg) { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { empty: "Empty", is_empty: is_empty, diff --git a/lib/es6/mapLabels.js b/lib/es6/mapLabels.js index af3164d63e..c791c85f85 100644 --- a/lib/es6/mapLabels.js +++ b/lib/es6/mapLabels.js @@ -3,14 +3,14 @@ import * as Caml_option from "./caml_option.js"; function Make(Ord) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -22,17 +22,15 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - l: "Empty", - v: x, - d: d, - r: "Empty", - h: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + l: "Empty", + v: x, + d: d, + r: "Empty", + h: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -98,14 +96,14 @@ function Make(Ord) { } }); }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let add = function (x, data, param) { + let add = (x, data, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -150,7 +148,7 @@ function Make(Ord) { return bal(l, v, d, rr); } }; - let find = function (x, _param) { + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -168,7 +166,7 @@ function Make(Ord) { continue; }; }; - let find_first_aux = function (_v0, _d0, f, _param) { + let find_first_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -190,7 +188,7 @@ function Make(Ord) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -208,7 +206,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt_aux = function (_v0, _d0, f, _param) { + let find_first_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -230,7 +228,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -244,7 +242,7 @@ function Make(Ord) { continue; }; }; - let find_last_aux = function (_v0, _d0, f, _param) { + let find_last_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -266,7 +264,7 @@ function Make(Ord) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -284,7 +282,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt_aux = function (_v0, _d0, f, _param) { + let find_last_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -306,7 +304,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -320,7 +318,7 @@ function Make(Ord) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -334,7 +332,7 @@ function Make(Ord) { continue; }; }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -348,7 +346,7 @@ function Make(Ord) { continue; }; }; - let min_binding = function (_param) { + let min_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -369,7 +367,7 @@ function Make(Ord) { continue; }; }; - let min_binding_opt = function (_param) { + let min_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -386,7 +384,7 @@ function Make(Ord) { continue; }; }; - let max_binding = function (_param) { + let max_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -407,7 +405,7 @@ function Make(Ord) { continue; }; }; - let max_binding_opt = function (_param) { + let max_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -424,7 +422,7 @@ function Make(Ord) { continue; }; }; - let remove_min_binding = function (param) { + let remove_min_binding = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -440,7 +438,7 @@ function Make(Ord) { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -450,7 +448,7 @@ function Make(Ord) { let match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -477,7 +475,7 @@ function Make(Ord) { return bal(l, v, d, rr); } }; - let update = function (x, f, param) { + let update = (x, f, param) => { if (typeof param !== "object") { let data = f(undefined); if (data !== undefined) { @@ -532,7 +530,7 @@ function Make(Ord) { return bal(l, v, d, rr); } }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -544,7 +542,7 @@ function Make(Ord) { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -560,7 +558,7 @@ function Make(Ord) { h: param.h }; }; - let mapi = function (f, param) { + let mapi = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -577,7 +575,7 @@ function Make(Ord) { h: param.h }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -589,7 +587,7 @@ function Make(Ord) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -605,7 +603,7 @@ function Make(Ord) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -621,21 +619,21 @@ function Make(Ord) { continue; }; }; - let add_min_binding = function (k, x, param) { + let add_min_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; - let add_max_binding = function (k, x, param) { + let add_max_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -652,7 +650,7 @@ function Make(Ord) { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -662,14 +660,14 @@ function Make(Ord) { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -704,7 +702,7 @@ function Make(Ord) { match$1[2] ]; }; - let merge$1 = function (f, s1, s2) { + let merge$1 = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -734,7 +732,7 @@ function Make(Ord) { 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)); }; - let union = function (f, s1, s2) { + let union = (f, s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -766,7 +764,7 @@ function Make(Ord) { return join(l$1, v2, d2, r$1); } }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -787,7 +785,7 @@ function Make(Ord) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -815,7 +813,7 @@ function Make(Ord) { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -833,7 +831,7 @@ function Make(Ord) { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -862,7 +860,7 @@ function Make(Ord) { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -889,14 +887,14 @@ function Make(Ord) { continue; }; }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let bindings_aux = function (_accu, _param) { + let bindings_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -914,9 +912,7 @@ function Make(Ord) { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { height: height, create: create, diff --git a/lib/es6/moreLabels.js b/lib/es6/moreLabels.js index 36efe9670a..5ab48c2721 100644 --- a/lib/es6/moreLabels.js +++ b/lib/es6/moreLabels.js @@ -32,15 +32,15 @@ let Hashtbl = { }; let $$Map = { - Make: (function (funarg) { - let height = function (param) { + Make: funarg => { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -52,17 +52,15 @@ let $$Map = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - l: "Empty", - v: x, - d: d, - r: "Empty", - h: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + l: "Empty", + v: x, + d: d, + r: "Empty", + h: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -128,14 +126,14 @@ let $$Map = { } }); }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let add = function (x, data, param) { + let add = (x, data, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -180,7 +178,7 @@ let $$Map = { return bal(l, v, d, rr); } }; - let find = function (x, _param) { + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -198,7 +196,7 @@ let $$Map = { continue; }; }; - let find_first_aux = function (_v0, _d0, f, _param) { + let find_first_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -220,7 +218,7 @@ let $$Map = { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -238,7 +236,7 @@ let $$Map = { continue; }; }; - let find_first_opt_aux = function (_v0, _d0, f, _param) { + let find_first_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -260,7 +258,7 @@ let $$Map = { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -274,7 +272,7 @@ let $$Map = { continue; }; }; - let find_last_aux = function (_v0, _d0, f, _param) { + let find_last_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -296,7 +294,7 @@ let $$Map = { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -314,7 +312,7 @@ let $$Map = { continue; }; }; - let find_last_opt_aux = function (_v0, _d0, f, _param) { + let find_last_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -336,7 +334,7 @@ let $$Map = { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -350,7 +348,7 @@ let $$Map = { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -364,7 +362,7 @@ let $$Map = { continue; }; }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -378,7 +376,7 @@ let $$Map = { continue; }; }; - let min_binding = function (_param) { + let min_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -399,7 +397,7 @@ let $$Map = { continue; }; }; - let min_binding_opt = function (_param) { + let min_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -416,7 +414,7 @@ let $$Map = { continue; }; }; - let max_binding = function (_param) { + let max_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -437,7 +435,7 @@ let $$Map = { continue; }; }; - let max_binding_opt = function (_param) { + let max_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -454,7 +452,7 @@ let $$Map = { continue; }; }; - let remove_min_binding = function (param) { + let remove_min_binding = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -470,7 +468,7 @@ let $$Map = { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -480,7 +478,7 @@ let $$Map = { let match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -507,7 +505,7 @@ let $$Map = { return bal(l, v, d, rr); } }; - let update = function (x, f, param) { + let update = (x, f, param) => { if (typeof param !== "object") { let data = f(undefined); if (data !== undefined) { @@ -562,7 +560,7 @@ let $$Map = { return bal(l, v, d, rr); } }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -574,7 +572,7 @@ let $$Map = { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -590,7 +588,7 @@ let $$Map = { h: param.h }; }; - let mapi = function (f, param) { + let mapi = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -607,7 +605,7 @@ let $$Map = { h: param.h }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -619,7 +617,7 @@ let $$Map = { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -635,7 +633,7 @@ let $$Map = { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -651,21 +649,21 @@ let $$Map = { continue; }; }; - let add_min_binding = function (k, x, param) { + let add_min_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; - let add_max_binding = function (k, x, param) { + let add_max_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -682,7 +680,7 @@ let $$Map = { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -692,14 +690,14 @@ let $$Map = { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -734,7 +732,7 @@ let $$Map = { match$1[2] ]; }; - let merge$1 = function (f, s1, s2) { + let merge$1 = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -764,7 +762,7 @@ let $$Map = { 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)); }; - let union = function (f, s1, s2) { + let union = (f, s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -796,7 +794,7 @@ let $$Map = { return join(l$1, v2, d2, r$1); } }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -817,7 +815,7 @@ let $$Map = { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -845,7 +843,7 @@ let $$Map = { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -863,7 +861,7 @@ let $$Map = { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -892,7 +890,7 @@ let $$Map = { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -919,14 +917,14 @@ let $$Map = { continue; }; }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let bindings_aux = function (_accu, _param) { + let bindings_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -944,9 +942,7 @@ let $$Map = { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { empty: "Empty", is_empty: is_empty, @@ -983,19 +979,19 @@ let $$Map = { map: map, mapi: mapi }; - }) + } }; let $$Set = { - Make: (function (funarg) { - let height = function (param) { + Make: funarg => { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, v, r) { + let create = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -1008,7 +1004,7 @@ let $$Set = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let bal = function (l, v, r) { + let bal = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -1071,7 +1067,7 @@ let $$Set = { } }); }; - let add = function (x, param) { + let add = (x, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -1103,30 +1099,28 @@ let $$Set = { return bal(l, v, rr); } }; - let singleton = function (x) { - return { - TAG: "Node", - l: "Empty", - v: x, - r: "Empty", - h: 1 - }; - }; - let add_min_element = function (x, param) { + let singleton = x => ({ + TAG: "Node", + l: "Empty", + v: x, + r: "Empty", + h: 1 + }); + let add_min_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; - let add_max_element = function (x, param) { + let add_max_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; - let join = function (l, v, r) { + let join = (l, v, r) => { if (typeof l !== "object") { return add_min_element(v, r); } @@ -1143,7 +1137,7 @@ let $$Set = { return create(l, v, r); } }; - let min_elt = function (_param) { + let min_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1161,7 +1155,7 @@ let $$Set = { continue; }; }; - let min_elt_opt = function (_param) { + let min_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1175,7 +1169,7 @@ let $$Set = { continue; }; }; - let max_elt = function (_param) { + let max_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1193,7 +1187,7 @@ let $$Set = { continue; }; }; - let max_elt_opt = function (_param) { + let max_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1207,7 +1201,7 @@ let $$Set = { continue; }; }; - let remove_min_elt = function (param) { + let remove_min_elt = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -1223,7 +1217,7 @@ let $$Set = { return bal(remove_min_elt(l), param.v, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -1232,7 +1226,7 @@ let $$Set = { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -1241,7 +1235,7 @@ let $$Set = { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -1275,14 +1269,14 @@ let $$Set = { match$1[2] ]; }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1296,7 +1290,7 @@ let $$Set = { continue; }; }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -1322,7 +1316,7 @@ let $$Set = { return bal(l, v, rr); } }; - let union = function (s1, s2) { + let union = (s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -1346,7 +1340,7 @@ let $$Set = { let match$1 = split(v2, s1); return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; - let inter = function (s1, s2) { + let inter = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -1364,7 +1358,7 @@ let $$Set = { return concat(inter(l1, l2), inter(r1, match[2])); } }; - let diff = function (s1, s2) { + let diff = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -1382,7 +1376,7 @@ let $$Set = { return join(diff(l1, l2), v1, diff(r1, match[2])); } }; - let cons_enum = function (_s, _e) { + let cons_enum = (_s, _e) => { while (true) { let e = _e; let s = _s; @@ -1399,7 +1393,7 @@ let $$Set = { continue; }; }; - let compare_aux = function (_e1, _e2) { + let compare_aux = (_e1, _e2) => { while (true) { let e2 = _e2; let e1 = _e1; @@ -1422,13 +1416,9 @@ let $$Set = { continue; }; }; - let compare = function (s1, s2) { - return compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); - }; - let equal = function (s1, s2) { - return compare(s1, s2) === 0; - }; - let subset = function (_s1, _s2) { + let compare = (s1, s2) => compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { while (true) { let s2 = _s2; let s1 = _s1; @@ -1478,7 +1468,7 @@ let $$Set = { continue; }; }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1490,7 +1480,7 @@ let $$Set = { continue; }; }; - let fold = function (f, _s, _accu) { + let fold = (f, _s, _accu) => { while (true) { let accu = _accu; let s = _s; @@ -1502,7 +1492,7 @@ let $$Set = { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1518,7 +1508,7 @@ let $$Set = { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1534,7 +1524,7 @@ let $$Set = { continue; }; }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -1554,7 +1544,7 @@ let $$Set = { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -1581,14 +1571,14 @@ let $$Set = { ]; } }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let elements_aux = function (_accu, _param) { + let elements_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -1603,10 +1593,8 @@ let $$Set = { continue; }; }; - let elements = function (s) { - return elements_aux(/* [] */0, s); - }; - let find = function (x, _param) { + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1625,7 +1613,7 @@ let $$Set = { continue; }; }; - let find_first_aux = function (_v0, f, _param) { + let find_first_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1642,7 +1630,7 @@ let $$Set = { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1660,7 +1648,7 @@ let $$Set = { continue; }; }; - let find_first_opt_aux = function (_v0, f, _param) { + let find_first_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1677,7 +1665,7 @@ let $$Set = { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1691,7 +1679,7 @@ let $$Set = { continue; }; }; - let find_last_aux = function (_v0, f, _param) { + let find_last_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1708,7 +1696,7 @@ let $$Set = { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1726,7 +1714,7 @@ let $$Set = { continue; }; }; - let find_last_opt_aux = function (_v0, f, _param) { + let find_last_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1743,7 +1731,7 @@ let $$Set = { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1757,7 +1745,7 @@ let $$Set = { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1772,14 +1760,14 @@ let $$Set = { continue; }; }; - let try_join = function (l, v, r) { + let try_join = (l, v, r) => { if ((l === "Empty" || funarg.compare(max_elt(l), v) < 0) && (r === "Empty" || funarg.compare(v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); } }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -1795,8 +1783,8 @@ let $$Set = { return try_join(l$p, v$p, r$p); } }; - let of_sorted_list = function (l) { - let sub = function (n, l) { + let of_sorted_list = l => { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -1899,7 +1887,7 @@ let $$Set = { }; return sub(List.length(l), l)[0]; }; - let of_list = function (l) { + let of_list = l => { if (!l) { return "Empty"; } @@ -1967,7 +1955,7 @@ let $$Set = { find_last_opt: find_last_opt, of_list: of_list }; - }) + } }; export { diff --git a/lib/es6/parsing.js b/lib/es6/parsing.js index bf77a01d44..c2eb456f4f 100644 --- a/lib/es6/parsing.js +++ b/lib/es6/parsing.js @@ -55,9 +55,7 @@ function clear_parser() { } let current_lookahead_fun = { - contents: (function (param) { - return false; - }) + contents: param => false }; function yyparse(tables, start, lexer, lexbuf) { @@ -145,13 +143,13 @@ function yyparse(tables, start, lexer, lexbuf) { if (exn$1.RE_EXN_ID === YYexit) { return exn$1._1; } - current_lookahead_fun.contents = (function (tok) { + current_lookahead_fun.contents = tok => { if (typeof tok !== "number") { return Caml_array.get(tables.transl_block, tok.TAG) === curr_char; } else { return Caml_array.get(tables.transl_const, tok) === curr_char; } - }); + }; throw new Error(exn$1.RE_EXN_ID, { cause: exn$1 }); diff --git a/lib/es6/pervasives.js b/lib/es6/pervasives.js index a80ead8cb4..e066b6e51c 100644 --- a/lib/es6/pervasives.js +++ b/lib/es6/pervasives.js @@ -191,17 +191,15 @@ function print_string(prim) { } let exit_function = { - contents: (function (prim) { - - }) + contents: prim => {} }; function at_exit(f) { let g = exit_function.contents; - exit_function.contents = (function () { + exit_function.contents = () => { f(); g(); - }); + }; } function exit(retcode) { diff --git a/lib/es6/random.js b/lib/es6/random.js index 4f58498949..eecb439f2f 100644 --- a/lib/es6/random.js +++ b/lib/es6/random.js @@ -19,12 +19,8 @@ function assign(st1, st2) { } function full_init(s, seed) { - let combine = function (accu, x) { - return Digest.string(accu + String(x)); - }; - let extract = function (d) { - return ((Caml_string.get(d, 0) + (Caml_string.get(d, 1) << 8) | 0) + (Caml_string.get(d, 2) << 16) | 0) + (Caml_string.get(d, 3) << 24) | 0; - }; + let combine = (accu, x) => Digest.string(accu + String(x)); + let extract = d => ((Caml_string.get(d, 0) + (Caml_string.get(d, 1) << 8) | 0) + (Caml_string.get(d, 2) << 16) | 0) + (Caml_string.get(d, 3) << 24) | 0; let seed$1 = seed.length === 0 ? [0] : seed; let l = seed$1.length; for (let i = 0; i <= 54; ++i) { diff --git a/lib/es6/set.js b/lib/es6/set.js index 764a62ec36..214de70318 100644 --- a/lib/es6/set.js +++ b/lib/es6/set.js @@ -4,14 +4,14 @@ import * as List from "./list.js"; import * as Caml_option from "./caml_option.js"; function Make(funarg) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, v, r) { + let create = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -24,7 +24,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let bal = function (l, v, r) { + let bal = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -87,7 +87,7 @@ function Make(funarg) { } }); }; - let add = function (x, param) { + let add = (x, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -119,30 +119,28 @@ function Make(funarg) { return bal(l, v, rr); } }; - let singleton = function (x) { - return { - TAG: "Node", - l: "Empty", - v: x, - r: "Empty", - h: 1 - }; - }; - let add_min_element = function (x, param) { + let singleton = x => ({ + TAG: "Node", + l: "Empty", + v: x, + r: "Empty", + h: 1 + }); + let add_min_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; - let add_max_element = function (x, param) { + let add_max_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; - let join = function (l, v, r) { + let join = (l, v, r) => { if (typeof l !== "object") { return add_min_element(v, r); } @@ -159,7 +157,7 @@ function Make(funarg) { return create(l, v, r); } }; - let min_elt = function (_param) { + let min_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -177,7 +175,7 @@ function Make(funarg) { continue; }; }; - let min_elt_opt = function (_param) { + let min_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -191,7 +189,7 @@ function Make(funarg) { continue; }; }; - let max_elt = function (_param) { + let max_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -209,7 +207,7 @@ function Make(funarg) { continue; }; }; - let max_elt_opt = function (_param) { + let max_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -223,7 +221,7 @@ function Make(funarg) { continue; }; }; - let remove_min_elt = function (param) { + let remove_min_elt = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -239,7 +237,7 @@ function Make(funarg) { return bal(remove_min_elt(l), param.v, param.r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -248,7 +246,7 @@ function Make(funarg) { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -282,14 +280,14 @@ function Make(funarg) { match$1[2] ]; }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -303,7 +301,7 @@ function Make(funarg) { continue; }; }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -335,7 +333,7 @@ function Make(funarg) { return bal(l, v, rr); } }; - let union = function (s1, s2) { + let union = (s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -359,7 +357,7 @@ function Make(funarg) { let match$1 = split(v2, s1); return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; - let inter = function (s1, s2) { + let inter = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -377,7 +375,7 @@ function Make(funarg) { return concat(inter(l1, l2), inter(r1, match[2])); } }; - let diff = function (s1, s2) { + let diff = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -395,7 +393,7 @@ function Make(funarg) { return join(diff(l1, l2), v1, diff(r1, match[2])); } }; - let cons_enum = function (_s, _e) { + let cons_enum = (_s, _e) => { while (true) { let e = _e; let s = _s; @@ -412,7 +410,7 @@ function Make(funarg) { continue; }; }; - let compare = function (s1, s2) { + let compare = (s1, s2) => { let _e1 = cons_enum(s1, "End"); let _e2 = cons_enum(s2, "End"); while (true) { @@ -437,10 +435,8 @@ function Make(funarg) { continue; }; }; - let equal = function (s1, s2) { - return compare(s1, s2) === 0; - }; - let subset = function (_s1, _s2) { + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { while (true) { let s2 = _s2; let s1 = _s1; @@ -490,7 +486,7 @@ function Make(funarg) { continue; }; }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -502,7 +498,7 @@ function Make(funarg) { continue; }; }; - let fold = function (f, _s, _accu) { + let fold = (f, _s, _accu) => { while (true) { let accu = _accu; let s = _s; @@ -514,7 +510,7 @@ function Make(funarg) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -530,7 +526,7 @@ function Make(funarg) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -546,7 +542,7 @@ function Make(funarg) { continue; }; }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -566,7 +562,7 @@ function Make(funarg) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -593,14 +589,14 @@ function Make(funarg) { ]; } }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let elements_aux = function (_accu, _param) { + let elements_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -615,10 +611,8 @@ function Make(funarg) { continue; }; }; - let elements = function (s) { - return elements_aux(/* [] */0, s); - }; - let find = function (x, _param) { + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -637,7 +631,7 @@ function Make(funarg) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -671,7 +665,7 @@ function Make(funarg) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -701,7 +695,7 @@ function Make(funarg) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -735,7 +729,7 @@ function Make(funarg) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -765,7 +759,7 @@ function Make(funarg) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -780,7 +774,7 @@ function Make(funarg) { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -798,7 +792,7 @@ function Make(funarg) { return union(l$p, add(v$p, r$p)); } }; - let of_list = function (l) { + let of_list = l => { if (!l) { return "Empty"; } @@ -822,7 +816,7 @@ function Make(funarg) { if (match$3) { if (match$3.tl) { let l$1 = List.sort_uniq(funarg.compare, l); - let sub = function (n, l) { + let sub = (n, l) => { switch (n) { case 0 : return [ diff --git a/lib/es6/setLabels.js b/lib/es6/setLabels.js index 0d96269262..604cad1ec7 100644 --- a/lib/es6/setLabels.js +++ b/lib/es6/setLabels.js @@ -4,14 +4,14 @@ import * as List from "./list.js"; import * as Caml_option from "./caml_option.js"; function Make(Ord) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, v, r) { + let create = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -24,7 +24,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let bal = function (l, v, r) { + let bal = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -87,7 +87,7 @@ function Make(Ord) { } }); }; - let add = function (x, param) { + let add = (x, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -119,30 +119,28 @@ function Make(Ord) { return bal(l, v, rr); } }; - let singleton = function (x) { - return { - TAG: "Node", - l: "Empty", - v: x, - r: "Empty", - h: 1 - }; - }; - let add_min_element = function (x, param) { + let singleton = x => ({ + TAG: "Node", + l: "Empty", + v: x, + r: "Empty", + h: 1 + }); + let add_min_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; - let add_max_element = function (x, param) { + let add_max_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; - let join = function (l, v, r) { + let join = (l, v, r) => { if (typeof l !== "object") { return add_min_element(v, r); } @@ -159,7 +157,7 @@ function Make(Ord) { return create(l, v, r); } }; - let min_elt = function (_param) { + let min_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -177,7 +175,7 @@ function Make(Ord) { continue; }; }; - let min_elt_opt = function (_param) { + let min_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -191,7 +189,7 @@ function Make(Ord) { continue; }; }; - let max_elt = function (_param) { + let max_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -209,7 +207,7 @@ function Make(Ord) { continue; }; }; - let max_elt_opt = function (_param) { + let max_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -223,7 +221,7 @@ function Make(Ord) { continue; }; }; - let remove_min_elt = function (param) { + let remove_min_elt = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -239,7 +237,7 @@ function Make(Ord) { return bal(remove_min_elt(l), param.v, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -248,7 +246,7 @@ function Make(Ord) { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -257,7 +255,7 @@ function Make(Ord) { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -291,14 +289,14 @@ function Make(Ord) { match$1[2] ]; }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -312,7 +310,7 @@ function Make(Ord) { continue; }; }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -338,7 +336,7 @@ function Make(Ord) { return bal(l, v, rr); } }; - let union = function (s1, s2) { + let union = (s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -362,7 +360,7 @@ function Make(Ord) { let match$1 = split(v2, s1); return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; - let inter = function (s1, s2) { + let inter = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -380,7 +378,7 @@ function Make(Ord) { return concat(inter(l1, l2), inter(r1, match[2])); } }; - let diff = function (s1, s2) { + let diff = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -398,7 +396,7 @@ function Make(Ord) { return join(diff(l1, l2), v1, diff(r1, match[2])); } }; - let cons_enum = function (_s, _e) { + let cons_enum = (_s, _e) => { while (true) { let e = _e; let s = _s; @@ -415,7 +413,7 @@ function Make(Ord) { continue; }; }; - let compare_aux = function (_e1, _e2) { + let compare_aux = (_e1, _e2) => { while (true) { let e2 = _e2; let e1 = _e1; @@ -438,13 +436,9 @@ function Make(Ord) { continue; }; }; - let compare = function (s1, s2) { - return compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); - }; - let equal = function (s1, s2) { - return compare(s1, s2) === 0; - }; - let subset = function (_s1, _s2) { + let compare = (s1, s2) => compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { while (true) { let s2 = _s2; let s1 = _s1; @@ -494,7 +488,7 @@ function Make(Ord) { continue; }; }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -506,7 +500,7 @@ function Make(Ord) { continue; }; }; - let fold = function (f, _s, _accu) { + let fold = (f, _s, _accu) => { while (true) { let accu = _accu; let s = _s; @@ -518,7 +512,7 @@ function Make(Ord) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -534,7 +528,7 @@ function Make(Ord) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -550,7 +544,7 @@ function Make(Ord) { continue; }; }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -570,7 +564,7 @@ function Make(Ord) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -597,14 +591,14 @@ function Make(Ord) { ]; } }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let elements_aux = function (_accu, _param) { + let elements_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -619,10 +613,8 @@ function Make(Ord) { continue; }; }; - let elements = function (s) { - return elements_aux(/* [] */0, s); - }; - let find = function (x, _param) { + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -641,7 +633,7 @@ function Make(Ord) { continue; }; }; - let find_first_aux = function (_v0, f, _param) { + let find_first_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -658,7 +650,7 @@ function Make(Ord) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -676,7 +668,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt_aux = function (_v0, f, _param) { + let find_first_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -693,7 +685,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -707,7 +699,7 @@ function Make(Ord) { continue; }; }; - let find_last_aux = function (_v0, f, _param) { + let find_last_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -724,7 +716,7 @@ function Make(Ord) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -742,7 +734,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt_aux = function (_v0, f, _param) { + let find_last_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -759,7 +751,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -773,7 +765,7 @@ function Make(Ord) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -788,14 +780,14 @@ function Make(Ord) { continue; }; }; - let try_join = function (l, v, r) { + let try_join = (l, v, r) => { if ((l === "Empty" || Ord.compare(max_elt(l), v) < 0) && (r === "Empty" || Ord.compare(v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); } }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -811,8 +803,8 @@ function Make(Ord) { return try_join(l$p, v$p, r$p); } }; - let of_sorted_list = function (l) { - let sub = function (n, l) { + let of_sorted_list = l => { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -915,7 +907,7 @@ function Make(Ord) { }; return sub(List.length(l), l)[0]; }; - let of_list = function (l) { + let of_list = l => { if (!l) { return "Empty"; } diff --git a/lib/es6/sort.js b/lib/es6/sort.js index f2c66fedfa..98d609d6e5 100644 --- a/lib/es6/sort.js +++ b/lib/es6/sort.js @@ -24,7 +24,7 @@ function merge(order, l1, l2) { } function list(order, l) { - let initlist = function (param) { + let initlist = param => { if (!param) { return /* [] */0; } @@ -57,7 +57,7 @@ function list(order, l) { tl: initlist(match.tl) }; }; - let merge2 = function (param) { + let merge2 = param => { if (!param) { return param; } @@ -92,7 +92,7 @@ function swap(arr, i, j) { } function array(cmp, arr) { - let qsort = function (_lo, _hi) { + let qsort = (_lo, _hi) => { while (true) { let hi = _hi; let lo = _lo; diff --git a/lib/es6/stream.js b/lib/es6/stream.js index 548760f914..2ed7fbfc14 100644 --- a/lib/es6/stream.js +++ b/lib/es6/stream.js @@ -254,7 +254,7 @@ function empty(s) { } function iter(f, strm) { - let do_rec = function () { + let do_rec = () => { while (true) { let a = peek(strm); if (a === undefined) { @@ -284,12 +284,10 @@ function from(f) { function of_list(l) { return { count: 0, - data: List.fold_right((function (x, l) { - return { - TAG: "Scons", - _0: x, - _1: l - }; + data: List.fold_right((x, l) => ({ + TAG: "Scons", + _0: x, + _1: l }), l, "Sempty") }; } @@ -298,7 +296,7 @@ function of_string(s) { let count = { contents: 0 }; - return from(function (param) { + return from(param => { let c = count.contents; if (c < s.length) { count.contents = count.contents + 1 | 0; @@ -312,7 +310,7 @@ function of_bytes(s) { let count = { contents: 0 }; - return from(function (param) { + return from(param => { let c = count.contents; if (c < s.length) { count.contents = count.contents + 1 | 0; @@ -356,39 +354,31 @@ function ising(i) { } function lapp(f, s) { - let f$1 = function () { - return { - TAG: "Sapp", - _0: data(f()), - _1: data(s) - }; - }; + let f$1 = () => ({ + TAG: "Sapp", + _0: data(f()), + _1: data(s) + }); return { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return f$1(); - }) + _0: CamlinternalLazy.from_fun(() => f$1()) } }; } function lcons(f, s) { - let f$1 = function () { - return { - TAG: "Scons", - _0: f(), - _1: data(s) - }; - }; + let f$1 = () => ({ + TAG: "Scons", + _0: f(), + _1: data(s) + }); return { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return f$1(); - }) + _0: CamlinternalLazy.from_fun(() => f$1()) } }; } @@ -398,13 +388,11 @@ function lsing(f) { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return { - TAG: "Scons", - _0: f(), - _1: "Sempty" - }; - }) + _0: CamlinternalLazy.from_fun(() => ({ + TAG: "Scons", + _0: f(), + _1: "Sempty" + })) } }; } @@ -414,9 +402,7 @@ function slazy(f) { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return data(f()); - }) + _0: CamlinternalLazy.from_fun(() => data(f())) } }; } diff --git a/lib/es6/string.js b/lib/es6/string.js index c19e2db03c..85e4d17c82 100644 --- a/lib/es6/string.js +++ b/lib/es6/string.js @@ -55,7 +55,7 @@ function trim(s) { } function escaped(s) { - let needs_escape = function (_i) { + let needs_escape = _i => { while (true) { let i = _i; if (i >= s.length) { diff --git a/lib/es6/stringLabels.js b/lib/es6/stringLabels.js index 74f7f99d18..72980fb1bb 100644 --- a/lib/es6/stringLabels.js +++ b/lib/es6/stringLabels.js @@ -57,7 +57,7 @@ function trim(s) { } function escaped(s) { - let needs_escape = function (_i) { + let needs_escape = _i => { while (true) { let i = _i; if (i >= s.length) { diff --git a/lib/js/arg.js b/lib/js/arg.js index e06814b14b..89c4a76246 100644 --- a/lib/js/arg.js +++ b/lib/js/arg.js @@ -50,9 +50,7 @@ function split(s) { function make_symlist(prefix, sep, suffix, l) { if (l) { - return List.fold_left((function (x, y) { - return x + (sep + y); - }), prefix + l.hd, l.tl) + suffix; + return List.fold_left((x, y) => x + (sep + y), prefix + l.hd, l.tl) + suffix; } else { return ""; } @@ -124,7 +122,7 @@ function add_help(speclist) { function usage_b(buf, speclist, errmsg) { Buffer.add_string(buf, errmsg + "\n"); - List.iter((function (x) { + List.iter(x => { let doc = x[2]; if (doc.length === 0) { return; @@ -136,7 +134,7 @@ function usage_b(buf, speclist, errmsg) { } let sym = make_symlist("{", "|", "}", spec._0); Buffer.add_string(buf, " " + key + " " + sym + doc + "\n"); - }), add_help(speclist)); + }, add_help(speclist)); } function usage_string(speclist, errmsg) { @@ -197,7 +195,7 @@ function float_of_string_opt(x) { function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist, anonfun, errmsg) { let initpos = current.contents; - let convert_error = function (error) { + let convert_error = error => { let b = Buffer.create(200); let progname = initpos < argv.contents.length ? Caml_array.get(argv.contents, initpos) : "(?)"; switch (error.TAG) { @@ -284,7 +282,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist } } let follow = match[1]; - let no_arg = function () { + let no_arg = () => { if (follow === undefined) { return; } @@ -300,7 +298,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist } }); }; - let get_arg = function () { + let get_arg = () => { if (follow !== undefined) { return follow; } @@ -317,7 +315,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist } }); }; - let consume_arg = function () { + let consume_arg = () => { if (follow !== undefined) { return; } else { @@ -325,7 +323,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist return; } }; - let treat_action = function (f) { + let treat_action = f => { switch (f.TAG) { case "Unit" : return f._0(); @@ -609,7 +607,7 @@ function parse_expand(l, f, msg) { function second_word(s) { let len = s.length; - let loop = function (_n) { + let loop = _n => { while (true) { let n = _n; if (n >= len) { @@ -668,14 +666,14 @@ function replace_leading_tab(s) { let seen = { contents: false }; - return $$String.map((function (c) { + return $$String.map(c => { if (c !== 9 || seen.contents) { return c; } else { seen.contents = true; return /* ' ' */32; } - }), s); + }, s); } function align(limitOpt, speclist) { @@ -683,7 +681,7 @@ function align(limitOpt, speclist) { let completed = add_help(speclist); let len = List.fold_left(max_arg_len, 0, completed); let len$1 = len < limit ? len : limit; - return List.map((function (x) { + return List.map(x => { let spec = x[1]; let kwd = x[0]; if (x[2] === "") { @@ -718,7 +716,7 @@ function align(limitOpt, speclist) { spec, prefix + (spaces$1 + suffix) ]; - }), completed); + }, completed); } exports.parse = parse; diff --git a/lib/js/array.js b/lib/js/array.js index 81d2af9cb4..8bdf08b552 100644 --- a/lib/js/array.js +++ b/lib/js/array.js @@ -299,7 +299,7 @@ function memq(x, a) { let Bottom = /* @__PURE__ */Caml_exceptions.create("Array.Bottom"); function sort(cmp, a) { - let maxson = function (l, i) { + let maxson = (l, i) => { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { @@ -324,7 +324,7 @@ function sort(cmp, a) { } }); }; - let trickle = function (l, i, e) { + let trickle = (l, i, e) => { try { let _i = i; while (true) { @@ -347,7 +347,7 @@ function sort(cmp, a) { }); } }; - let bubble = function (l, i) { + let bubble = (l, i) => { try { let _i = i; while (true) { @@ -367,7 +367,7 @@ function sort(cmp, a) { }); } }; - let trickleup = function (_i, e) { + let trickleup = (_i, e) => { while (true) { let i = _i; let father = (i - 1 | 0) / 3 | 0; @@ -412,7 +412,7 @@ function sort(cmp, a) { } function stable_sort(cmp, a) { - let merge = function (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { let src1r = src1ofs + src1len | 0; let src2r = src2ofs + src2len | 0; let _i1 = src1ofs; @@ -448,7 +448,7 @@ function stable_sort(cmp, a) { continue; }; }; - let isortto = function (srcofs, dst, dstofs, len) { + let isortto = (srcofs, dst, dstofs, len) => { for (let i = 0; i < len; ++i) { let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; @@ -459,7 +459,7 @@ function stable_sort(cmp, a) { Caml_array.set(dst, j + 1 | 0, e); } }; - let sortto = function (srcofs, dst, dstofs, len) { + let sortto = (srcofs, dst, dstofs, len) => { if (len <= 5) { return isortto(srcofs, dst, dstofs, len); } diff --git a/lib/js/arrayLabels.js b/lib/js/arrayLabels.js index cd50a85c00..cc4be0533e 100644 --- a/lib/js/arrayLabels.js +++ b/lib/js/arrayLabels.js @@ -299,7 +299,7 @@ function memq(x, a) { let Bottom = /* @__PURE__ */Caml_exceptions.create("ArrayLabels.Bottom"); function sort(cmp, a) { - let maxson = function (l, i) { + let maxson = (l, i) => { let i31 = ((i + i | 0) + i | 0) + 1 | 0; let x = i31; if ((i31 + 2 | 0) < l) { @@ -324,7 +324,7 @@ function sort(cmp, a) { } }); }; - let trickle = function (l, i, e) { + let trickle = (l, i, e) => { try { let _i = i; while (true) { @@ -347,7 +347,7 @@ function sort(cmp, a) { }); } }; - let bubble = function (l, i) { + let bubble = (l, i) => { try { let _i = i; while (true) { @@ -367,7 +367,7 @@ function sort(cmp, a) { }); } }; - let trickleup = function (_i, e) { + let trickleup = (_i, e) => { while (true) { let i = _i; let father = (i - 1 | 0) / 3 | 0; @@ -412,7 +412,7 @@ function sort(cmp, a) { } function stable_sort(cmp, a) { - let merge = function (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { let src1r = src1ofs + src1len | 0; let src2r = src2ofs + src2len | 0; let _i1 = src1ofs; @@ -448,7 +448,7 @@ function stable_sort(cmp, a) { continue; }; }; - let isortto = function (srcofs, dst, dstofs, len) { + let isortto = (srcofs, dst, dstofs, len) => { for (let i = 0; i < len; ++i) { let e = Caml_array.get(a, srcofs + i | 0); let j = (dstofs + i | 0) - 1 | 0; @@ -459,7 +459,7 @@ function stable_sort(cmp, a) { Caml_array.set(dst, j + 1 | 0, e); } }; - let sortto = function (srcofs, dst, dstofs, len) { + let sortto = (srcofs, dst, dstofs, len) => { if (len <= 5) { return isortto(srcofs, dst, dstofs, len); } diff --git a/lib/js/belt_Array.js b/lib/js/belt_Array.js index 6a48e4f348..db7b6440a2 100644 --- a/lib/js/belt_Array.js +++ b/lib/js/belt_Array.js @@ -59,9 +59,7 @@ function swapUnsafe(xs, i, j) { function shuffleInPlace(xs) { let len = xs.length; - let random_int = function (min, max) { - return Math.floor(Math.random() * (max - min | 0)) + min | 0; - }; + let random_int = (min, max) => Math.floor(Math.random() * (max - min | 0)) + min | 0; for (let i = 0; i < len; ++i) { swapUnsafe(xs, i, random_int(i, len)); } diff --git a/lib/js/belt_MapDict.js b/lib/js/belt_MapDict.js index 8522d77890..a4581f83e9 100644 --- a/lib/js/belt_MapDict.js +++ b/lib/js/belt_MapDict.js @@ -196,17 +196,13 @@ function split(n, x, cmp) { function merge(s1, s2, f, cmp) { if (s1 === undefined) { if (s2 !== undefined) { - return Belt_internalAVLtree.keepMap(s2, (function (k, v) { - return f(k, undefined, Caml_option.some(v)); - })); + return Belt_internalAVLtree.keepMap(s2, (k, v) => f(k, undefined, Caml_option.some(v))); } else { return; } } if (s2 === undefined) { - return Belt_internalAVLtree.keepMap(s1, (function (k, v) { - return f(k, Caml_option.some(v), undefined); - })); + return Belt_internalAVLtree.keepMap(s1, (k, v) => f(k, Caml_option.some(v), undefined)); } if (s1.h >= s2.h) { let v1 = s1.k; diff --git a/lib/js/belt_internalAVLset.js b/lib/js/belt_internalAVLset.js index dd45a21036..bd0e013f01 100644 --- a/lib/js/belt_internalAVLset.js +++ b/lib/js/belt_internalAVLset.js @@ -827,9 +827,7 @@ function fromArray(xs, cmp) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (x, y) { - return cmp(x, y) < 0; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (x, y) => cmp(x, y) < 0); let result; if (next >= 0) { result = fromSortedArrayAux(xs, 0, next); diff --git a/lib/js/belt_internalAVLtree.js b/lib/js/belt_internalAVLtree.js index abf3c13607..825157acc4 100644 --- a/lib/js/belt_internalAVLtree.js +++ b/lib/js/belt_internalAVLtree.js @@ -1001,9 +1001,7 @@ function fromArray(xs, cmp) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (param, param$1) { - return cmp(param[0], param$1[0]) < 0; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (param, param$1) => cmp(param[0], param$1[0]) < 0); let result; if (next >= 0) { result = fromSortedArrayAux(xs, 0, next); diff --git a/lib/js/belt_internalBuckets.js b/lib/js/belt_internalBuckets.js index d09ba28760..159c1934fd 100644 --- a/lib/js/belt_internalBuckets.js +++ b/lib/js/belt_internalBuckets.js @@ -108,25 +108,23 @@ function reduce(h, init, f) { } function getMaxBucketLength(h) { - return Belt_Array.reduce(h.buckets, 0, (function (m, b) { + return Belt_Array.reduce(h.buckets, 0, (m, b) => { let len = bucketLength(0, b); if (m > len) { return m; } else { return len; } - })); + }); } function getBucketHistogram(h) { let mbl = getMaxBucketLength(h); - let histo = Belt_Array.makeBy(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEach(h.buckets, (function (b) { + let histo = Belt_Array.makeBy(mbl + 1 | 0, param => 0); + Belt_Array.forEach(h.buckets, b => { let l = bucketLength(0, b); histo[l] = histo[l] + 1 | 0; - })); + }); return histo; } @@ -233,24 +231,18 @@ function linear(h, f) { } function keysToArray(h) { - return linear(h, (function (x) { - return x.key; - })); + return linear(h, x => x.key); } function valuesToArray(h) { - return linear(h, (function (x) { - return x.value; - })); + return linear(h, x => x.value); } function toArray(h) { - return linear(h, (function (x) { - return [ - x.key, - x.value - ]; - })); + return linear(h, x => [ + x.key, + x.value + ]); } let C; diff --git a/lib/js/belt_internalMapInt.js b/lib/js/belt_internalMapInt.js index c7558033f2..033567d0f4 100644 --- a/lib/js/belt_internalMapInt.js +++ b/lib/js/belt_internalMapInt.js @@ -303,9 +303,7 @@ function fromArray(xs) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (param, param$1) => param[0] < param$1[0]); let result; if (next >= 0) { result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); diff --git a/lib/js/belt_internalMapString.js b/lib/js/belt_internalMapString.js index fee0b6cb21..0db017ec4e 100644 --- a/lib/js/belt_internalMapString.js +++ b/lib/js/belt_internalMapString.js @@ -303,9 +303,7 @@ function fromArray(xs) { if (len === 0) { return; } - let next = Belt_SortArray.strictlySortedLength(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); + let next = Belt_SortArray.strictlySortedLength(xs, (param, param$1) => param[0] < param$1[0]); let result; if (next >= 0) { result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); diff --git a/lib/js/belt_internalSetBuckets.js b/lib/js/belt_internalSetBuckets.js index 5484d3296a..c899bd03dd 100644 --- a/lib/js/belt_internalSetBuckets.js +++ b/lib/js/belt_internalSetBuckets.js @@ -134,25 +134,23 @@ function reduce(h, init, f) { } function getMaxBucketLength(h) { - return Belt_Array.reduce(h.buckets, 0, (function (m, b) { + return Belt_Array.reduce(h.buckets, 0, (m, b) => { let len = bucketLength(0, b); if (m > len) { return m; } else { return len; } - })); + }); } function getBucketHistogram(h) { let mbl = getMaxBucketLength(h); - let histo = Belt_Array.makeBy(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEach(h.buckets, (function (b) { + let histo = Belt_Array.makeBy(mbl + 1 | 0, param => 0); + Belt_Array.forEach(h.buckets, b => { let l = bucketLength(0, b); histo[l] = histo[l] + 1 | 0; - })); + }); return histo; } diff --git a/lib/js/caml_format.js b/lib/js/caml_format.js index c272d1b695..7ec916dc57 100644 --- a/lib/js/caml_format.js +++ b/lib/js/caml_format.js @@ -136,7 +136,7 @@ function int_of_string(s) { } }); } - let aux = function (_acc, _k) { + let aux = (_acc, _k) => { while (true) { let k = _k; let acc = _acc; @@ -225,7 +225,7 @@ function int64_of_string(s) { } }); } - let aux = function (_acc, _k) { + let aux = (_acc, _k) => { while (true) { let k = _k; let acc = _acc; @@ -404,7 +404,7 @@ function parse_format(fmt) { case 46 : f.prec = 0; let j = i + 1 | 0; - while ((function () { + while ((() => { let w = fmt.codePointAt(j) - 48 | 0; return w >= 0 && w <= 9; })()) { @@ -443,7 +443,7 @@ function parse_format(fmt) { case 3 : f.width = 0; let j$1 = i; - while ((function () { + while ((() => { let w = fmt.codePointAt(j$1) - 48 | 0; return w >= 0 && w <= 9; })()) { @@ -676,7 +676,7 @@ function format_float(fmt, x) { p = p - (exp + 1 | 0) | 0; s = x$1.toFixed(p); } else { - while ((function () { + while ((() => { s = x$1.toFixed(p); return s.length > (prec$1 + 1 | 0); })()) { diff --git a/lib/js/caml_hash.js b/lib/js/caml_hash.js index 0fbd07cb73..76a6293626 100644 --- a/lib/js/caml_hash.js +++ b/lib/js/caml_hash.js @@ -84,9 +84,7 @@ function hash(count, _limit, seed, obj) { ++ size } return size - })(obj$1, (function (v) { - push_back(queue, v); - })); + })(obj$1, v => push_back(queue, v)); s = Caml_hash_primitive.hash_mix_int(s, (size$1 << 10) | 0); } } diff --git a/lib/js/caml_int64.js b/lib/js/caml_int64.js index 10e77156ba..dcb3f8e08c 100644 --- a/lib/js/caml_int64.js +++ b/lib/js/caml_int64.js @@ -527,9 +527,7 @@ function to_int32(x) { function to_hex(x) { let x_lo = x[1]; let x_hi = x[0]; - let aux = function (v) { - return (v >>> 0).toString(16); - }; + let aux = v => (v >>> 0).toString(16); if (x_hi === 0 && x_lo === 0) { return "0"; } diff --git a/lib/js/caml_module.js b/lib/js/caml_module.js index 32846e33c2..b601cf66dd 100644 --- a/lib/js/caml_module.js +++ b/lib/js/caml_module.js @@ -3,7 +3,7 @@ let Caml_obj = require("./caml_obj.js"); function init_mod(loc, shape) { - let undef_module = function (param) { + let undef_module = param => { throw new Error("Undefined_recursive_module", { cause: { RE_EXN_ID: "Undefined_recursive_module", @@ -11,7 +11,7 @@ function init_mod(loc, shape) { } }); }; - let loop = function (shape, struct_, idx) { + let loop = (shape, struct_, idx) => { if (typeof shape !== "object") { switch (shape) { case "Function" : @@ -50,7 +50,7 @@ function init_mod(loc, shape) { } function update_mod(shape, o, n) { - let aux = function (shape, o, n, parent, i) { + let aux = (shape, o, n, parent, i) => { if (typeof shape !== "object") { switch (shape) { case "Function" : diff --git a/lib/js/caml_obj.js b/lib/js/caml_obj.js index 65e0d78ebc..0b3f182a11 100644 --- a/lib/js/caml_obj.js +++ b/lib/js/caml_obj.js @@ -211,7 +211,7 @@ function aux_obj_compare(a, b) { let min_key_rhs = { contents: undefined }; - let do_key = function (param, key) { + let do_key = (param, key) => { let min_key = param[2]; let b = param[1]; if (!(!Object.prototype.hasOwnProperty.call(b, key) || compare(param[0][key], b[key]) > 0)) { @@ -225,20 +225,16 @@ function aux_obj_compare(a, b) { return; } }; - let do_key_a = function (key) { - do_key([ - a, - b, - min_key_rhs - ], key); - }; - let do_key_b = function (key) { - do_key([ - b, - a, - min_key_lhs - ], key); - }; + let do_key_a = key => do_key([ + a, + b, + min_key_rhs + ], key); + let do_key_b = key => do_key([ + b, + a, + min_key_lhs + ], key); for_in(a, do_key_a); for_in(b, do_key_b); let match = min_key_lhs.contents; @@ -314,14 +310,14 @@ function equal(a, b) { let result = { contents: true }; - let do_key_a = function (key) { + let do_key_a = key => { if (!Object.prototype.hasOwnProperty.call(b, key)) { result.contents = false; return; } }; - let do_key_b = function (key) { + let do_key_b = key => { if (!Object.prototype.hasOwnProperty.call(a, key) || !equal(b[key], a[key])) { result.contents = false; return; diff --git a/lib/js/camlinternalLazy.js b/lib/js/camlinternalLazy.js index a1f4efec8a..b92f4ac145 100644 --- a/lib/js/camlinternalLazy.js +++ b/lib/js/camlinternalLazy.js @@ -32,11 +32,11 @@ function force(lzv) { try { return forward_with_closure(lzv, closure); } catch (e) { - lzv.VAL = (function () { + lzv.VAL = () => { throw new Error(e.RE_EXN_ID, { cause: e }); - }); + }; throw new Error(e.RE_EXN_ID, { cause: e }); diff --git a/lib/js/curry.js b/lib/js/curry.js index 54c46389bf..5b6f7bd1eb 100644 --- a/lib/js/curry.js +++ b/lib/js/curry.js @@ -14,9 +14,7 @@ function app(_f, _args) { return f.apply(null, args); } if (d >= 0) { - return function (x) { - return app(f, args.concat([x])); - }; + return x => app(f, args.concat([x])); } _args = Caml_array.sub(args, arity, -d | 0); _f = f.apply(null, Caml_array.sub(args, 0, arity)); @@ -33,29 +31,17 @@ function _1(o, a0) { case 1 : return o(a0); case 2 : - return function (param) { - return o(a0, param); - }; + return param => o(a0, param); case 3 : - return function (param, param$1) { - return o(a0, param, param$1); - }; + return (param, param$1) => o(a0, param, param$1); case 4 : - return function (param, param$1, param$2) { - return o(a0, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, param, param$1, param$2); case 5 : - return function (param, param$1, param$2, param$3) { - return o(a0, param, param$1, param$2, param$3); - }; + return (param, param$1, param$2, param$3) => o(a0, param, param$1, param$2, param$3); case 6 : - return function (param, param$1, param$2, param$3, param$4) { - return o(a0, param, param$1, param$2, param$3, param$4); - }; + return (param, param$1, param$2, param$3, param$4) => o(a0, param, param$1, param$2, param$3, param$4); case 7 : - return function (param, param$1, param$2, param$3, param$4, param$5) { - return o(a0, param, param$1, param$2, param$3, param$4, param$5); - }; + return (param, param$1, param$2, param$3, param$4, param$5) => o(a0, param, param$1, param$2, param$3, param$4, param$5); default: return app(o, [a0]); } @@ -67,9 +53,7 @@ function __1(o) { if (arity === 1) { return o; } else { - return function (a0) { - return _1(o, a0); - }; + return a0 => _1(o, a0); } } @@ -84,25 +68,15 @@ function _2(o, a0, a1) { case 2 : return o(a0, a1); case 3 : - return function (param) { - return o(a0, a1, param); - }; + return param => o(a0, a1, param); case 4 : - return function (param, param$1) { - return o(a0, a1, param, param$1); - }; + return (param, param$1) => o(a0, a1, param, param$1); case 5 : - return function (param, param$1, param$2) { - return o(a0, a1, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, a1, param, param$1, param$2); case 6 : - return function (param, param$1, param$2, param$3) { - return o(a0, a1, param, param$1, param$2, param$3); - }; + return (param, param$1, param$2, param$3) => o(a0, a1, param, param$1, param$2, param$3); case 7 : - return function (param, param$1, param$2, param$3, param$4) { - return o(a0, a1, param, param$1, param$2, param$3, param$4); - }; + return (param, param$1, param$2, param$3, param$4) => o(a0, a1, param, param$1, param$2, param$3, param$4); default: return app(o, [ a0, @@ -117,9 +91,7 @@ function __2(o) { if (arity === 2) { return o; } else { - return function (a0, a1) { - return _2(o, a0, a1); - }; + return (a0, a1) => _2(o, a0, a1); } } @@ -139,21 +111,13 @@ function _3(o, a0, a1, a2) { case 3 : return o(a0, a1, a2); case 4 : - return function (param) { - return o(a0, a1, a2, param); - }; + return param => o(a0, a1, a2, param); case 5 : - return function (param, param$1) { - return o(a0, a1, a2, param, param$1); - }; + return (param, param$1) => o(a0, a1, a2, param, param$1); case 6 : - return function (param, param$1, param$2) { - return o(a0, a1, a2, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, a1, a2, param, param$1, param$2); case 7 : - return function (param, param$1, param$2, param$3) { - return o(a0, a1, a2, param, param$1, param$2, param$3); - }; + return (param, param$1, param$2, param$3) => o(a0, a1, a2, param, param$1, param$2, param$3); default: return app(o, [ a0, @@ -169,9 +133,7 @@ function __3(o) { if (arity === 3) { return o; } else { - return function (a0, a1, a2) { - return _3(o, a0, a1, a2); - }; + return (a0, a1, a2) => _3(o, a0, a1, a2); } } @@ -197,17 +159,11 @@ function _4(o, a0, a1, a2, a3) { case 4 : return o(a0, a1, a2, a3); case 5 : - return function (param) { - return o(a0, a1, a2, a3, param); - }; + return param => o(a0, a1, a2, a3, param); case 6 : - return function (param, param$1) { - return o(a0, a1, a2, a3, param, param$1); - }; + return (param, param$1) => o(a0, a1, a2, a3, param, param$1); case 7 : - return function (param, param$1, param$2) { - return o(a0, a1, a2, a3, param, param$1, param$2); - }; + return (param, param$1, param$2) => o(a0, a1, a2, a3, param, param$1, param$2); default: return app(o, [ a0, @@ -224,9 +180,7 @@ function __4(o) { if (arity === 4) { return o; } else { - return function (a0, a1, a2, a3) { - return _4(o, a0, a1, a2, a3); - }; + return (a0, a1, a2, a3) => _4(o, a0, a1, a2, a3); } } @@ -259,13 +213,9 @@ function _5(o, a0, a1, a2, a3, a4) { case 5 : return o(a0, a1, a2, a3, a4); case 6 : - return function (param) { - return o(a0, a1, a2, a3, a4, param); - }; + return param => o(a0, a1, a2, a3, a4, param); case 7 : - return function (param, param$1) { - return o(a0, a1, a2, a3, a4, param, param$1); - }; + return (param, param$1) => o(a0, a1, a2, a3, a4, param, param$1); default: return app(o, [ a0, @@ -283,9 +233,7 @@ function __5(o) { if (arity === 5) { return o; } else { - return function (a0, a1, a2, a3, a4) { - return _5(o, a0, a1, a2, a3, a4); - }; + return (a0, a1, a2, a3, a4) => _5(o, a0, a1, a2, a3, a4); } } @@ -326,9 +274,7 @@ function _6(o, a0, a1, a2, a3, a4, a5) { case 6 : return o(a0, a1, a2, a3, a4, a5); case 7 : - return function (param) { - return o(a0, a1, a2, a3, a4, a5, param); - }; + return param => o(a0, a1, a2, a3, a4, a5, param); default: return app(o, [ a0, @@ -347,9 +293,7 @@ function __6(o) { if (arity === 6) { return o; } else { - return function (a0, a1, a2, a3, a4, a5) { - return _6(o, a0, a1, a2, a3, a4, a5); - }; + return (a0, a1, a2, a3, a4, a5) => _6(o, a0, a1, a2, a3, a4, a5); } } @@ -417,9 +361,7 @@ function __7(o) { if (arity === 7) { return o; } else { - return function (a0, a1, a2, a3, a4, a5, a6) { - return _7(o, a0, a1, a2, a3, a4, a5, a6); - }; + return (a0, a1, a2, a3, a4, a5, a6) => _7(o, a0, a1, a2, a3, a4, a5, a6); } } @@ -496,9 +438,7 @@ function __8(o) { if (arity === 8) { return o; } else { - return function (a0, a1, a2, a3, a4, a5, a6, a7) { - return _8(o, a0, a1, a2, a3, a4, a5, a6, a7); - }; + return (a0, a1, a2, a3, a4, a5, a6, a7) => _8(o, a0, a1, a2, a3, a4, a5, a6, a7); } } diff --git a/lib/js/digest.js b/lib/js/digest.js index 103d5c8fa9..1630c5a8a8 100644 --- a/lib/js/digest.js +++ b/lib/js/digest.js @@ -64,7 +64,7 @@ function from_hex(s) { } }); } - let digit = function (c) { + let digit = c => { if (c >= 65) { if (c >= 97) { if (c >= 103) { @@ -97,9 +97,7 @@ function from_hex(s) { } return c - /* '0' */48 | 0; }; - let byte = function (i) { - return (digit(Caml_string.get(s, i)) << 4) + digit(Caml_string.get(s, i + 1 | 0)) | 0; - }; + let byte = i => (digit(Caml_string.get(s, i)) << 4) + digit(Caml_string.get(s, i + 1 | 0)) | 0; let result = Caml_bytes.create(16); for (let i = 0; i <= 15; ++i) { Caml_bytes.set(result, i, Char.chr(byte((i << 1)))); diff --git a/lib/js/filename.js b/lib/js/filename.js index 4cbda61834..293fb0b731 100644 --- a/lib/js/filename.js +++ b/lib/js/filename.js @@ -215,7 +215,7 @@ function quote$1(s) { let l = s.length; let b = Buffer.create(l + 20 | 0); Buffer.add_char(b, /* '"' */34); - let loop = function (_i) { + let loop = _i => { while (true) { let i = _i; if (i === l) { @@ -233,7 +233,7 @@ function quote$1(s) { continue; }; }; - let loop_bs = function (_n, _i) { + let loop_bs = (_n, _i) => { while (true) { let i = _i; let n = _n; @@ -256,7 +256,7 @@ function quote$1(s) { return loop(i + 1 | 0); }; }; - let add_bs = function (n) { + let add_bs = n => { for (let _j = 1; _j <= n; ++_j) { Buffer.add_char(b, /* '\\' */92); } @@ -266,7 +266,7 @@ function quote$1(s) { } function has_drive(s) { - let is_letter = function (param) { + let is_letter = param => { if (param >= 91) { return !(param > 122 || param < 97); } else { diff --git a/lib/js/genlex.js b/lib/js/genlex.js index e708d6239b..0b989249f2 100644 --- a/lib/js/genlex.js +++ b/lib/js/genlex.js @@ -43,13 +43,11 @@ function get_string() { function make_lexer(keywords) { let kwd_table = Hashtbl.create(undefined, 17); - List.iter((function (s) { - Hashtbl.add(kwd_table, s, { - TAG: "Kwd", - _0: s - }); + List.iter(s => Hashtbl.add(kwd_table, s, { + TAG: "Kwd", + _0: s }), keywords); - let ident_or_keyword = function (id) { + let ident_or_keyword = id => { try { return Hashtbl.find(kwd_table, id); } catch (raw_exn) { @@ -65,7 +63,7 @@ function make_lexer(keywords) { }); } }; - let keyword_or_error = function (c) { + let keyword_or_error = c => { let s = Caml_string.make(1, c); try { return Hashtbl.find(kwd_table, s); @@ -84,7 +82,7 @@ function make_lexer(keywords) { }); } }; - let next_token = function (strm__) { + let next_token = strm__ => { while (true) { let c = Stream.peek(strm__); if (c === undefined) { @@ -310,7 +308,7 @@ function make_lexer(keywords) { } }; }; - let ident2 = function (strm__) { + let ident2 = strm__ => { while (true) { let c = Stream.peek(strm__); if (c === undefined) { @@ -377,7 +375,7 @@ function make_lexer(keywords) { continue; }; }; - let number = function (strm__) { + let number = strm__ => { while (true) { let c = Stream.peek(strm__); if (c !== undefined) { @@ -428,7 +426,7 @@ function make_lexer(keywords) { }; }; }; - let exponent_part = function (strm__) { + let exponent_part = strm__ => { let c = Stream.peek(strm__); if (c !== undefined && !(c !== 43 && c !== 45)) { Stream.junk(strm__); @@ -438,7 +436,7 @@ function make_lexer(keywords) { return end_exponent_part(strm__); } }; - let end_exponent_part = function (strm__) { + let end_exponent_part = strm__ => { while (true) { let c = Stream.peek(strm__); if (c === undefined) { @@ -458,7 +456,7 @@ function make_lexer(keywords) { continue; }; }; - let string = function (strm__) { + let string = strm__ => { while (true) { let c = Stream.peek(strm__); if (c !== undefined) { @@ -499,7 +497,7 @@ function make_lexer(keywords) { }); }; }; - let char = function (strm__) { + let char = strm__ => { let c = Stream.peek(strm__); if (c !== undefined) { if (c !== 92) { @@ -531,7 +529,7 @@ function make_lexer(keywords) { }); } }; - let escape = function (strm__) { + let escape = strm__ => { let c1 = Stream.peek(strm__); if (c1 !== undefined) { if (c1 >= 58) { @@ -601,7 +599,7 @@ function make_lexer(keywords) { }); } }; - let comment = function (strm__) { + let comment = strm__ => { while (true) { let match = Stream.peek(strm__); if (match !== undefined) { @@ -659,11 +657,7 @@ function make_lexer(keywords) { } }; }; - return function (input) { - return Stream.from(function (_count) { - return next_token(input); - }); - }; + return input => Stream.from(_count => next_token(input)); } exports.make_lexer = make_lexer; diff --git a/lib/js/hashtbl.js b/lib/js/hashtbl.js index 112833ee17..b22fa9064a 100644 --- a/lib/js/hashtbl.js +++ b/lib/js/hashtbl.js @@ -38,9 +38,7 @@ function is_randomized() { return randomized.contents; } -let prng = CamlinternalLazy.from_fun(function () { - return Random.State.make_self_init(); -}); +let prng = CamlinternalLazy.from_fun(() => Random.State.make_self_init()); function power_2_above(_x, n) { while (true) { @@ -94,7 +92,7 @@ function copy_bucketlist(param) { let key = param.key; let data = param.data; let next = param.next; - let loop = function (_prec, _param) { + let loop = (_prec, _param) => { while (true) { let param = _param; let prec = _prec; @@ -162,7 +160,7 @@ function resize(indexfun, h) { let ndata_tail = Caml_array.make(nsize, "Empty"); let inplace = h.initial_size >= 0; h.data = ndata; - let insert_bucket = function (_param) { + let insert_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -362,7 +360,7 @@ function find_opt(h, key) { } function find_all(h, key) { - let find_in_bucket = function (_param) { + let find_in_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -440,7 +438,7 @@ function mem(h, key) { } function iter(f, h) { - let do_bucket = function (_param) { + let do_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -539,7 +537,7 @@ function filter_map_inplace(f, h) { } function fold(f, h, init) { - let do_bucket = function (_b, _accu) { + let do_bucket = (_b, _accu) => { while (true) { let accu = _accu; let b = _b; @@ -596,14 +594,12 @@ function bucket_length(_accu, _param) { } function stats(h) { - let mbl = $$Array.fold_left((function (m, b) { - return Caml.int_max(m, bucket_length(0, b)); - }), 0, h.data); + let mbl = $$Array.fold_left((m, b) => Caml.int_max(m, bucket_length(0, b)), 0, h.data); let histo = Caml_array.make(mbl + 1 | 0, 0); - $$Array.iter((function (b) { + $$Array.iter(b => { let l = bucket_length(0, b); Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); - }), h.data); + }, h.data); return { num_bindings: h.size, num_buckets: h.data.length, @@ -613,10 +609,8 @@ function stats(h) { } function MakeSeeded(H) { - let key_index = function (h, key) { - return H.hash(h.seed, key) & (h.data.length - 1 | 0); - }; - let add = function (h, key, data) { + let key_index = (h, key) => H.hash(h.seed, key) & (h.data.length - 1 | 0); + let add = (h, key, data) => { let i = key_index(h, key); let bucket = { TAG: "Cons", @@ -631,7 +625,7 @@ function MakeSeeded(H) { } }; - let remove = function (h, key) { + let remove = (h, key) => { let i = key_index(h, key); let _prec = "Empty"; let _param = Caml_array.get(h.data, i); @@ -657,7 +651,7 @@ function MakeSeeded(H) { continue; }; }; - let find = function (h, key) { + let find = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { throw new Error("Not_found", { @@ -719,7 +713,7 @@ function MakeSeeded(H) { }; } }; - let find_opt = function (h, key) { + let find_opt = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { return; @@ -765,8 +759,8 @@ function MakeSeeded(H) { }; } }; - let find_all = function (h, key) { - let find_in_bucket = function (_param) { + let find_all = (h, key) => { + let find_in_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -787,7 +781,7 @@ function MakeSeeded(H) { }; return find_in_bucket(Caml_array.get(h.data, key_index(h, key))); }; - let replace_bucket = function (key, data, _param) { + let replace_bucket = (key, data, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -804,7 +798,7 @@ function MakeSeeded(H) { continue; }; }; - let replace = function (h, key, data) { + let replace = (h, key, data) => { let i = key_index(h, key); let l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { @@ -823,7 +817,7 @@ function MakeSeeded(H) { } }; - let mem = function (h, key) { + let mem = (h, key) => { let _param = Caml_array.get(h.data, key_index(h, key)); while (true) { let param = _param; @@ -861,10 +855,8 @@ 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); - }; - let add = function (h, key, data) { + let key_index = (h, key) => H.hash(key) & (h.data.length - 1 | 0); + let add = (h, key, data) => { let i = key_index(h, key); let bucket = { TAG: "Cons", @@ -879,7 +871,7 @@ function Make(H) { } }; - let remove = function (h, key) { + let remove = (h, key) => { let i = key_index(h, key); let _prec = "Empty"; let _param = Caml_array.get(h.data, i); @@ -905,7 +897,7 @@ function Make(H) { continue; }; }; - let find = function (h, key) { + let find = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { throw new Error("Not_found", { @@ -967,7 +959,7 @@ function Make(H) { }; } }; - let find_opt = function (h, key) { + let find_opt = (h, key) => { let match = Caml_array.get(h.data, key_index(h, key)); if (typeof match !== "object") { return; @@ -1013,8 +1005,8 @@ function Make(H) { }; } }; - let find_all = function (h, key) { - let find_in_bucket = function (_param) { + let find_all = (h, key) => { + let find_in_bucket = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1035,7 +1027,7 @@ function Make(H) { }; return find_in_bucket(Caml_array.get(h.data, key_index(h, key))); }; - let replace_bucket = function (key, data, _param) { + let replace_bucket = (key, data, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1052,7 +1044,7 @@ function Make(H) { continue; }; }; - let replace = function (h, key, data) { + let replace = (h, key, data) => { let i = key_index(h, key); let l = Caml_array.get(h.data, i); if (replace_bucket(key, data, l)) { @@ -1071,7 +1063,7 @@ function Make(H) { } }; - let mem = function (h, key) { + let mem = (h, key) => { let _param = Caml_array.get(h.data, key_index(h, key)); while (true) { let param = _param; @@ -1087,9 +1079,7 @@ function Make(H) { continue; }; }; - let create$1 = function (sz) { - return create(false, sz); - }; + let create$1 = sz => create(false, sz); return { create: create$1, clear: clear, diff --git a/lib/js/hashtblLabels.js b/lib/js/hashtblLabels.js index 6aa7894bbb..26214bb36b 100644 --- a/lib/js/hashtblLabels.js +++ b/lib/js/hashtblLabels.js @@ -11,21 +11,15 @@ function replace(tbl, key, data) { } function iter(f, tbl) { - Hashtbl.iter((function (key, data) { - f(key, data); - }), tbl); + Hashtbl.iter((key, data) => f(key, data), tbl); } function filter_map_inplace(f, tbl) { - Hashtbl.filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); + Hashtbl.filter_map_inplace((key, data) => f(key, data), tbl); } function fold(f, tbl, init) { - return Hashtbl.fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); + return Hashtbl.fold((key, data, acc) => f(key, data, acc), tbl, init); } function MakeSeeded(H) { @@ -35,27 +29,11 @@ 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 iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); - }; - let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); - }; - let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); - }; + let add$1 = (tbl, key, data) => add(tbl, key, data); + let replace$1 = (tbl, key, data) => replace(tbl, key, data); + let iter$1 = (f, tbl) => iter((key, data) => f(key, data), tbl); + let filter_map_inplace$1 = (f, tbl) => filter_map_inplace((key, data) => f(key, data), tbl); + let fold$1 = (f, tbl, init) => fold((key, data, acc) => f(key, data, acc), tbl, init); return { create: include.create, clear: include.clear, @@ -77,9 +55,7 @@ function MakeSeeded(H) { } function Make(H) { - let hash = function (_seed, x) { - return H.hash(x); - }; + let hash = (_seed, x) => H.hash(x); let H_equal = H.equal; let H$1 = { equal: H_equal, @@ -92,30 +68,12 @@ 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 iter$1 = function (f, tbl) { - iter((function (key, data) { - f(key, data); - }), tbl); - }; - let filter_map_inplace$1 = function (f, tbl) { - filter_map_inplace((function (key, data) { - return f(key, data); - }), tbl); - }; - let fold$1 = function (f, tbl, init) { - return fold((function (key, data, acc) { - return f(key, data, acc); - }), tbl, init); - }; - let create$1 = function (sz) { - return create(false, sz); - }; + let add$1 = (tbl, key, data) => add(tbl, key, data); + let replace$1 = (tbl, key, data) => replace(tbl, key, data); + let iter$1 = (f, tbl) => iter((key, data) => f(key, data), tbl); + let filter_map_inplace$1 = (f, tbl) => filter_map_inplace((key, data) => f(key, data), tbl); + let fold$1 = (f, tbl, init) => fold((key, data, acc) => f(key, data, acc), tbl, init); + let create$1 = sz => create(false, sz); return { create: create$1, clear: include.clear, diff --git a/lib/js/lazy.js b/lib/js/lazy.js index fe1b4b9d8b..5425717915 100644 --- a/lib/js/lazy.js +++ b/lib/js/lazy.js @@ -3,9 +3,7 @@ let CamlinternalLazy = require("./camlinternalLazy.js"); function from_fun(f) { - return CamlinternalLazy.from_fun(function () { - return f(); - }); + return CamlinternalLazy.from_fun(() => f()); } let from_val = CamlinternalLazy.from_val; diff --git a/lib/js/lexing.js b/lib/js/lexing.js index eb3b49462b..8b7d2f0f20 100644 --- a/lib/js/lexing.js +++ b/lib/js/lexing.js @@ -44,7 +44,7 @@ let zero_pos = { function from_function(f) { return { - refill_buff: (function (x) { + refill_buff: x => { let aux_buffer = Caml_bytes.create(512); let read = f(aux_buffer, aux_buffer.length); let n = read > 0 ? read : (x.lex_eof_reached = true, 0); @@ -82,7 +82,7 @@ function from_function(f) { } Bytes.blit(aux_buffer, 0, x.lex_buffer, x.lex_buffer_len, n); x.lex_buffer_len = x.lex_buffer_len + n | 0; - }), + }, lex_buffer: Caml_bytes.create(1024), lex_buffer_len: 0, lex_abs_pos: 0, @@ -99,9 +99,9 @@ function from_function(f) { function from_string(s) { return { - refill_buff: (function (lexbuf) { + refill_buff: lexbuf => { lexbuf.lex_eof_reached = true; - }), + }, lex_buffer: Bytes.of_string(s), lex_buffer_len: s.length, lex_abs_pos: 0, diff --git a/lib/js/list.js b/lib/js/list.js index 46da49279a..cebd113d2d 100644 --- a/lib/js/list.js +++ b/lib/js/list.js @@ -856,7 +856,7 @@ function chop(_k, _l) { } function stable_sort(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1002,7 +1002,7 @@ function stable_sort(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1157,7 +1157,7 @@ function stable_sort(cmp, l) { } function sort_uniq(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1388,7 +1388,7 @@ function sort_uniq(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; diff --git a/lib/js/listLabels.js b/lib/js/listLabels.js index 564e9376f2..b026ab1ad4 100644 --- a/lib/js/listLabels.js +++ b/lib/js/listLabels.js @@ -856,7 +856,7 @@ function chop(_k, _l) { } function stable_sort(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1002,7 +1002,7 @@ function stable_sort(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1157,7 +1157,7 @@ function stable_sort(cmp, l) { } function sort_uniq(cmp, l) { - let sort = function (n, l) { + let sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; @@ -1388,7 +1388,7 @@ function sort_uniq(cmp, l) { continue; }; }; - let rev_sort = function (n, l) { + let rev_sort = (n, l) => { if (n !== 2) { if (n === 3 && l) { let match = l.tl; diff --git a/lib/js/map.js b/lib/js/map.js index 62e301eb40..3588ee0024 100644 --- a/lib/js/map.js +++ b/lib/js/map.js @@ -3,14 +3,14 @@ let Caml_option = require("./caml_option.js"); function Make(funarg) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -22,17 +22,15 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - l: "Empty", - v: x, - d: d, - r: "Empty", - h: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + l: "Empty", + v: x, + d: d, + r: "Empty", + h: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -98,14 +96,14 @@ function Make(funarg) { } }); }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let add = function (x, data, param) { + let add = (x, data, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -150,7 +148,7 @@ function Make(funarg) { return bal(l, v, d, rr); } }; - let find = function (x, _param) { + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -168,7 +166,7 @@ function Make(funarg) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -208,7 +206,7 @@ function Make(funarg) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -244,7 +242,7 @@ function Make(funarg) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -284,7 +282,7 @@ function Make(funarg) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -320,7 +318,7 @@ function Make(funarg) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -334,7 +332,7 @@ function Make(funarg) { continue; }; }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -348,7 +346,7 @@ function Make(funarg) { continue; }; }; - let min_binding = function (_param) { + let min_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -369,7 +367,7 @@ function Make(funarg) { continue; }; }; - let min_binding_opt = function (_param) { + let min_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -386,7 +384,7 @@ function Make(funarg) { continue; }; }; - let max_binding = function (_param) { + let max_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -407,7 +405,7 @@ function Make(funarg) { continue; }; }; - let max_binding_opt = function (_param) { + let max_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -424,7 +422,7 @@ function Make(funarg) { continue; }; }; - let remove_min_binding = function (param) { + let remove_min_binding = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -440,7 +438,7 @@ function Make(funarg) { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -450,7 +448,7 @@ function Make(funarg) { let match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -477,7 +475,7 @@ function Make(funarg) { return bal(l, v, d, rr); } }; - let update = function (x, f, param) { + let update = (x, f, param) => { if (typeof param !== "object") { let data = f(undefined); if (data !== undefined) { @@ -532,7 +530,7 @@ function Make(funarg) { return bal(l, v, d, rr); } }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -544,7 +542,7 @@ function Make(funarg) { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -560,7 +558,7 @@ function Make(funarg) { h: param.h }; }; - let mapi = function (f, param) { + let mapi = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -577,7 +575,7 @@ function Make(funarg) { h: param.h }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -589,7 +587,7 @@ function Make(funarg) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -605,7 +603,7 @@ function Make(funarg) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -621,21 +619,21 @@ function Make(funarg) { continue; }; }; - let add_min_binding = function (k, x, param) { + let add_min_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; - let add_max_binding = function (k, x, param) { + let add_max_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -652,7 +650,7 @@ function Make(funarg) { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -662,14 +660,14 @@ function Make(funarg) { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -704,7 +702,7 @@ function Make(funarg) { match$1[2] ]; }; - let merge$1 = function (f, s1, s2) { + let merge$1 = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -734,7 +732,7 @@ function Make(funarg) { 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)); }; - let union = function (f, s1, s2) { + let union = (f, s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -766,7 +764,7 @@ function Make(funarg) { return join(l$1, v2, d2, r$1); } }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -787,7 +785,7 @@ function Make(funarg) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -815,7 +813,7 @@ function Make(funarg) { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -833,7 +831,7 @@ function Make(funarg) { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -862,7 +860,7 @@ function Make(funarg) { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -889,14 +887,14 @@ function Make(funarg) { continue; }; }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let bindings_aux = function (_accu, _param) { + let bindings_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -914,9 +912,7 @@ function Make(funarg) { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { empty: "Empty", is_empty: is_empty, diff --git a/lib/js/mapLabels.js b/lib/js/mapLabels.js index 09ef63e715..4094b6e60e 100644 --- a/lib/js/mapLabels.js +++ b/lib/js/mapLabels.js @@ -3,14 +3,14 @@ let Caml_option = require("./caml_option.js"); function Make(Ord) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -22,17 +22,15 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - l: "Empty", - v: x, - d: d, - r: "Empty", - h: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + l: "Empty", + v: x, + d: d, + r: "Empty", + h: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -98,14 +96,14 @@ function Make(Ord) { } }); }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let add = function (x, data, param) { + let add = (x, data, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -150,7 +148,7 @@ function Make(Ord) { return bal(l, v, d, rr); } }; - let find = function (x, _param) { + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -168,7 +166,7 @@ function Make(Ord) { continue; }; }; - let find_first_aux = function (_v0, _d0, f, _param) { + let find_first_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -190,7 +188,7 @@ function Make(Ord) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -208,7 +206,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt_aux = function (_v0, _d0, f, _param) { + let find_first_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -230,7 +228,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -244,7 +242,7 @@ function Make(Ord) { continue; }; }; - let find_last_aux = function (_v0, _d0, f, _param) { + let find_last_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -266,7 +264,7 @@ function Make(Ord) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -284,7 +282,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt_aux = function (_v0, _d0, f, _param) { + let find_last_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -306,7 +304,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -320,7 +318,7 @@ function Make(Ord) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -334,7 +332,7 @@ function Make(Ord) { continue; }; }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -348,7 +346,7 @@ function Make(Ord) { continue; }; }; - let min_binding = function (_param) { + let min_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -369,7 +367,7 @@ function Make(Ord) { continue; }; }; - let min_binding_opt = function (_param) { + let min_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -386,7 +384,7 @@ function Make(Ord) { continue; }; }; - let max_binding = function (_param) { + let max_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -407,7 +405,7 @@ function Make(Ord) { continue; }; }; - let max_binding_opt = function (_param) { + let max_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -424,7 +422,7 @@ function Make(Ord) { continue; }; }; - let remove_min_binding = function (param) { + let remove_min_binding = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -440,7 +438,7 @@ function Make(Ord) { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -450,7 +448,7 @@ function Make(Ord) { let match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -477,7 +475,7 @@ function Make(Ord) { return bal(l, v, d, rr); } }; - let update = function (x, f, param) { + let update = (x, f, param) => { if (typeof param !== "object") { let data = f(undefined); if (data !== undefined) { @@ -532,7 +530,7 @@ function Make(Ord) { return bal(l, v, d, rr); } }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -544,7 +542,7 @@ function Make(Ord) { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -560,7 +558,7 @@ function Make(Ord) { h: param.h }; }; - let mapi = function (f, param) { + let mapi = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -577,7 +575,7 @@ function Make(Ord) { h: param.h }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -589,7 +587,7 @@ function Make(Ord) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -605,7 +603,7 @@ function Make(Ord) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -621,21 +619,21 @@ function Make(Ord) { continue; }; }; - let add_min_binding = function (k, x, param) { + let add_min_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; - let add_max_binding = function (k, x, param) { + let add_max_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -652,7 +650,7 @@ function Make(Ord) { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -662,14 +660,14 @@ function Make(Ord) { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -704,7 +702,7 @@ function Make(Ord) { match$1[2] ]; }; - let merge$1 = function (f, s1, s2) { + let merge$1 = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -734,7 +732,7 @@ function Make(Ord) { 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)); }; - let union = function (f, s1, s2) { + let union = (f, s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -766,7 +764,7 @@ function Make(Ord) { return join(l$1, v2, d2, r$1); } }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -787,7 +785,7 @@ function Make(Ord) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -815,7 +813,7 @@ function Make(Ord) { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -833,7 +831,7 @@ function Make(Ord) { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -862,7 +860,7 @@ function Make(Ord) { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -889,14 +887,14 @@ function Make(Ord) { continue; }; }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let bindings_aux = function (_accu, _param) { + let bindings_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -914,9 +912,7 @@ function Make(Ord) { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { height: height, create: create, diff --git a/lib/js/moreLabels.js b/lib/js/moreLabels.js index 0a88535c30..fdbe98c04b 100644 --- a/lib/js/moreLabels.js +++ b/lib/js/moreLabels.js @@ -32,15 +32,15 @@ let Hashtbl = { }; let $$Map = { - Make: (function (funarg) { - let height = function (param) { + Make: funarg => { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -52,17 +52,15 @@ let $$Map = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - l: "Empty", - v: x, - d: d, - r: "Empty", - h: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + l: "Empty", + v: x, + d: d, + r: "Empty", + h: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -128,14 +126,14 @@ let $$Map = { } }); }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let add = function (x, data, param) { + let add = (x, data, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -180,7 +178,7 @@ let $$Map = { return bal(l, v, d, rr); } }; - let find = function (x, _param) { + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -198,7 +196,7 @@ let $$Map = { continue; }; }; - let find_first_aux = function (_v0, _d0, f, _param) { + let find_first_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -220,7 +218,7 @@ let $$Map = { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -238,7 +236,7 @@ let $$Map = { continue; }; }; - let find_first_opt_aux = function (_v0, _d0, f, _param) { + let find_first_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -260,7 +258,7 @@ let $$Map = { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -274,7 +272,7 @@ let $$Map = { continue; }; }; - let find_last_aux = function (_v0, _d0, f, _param) { + let find_last_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -296,7 +294,7 @@ let $$Map = { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -314,7 +312,7 @@ let $$Map = { continue; }; }; - let find_last_opt_aux = function (_v0, _d0, f, _param) { + let find_last_opt_aux = (_v0, _d0, f, _param) => { while (true) { let param = _param; let d0 = _d0; @@ -336,7 +334,7 @@ let $$Map = { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -350,7 +348,7 @@ let $$Map = { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -364,7 +362,7 @@ let $$Map = { continue; }; }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -378,7 +376,7 @@ let $$Map = { continue; }; }; - let min_binding = function (_param) { + let min_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -399,7 +397,7 @@ let $$Map = { continue; }; }; - let min_binding_opt = function (_param) { + let min_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -416,7 +414,7 @@ let $$Map = { continue; }; }; - let max_binding = function (_param) { + let max_binding = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -437,7 +435,7 @@ let $$Map = { continue; }; }; - let max_binding_opt = function (_param) { + let max_binding_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -454,7 +452,7 @@ let $$Map = { continue; }; }; - let remove_min_binding = function (param) { + let remove_min_binding = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -470,7 +468,7 @@ let $$Map = { return bal(remove_min_binding(l), param.v, param.d, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -480,7 +478,7 @@ let $$Map = { let match = min_binding(t2); return bal(t1, match[0], match[1], remove_min_binding(t2)); }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -507,7 +505,7 @@ let $$Map = { return bal(l, v, d, rr); } }; - let update = function (x, f, param) { + let update = (x, f, param) => { if (typeof param !== "object") { let data = f(undefined); if (data !== undefined) { @@ -562,7 +560,7 @@ let $$Map = { return bal(l, v, d, rr); } }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -574,7 +572,7 @@ let $$Map = { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -590,7 +588,7 @@ let $$Map = { h: param.h }; }; - let mapi = function (f, param) { + let mapi = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -607,7 +605,7 @@ let $$Map = { h: param.h }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -619,7 +617,7 @@ let $$Map = { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -635,7 +633,7 @@ let $$Map = { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -651,21 +649,21 @@ let $$Map = { continue; }; }; - let add_min_binding = function (k, x, param) { + let add_min_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); } }; - let add_max_binding = function (k, x, param) { + let add_max_binding = (k, x, param) => { if (typeof param !== "object") { return singleton(k, x); } else { return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -682,7 +680,7 @@ let $$Map = { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -692,14 +690,14 @@ let $$Map = { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -734,7 +732,7 @@ let $$Map = { match$1[2] ]; }; - let merge$1 = function (f, s1, s2) { + let merge$1 = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -764,7 +762,7 @@ let $$Map = { 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)); }; - let union = function (f, s1, s2) { + let union = (f, s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -796,7 +794,7 @@ let $$Map = { return join(l$1, v2, d2, r$1); } }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -817,7 +815,7 @@ let $$Map = { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -845,7 +843,7 @@ let $$Map = { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -863,7 +861,7 @@ let $$Map = { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -892,7 +890,7 @@ let $$Map = { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -919,14 +917,14 @@ let $$Map = { continue; }; }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let bindings_aux = function (_accu, _param) { + let bindings_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -944,9 +942,7 @@ let $$Map = { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { empty: "Empty", is_empty: is_empty, @@ -983,19 +979,19 @@ let $$Map = { map: map, mapi: mapi }; - }) + } }; let $$Set = { - Make: (function (funarg) { - let height = function (param) { + Make: funarg => { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, v, r) { + let create = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -1008,7 +1004,7 @@ let $$Set = { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let bal = function (l, v, r) { + let bal = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -1071,7 +1067,7 @@ let $$Set = { } }); }; - let add = function (x, param) { + let add = (x, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -1103,30 +1099,28 @@ let $$Set = { return bal(l, v, rr); } }; - let singleton = function (x) { - return { - TAG: "Node", - l: "Empty", - v: x, - r: "Empty", - h: 1 - }; - }; - let add_min_element = function (x, param) { + let singleton = x => ({ + TAG: "Node", + l: "Empty", + v: x, + r: "Empty", + h: 1 + }); + let add_min_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; - let add_max_element = function (x, param) { + let add_max_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; - let join = function (l, v, r) { + let join = (l, v, r) => { if (typeof l !== "object") { return add_min_element(v, r); } @@ -1143,7 +1137,7 @@ let $$Set = { return create(l, v, r); } }; - let min_elt = function (_param) { + let min_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1161,7 +1155,7 @@ let $$Set = { continue; }; }; - let min_elt_opt = function (_param) { + let min_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1175,7 +1169,7 @@ let $$Set = { continue; }; }; - let max_elt = function (_param) { + let max_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1193,7 +1187,7 @@ let $$Set = { continue; }; }; - let max_elt_opt = function (_param) { + let max_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1207,7 +1201,7 @@ let $$Set = { continue; }; }; - let remove_min_elt = function (param) { + let remove_min_elt = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -1223,7 +1217,7 @@ let $$Set = { return bal(remove_min_elt(l), param.v, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -1232,7 +1226,7 @@ let $$Set = { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -1241,7 +1235,7 @@ let $$Set = { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -1275,14 +1269,14 @@ let $$Set = { match$1[2] ]; }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1296,7 +1290,7 @@ let $$Set = { continue; }; }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -1322,7 +1316,7 @@ let $$Set = { return bal(l, v, rr); } }; - let union = function (s1, s2) { + let union = (s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -1346,7 +1340,7 @@ let $$Set = { let match$1 = split(v2, s1); return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; - let inter = function (s1, s2) { + let inter = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -1364,7 +1358,7 @@ let $$Set = { return concat(inter(l1, l2), inter(r1, match[2])); } }; - let diff = function (s1, s2) { + let diff = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -1382,7 +1376,7 @@ let $$Set = { return join(diff(l1, l2), v1, diff(r1, match[2])); } }; - let cons_enum = function (_s, _e) { + let cons_enum = (_s, _e) => { while (true) { let e = _e; let s = _s; @@ -1399,7 +1393,7 @@ let $$Set = { continue; }; }; - let compare_aux = function (_e1, _e2) { + let compare_aux = (_e1, _e2) => { while (true) { let e2 = _e2; let e1 = _e1; @@ -1422,13 +1416,9 @@ let $$Set = { continue; }; }; - let compare = function (s1, s2) { - return compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); - }; - let equal = function (s1, s2) { - return compare(s1, s2) === 0; - }; - let subset = function (_s1, _s2) { + let compare = (s1, s2) => compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { while (true) { let s2 = _s2; let s1 = _s1; @@ -1478,7 +1468,7 @@ let $$Set = { continue; }; }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1490,7 +1480,7 @@ let $$Set = { continue; }; }; - let fold = function (f, _s, _accu) { + let fold = (f, _s, _accu) => { while (true) { let accu = _accu; let s = _s; @@ -1502,7 +1492,7 @@ let $$Set = { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1518,7 +1508,7 @@ let $$Set = { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1534,7 +1524,7 @@ let $$Set = { continue; }; }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -1554,7 +1544,7 @@ let $$Set = { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -1581,14 +1571,14 @@ let $$Set = { ]; } }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let elements_aux = function (_accu, _param) { + let elements_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -1603,10 +1593,8 @@ let $$Set = { continue; }; }; - let elements = function (s) { - return elements_aux(/* [] */0, s); - }; - let find = function (x, _param) { + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1625,7 +1613,7 @@ let $$Set = { continue; }; }; - let find_first_aux = function (_v0, f, _param) { + let find_first_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1642,7 +1630,7 @@ let $$Set = { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1660,7 +1648,7 @@ let $$Set = { continue; }; }; - let find_first_opt_aux = function (_v0, f, _param) { + let find_first_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1677,7 +1665,7 @@ let $$Set = { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1691,7 +1679,7 @@ let $$Set = { continue; }; }; - let find_last_aux = function (_v0, f, _param) { + let find_last_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1708,7 +1696,7 @@ let $$Set = { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1726,7 +1714,7 @@ let $$Set = { continue; }; }; - let find_last_opt_aux = function (_v0, f, _param) { + let find_last_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -1743,7 +1731,7 @@ let $$Set = { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1757,7 +1745,7 @@ let $$Set = { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -1772,14 +1760,14 @@ let $$Set = { continue; }; }; - let try_join = function (l, v, r) { + let try_join = (l, v, r) => { if ((l === "Empty" || funarg.compare(max_elt(l), v) < 0) && (r === "Empty" || funarg.compare(v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); } }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -1795,8 +1783,8 @@ let $$Set = { return try_join(l$p, v$p, r$p); } }; - let of_sorted_list = function (l) { - let sub = function (n, l) { + let of_sorted_list = l => { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -1899,7 +1887,7 @@ let $$Set = { }; return sub(List.length(l), l)[0]; }; - let of_list = function (l) { + let of_list = l => { if (!l) { return "Empty"; } @@ -1967,7 +1955,7 @@ let $$Set = { find_last_opt: find_last_opt, of_list: of_list }; - }) + } }; exports.Hashtbl = Hashtbl; diff --git a/lib/js/parsing.js b/lib/js/parsing.js index 72a439cfa8..b4a3eef011 100644 --- a/lib/js/parsing.js +++ b/lib/js/parsing.js @@ -55,9 +55,7 @@ function clear_parser() { } let current_lookahead_fun = { - contents: (function (param) { - return false; - }) + contents: param => false }; function yyparse(tables, start, lexer, lexbuf) { @@ -145,13 +143,13 @@ function yyparse(tables, start, lexer, lexbuf) { if (exn$1.RE_EXN_ID === YYexit) { return exn$1._1; } - current_lookahead_fun.contents = (function (tok) { + current_lookahead_fun.contents = tok => { if (typeof tok !== "number") { return Caml_array.get(tables.transl_block, tok.TAG) === curr_char; } else { return Caml_array.get(tables.transl_const, tok) === curr_char; } - }); + }; throw new Error(exn$1.RE_EXN_ID, { cause: exn$1 }); diff --git a/lib/js/pervasives.js b/lib/js/pervasives.js index adb37289e3..445c238f4b 100644 --- a/lib/js/pervasives.js +++ b/lib/js/pervasives.js @@ -191,17 +191,15 @@ function print_string(prim) { } let exit_function = { - contents: (function (prim) { - - }) + contents: prim => {} }; function at_exit(f) { let g = exit_function.contents; - exit_function.contents = (function () { + exit_function.contents = () => { f(); g(); - }); + }; } function exit(retcode) { diff --git a/lib/js/random.js b/lib/js/random.js index f10fd3cdde..0b844d4e69 100644 --- a/lib/js/random.js +++ b/lib/js/random.js @@ -19,12 +19,8 @@ function assign(st1, st2) { } function full_init(s, seed) { - let combine = function (accu, x) { - return Digest.string(accu + String(x)); - }; - let extract = function (d) { - return ((Caml_string.get(d, 0) + (Caml_string.get(d, 1) << 8) | 0) + (Caml_string.get(d, 2) << 16) | 0) + (Caml_string.get(d, 3) << 24) | 0; - }; + let combine = (accu, x) => Digest.string(accu + String(x)); + let extract = d => ((Caml_string.get(d, 0) + (Caml_string.get(d, 1) << 8) | 0) + (Caml_string.get(d, 2) << 16) | 0) + (Caml_string.get(d, 3) << 24) | 0; let seed$1 = seed.length === 0 ? [0] : seed; let l = seed$1.length; for (let i = 0; i <= 54; ++i) { diff --git a/lib/js/set.js b/lib/js/set.js index 3c6211b669..3b5ca118c9 100644 --- a/lib/js/set.js +++ b/lib/js/set.js @@ -4,14 +4,14 @@ let List = require("./list.js"); let Caml_option = require("./caml_option.js"); function Make(funarg) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, v, r) { + let create = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -24,7 +24,7 @@ function Make(funarg) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let bal = function (l, v, r) { + let bal = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -87,7 +87,7 @@ function Make(funarg) { } }); }; - let add = function (x, param) { + let add = (x, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -119,30 +119,28 @@ function Make(funarg) { return bal(l, v, rr); } }; - let singleton = function (x) { - return { - TAG: "Node", - l: "Empty", - v: x, - r: "Empty", - h: 1 - }; - }; - let add_min_element = function (x, param) { + let singleton = x => ({ + TAG: "Node", + l: "Empty", + v: x, + r: "Empty", + h: 1 + }); + let add_min_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; - let add_max_element = function (x, param) { + let add_max_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; - let join = function (l, v, r) { + let join = (l, v, r) => { if (typeof l !== "object") { return add_min_element(v, r); } @@ -159,7 +157,7 @@ function Make(funarg) { return create(l, v, r); } }; - let min_elt = function (_param) { + let min_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -177,7 +175,7 @@ function Make(funarg) { continue; }; }; - let min_elt_opt = function (_param) { + let min_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -191,7 +189,7 @@ function Make(funarg) { continue; }; }; - let max_elt = function (_param) { + let max_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -209,7 +207,7 @@ function Make(funarg) { continue; }; }; - let max_elt_opt = function (_param) { + let max_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -223,7 +221,7 @@ function Make(funarg) { continue; }; }; - let remove_min_elt = function (param) { + let remove_min_elt = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -239,7 +237,7 @@ function Make(funarg) { return bal(remove_min_elt(l), param.v, param.r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -248,7 +246,7 @@ function Make(funarg) { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -282,14 +280,14 @@ function Make(funarg) { match$1[2] ]; }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -303,7 +301,7 @@ function Make(funarg) { continue; }; }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -335,7 +333,7 @@ function Make(funarg) { return bal(l, v, rr); } }; - let union = function (s1, s2) { + let union = (s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -359,7 +357,7 @@ function Make(funarg) { let match$1 = split(v2, s1); return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; - let inter = function (s1, s2) { + let inter = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -377,7 +375,7 @@ function Make(funarg) { return concat(inter(l1, l2), inter(r1, match[2])); } }; - let diff = function (s1, s2) { + let diff = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -395,7 +393,7 @@ function Make(funarg) { return join(diff(l1, l2), v1, diff(r1, match[2])); } }; - let cons_enum = function (_s, _e) { + let cons_enum = (_s, _e) => { while (true) { let e = _e; let s = _s; @@ -412,7 +410,7 @@ function Make(funarg) { continue; }; }; - let compare = function (s1, s2) { + let compare = (s1, s2) => { let _e1 = cons_enum(s1, "End"); let _e2 = cons_enum(s2, "End"); while (true) { @@ -437,10 +435,8 @@ function Make(funarg) { continue; }; }; - let equal = function (s1, s2) { - return compare(s1, s2) === 0; - }; - let subset = function (_s1, _s2) { + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { while (true) { let s2 = _s2; let s1 = _s1; @@ -490,7 +486,7 @@ function Make(funarg) { continue; }; }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -502,7 +498,7 @@ function Make(funarg) { continue; }; }; - let fold = function (f, _s, _accu) { + let fold = (f, _s, _accu) => { while (true) { let accu = _accu; let s = _s; @@ -514,7 +510,7 @@ function Make(funarg) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -530,7 +526,7 @@ function Make(funarg) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -546,7 +542,7 @@ function Make(funarg) { continue; }; }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -566,7 +562,7 @@ function Make(funarg) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -593,14 +589,14 @@ function Make(funarg) { ]; } }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let elements_aux = function (_accu, _param) { + let elements_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -615,10 +611,8 @@ function Make(funarg) { continue; }; }; - let elements = function (s) { - return elements_aux(/* [] */0, s); - }; - let find = function (x, _param) { + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -637,7 +631,7 @@ function Make(funarg) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -671,7 +665,7 @@ function Make(funarg) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -701,7 +695,7 @@ function Make(funarg) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -735,7 +729,7 @@ function Make(funarg) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -765,7 +759,7 @@ function Make(funarg) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -780,7 +774,7 @@ function Make(funarg) { continue; }; }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -798,7 +792,7 @@ function Make(funarg) { return union(l$p, add(v$p, r$p)); } }; - let of_list = function (l) { + let of_list = l => { if (!l) { return "Empty"; } @@ -822,7 +816,7 @@ function Make(funarg) { if (match$3) { if (match$3.tl) { let l$1 = List.sort_uniq(funarg.compare, l); - let sub = function (n, l) { + let sub = (n, l) => { switch (n) { case 0 : return [ diff --git a/lib/js/setLabels.js b/lib/js/setLabels.js index 737c8d4c8f..85c913e920 100644 --- a/lib/js/setLabels.js +++ b/lib/js/setLabels.js @@ -4,14 +4,14 @@ let List = require("./list.js"); let Caml_option = require("./caml_option.js"); function Make(Ord) { - let height = function (param) { + let height = param => { if (typeof param !== "object") { return 0; } else { return param.h; } }; - let create = function (l, v, r) { + let create = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -24,7 +24,7 @@ function Make(Ord) { h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let bal = function (l, v, r) { + let bal = (l, v, r) => { let hl; hl = typeof l !== "object" ? 0 : l.h; let hr; @@ -87,7 +87,7 @@ function Make(Ord) { } }); }; - let add = function (x, param) { + let add = (x, param) => { if (typeof param !== "object") { return { TAG: "Node", @@ -119,30 +119,28 @@ function Make(Ord) { return bal(l, v, rr); } }; - let singleton = function (x) { - return { - TAG: "Node", - l: "Empty", - v: x, - r: "Empty", - h: 1 - }; - }; - let add_min_element = function (x, param) { + let singleton = x => ({ + TAG: "Node", + l: "Empty", + v: x, + r: "Empty", + h: 1 + }); + let add_min_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(add_min_element(x, param.l), param.v, param.r); } }; - let add_max_element = function (x, param) { + let add_max_element = (x, param) => { if (typeof param !== "object") { return singleton(x); } else { return bal(param.l, param.v, add_max_element(x, param.r)); } }; - let join = function (l, v, r) { + let join = (l, v, r) => { if (typeof l !== "object") { return add_min_element(v, r); } @@ -159,7 +157,7 @@ function Make(Ord) { return create(l, v, r); } }; - let min_elt = function (_param) { + let min_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -177,7 +175,7 @@ function Make(Ord) { continue; }; }; - let min_elt_opt = function (_param) { + let min_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -191,7 +189,7 @@ function Make(Ord) { continue; }; }; - let max_elt = function (_param) { + let max_elt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -209,7 +207,7 @@ function Make(Ord) { continue; }; }; - let max_elt_opt = function (_param) { + let max_elt_opt = _param => { while (true) { let param = _param; if (typeof param !== "object") { @@ -223,7 +221,7 @@ function Make(Ord) { continue; }; }; - let remove_min_elt = function (param) { + let remove_min_elt = param => { if (typeof param !== "object") { throw new Error("Invalid_argument", { cause: { @@ -239,7 +237,7 @@ function Make(Ord) { return bal(remove_min_elt(l), param.v, param.r); } }; - let merge = function (t1, t2) { + let merge = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -248,7 +246,7 @@ function Make(Ord) { return bal(t1, min_elt(t2), remove_min_elt(t2)); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } else if (typeof t2 !== "object") { @@ -257,7 +255,7 @@ function Make(Ord) { return join(t1, min_elt(t2), remove_min_elt(t2)); } }; - let split = function (x, param) { + let split = (x, param) => { if (typeof param !== "object") { return [ "Empty", @@ -291,14 +289,14 @@ function Make(Ord) { match$1[2] ]; }; - let is_empty = function (param) { + let is_empty = param => { if (typeof param !== "object") { return true; } else { return false; } }; - let mem = function (x, _param) { + let mem = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -312,7 +310,7 @@ function Make(Ord) { continue; }; }; - let remove = function (x, param) { + let remove = (x, param) => { if (typeof param !== "object") { return "Empty"; } @@ -338,7 +336,7 @@ function Make(Ord) { return bal(l, v, rr); } }; - let union = function (s1, s2) { + let union = (s1, s2) => { if (typeof s1 !== "object") { return s2; } @@ -362,7 +360,7 @@ function Make(Ord) { let match$1 = split(v2, s1); return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); }; - let inter = function (s1, s2) { + let inter = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -380,7 +378,7 @@ function Make(Ord) { return concat(inter(l1, l2), inter(r1, match[2])); } }; - let diff = function (s1, s2) { + let diff = (s1, s2) => { if (typeof s1 !== "object") { return "Empty"; } @@ -398,7 +396,7 @@ function Make(Ord) { return join(diff(l1, l2), v1, diff(r1, match[2])); } }; - let cons_enum = function (_s, _e) { + let cons_enum = (_s, _e) => { while (true) { let e = _e; let s = _s; @@ -415,7 +413,7 @@ function Make(Ord) { continue; }; }; - let compare_aux = function (_e1, _e2) { + let compare_aux = (_e1, _e2) => { while (true) { let e2 = _e2; let e1 = _e1; @@ -438,13 +436,9 @@ function Make(Ord) { continue; }; }; - let compare = function (s1, s2) { - return compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); - }; - let equal = function (s1, s2) { - return compare(s1, s2) === 0; - }; - let subset = function (_s1, _s2) { + let compare = (s1, s2) => compare_aux(cons_enum(s1, "End"), cons_enum(s2, "End")); + let equal = (s1, s2) => compare(s1, s2) === 0; + let subset = (_s1, _s2) => { while (true) { let s2 = _s2; let s1 = _s1; @@ -494,7 +488,7 @@ function Make(Ord) { continue; }; }; - let iter = function (f, _param) { + let iter = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -506,7 +500,7 @@ function Make(Ord) { continue; }; }; - let fold = function (f, _s, _accu) { + let fold = (f, _s, _accu) => { while (true) { let accu = _accu; let s = _s; @@ -518,7 +512,7 @@ function Make(Ord) { continue; }; }; - let for_all = function (p, _param) { + let for_all = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -534,7 +528,7 @@ function Make(Ord) { continue; }; }; - let exists = function (p, _param) { + let exists = (p, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -550,7 +544,7 @@ function Make(Ord) { continue; }; }; - let filter = function (p, param) { + let filter = (p, param) => { if (typeof param !== "object") { return "Empty"; } @@ -570,7 +564,7 @@ function Make(Ord) { return concat(l$p, r$p); } }; - let partition = function (p, param) { + let partition = (p, param) => { if (typeof param !== "object") { return [ "Empty", @@ -597,14 +591,14 @@ function Make(Ord) { ]; } }; - let cardinal = function (param) { + let cardinal = param => { if (typeof param !== "object") { return 0; } else { return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; } }; - let elements_aux = function (_accu, _param) { + let elements_aux = (_accu, _param) => { while (true) { let param = _param; let accu = _accu; @@ -619,10 +613,8 @@ function Make(Ord) { continue; }; }; - let elements = function (s) { - return elements_aux(/* [] */0, s); - }; - let find = function (x, _param) { + let elements = s => elements_aux(/* [] */0, s); + let find = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -641,7 +633,7 @@ function Make(Ord) { continue; }; }; - let find_first_aux = function (_v0, f, _param) { + let find_first_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -658,7 +650,7 @@ function Make(Ord) { continue; }; }; - let find_first = function (f, _param) { + let find_first = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -676,7 +668,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt_aux = function (_v0, f, _param) { + let find_first_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -693,7 +685,7 @@ function Make(Ord) { continue; }; }; - let find_first_opt = function (f, _param) { + let find_first_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -707,7 +699,7 @@ function Make(Ord) { continue; }; }; - let find_last_aux = function (_v0, f, _param) { + let find_last_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -724,7 +716,7 @@ function Make(Ord) { continue; }; }; - let find_last = function (f, _param) { + let find_last = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -742,7 +734,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt_aux = function (_v0, f, _param) { + let find_last_opt_aux = (_v0, f, _param) => { while (true) { let param = _param; let v0 = _v0; @@ -759,7 +751,7 @@ function Make(Ord) { continue; }; }; - let find_last_opt = function (f, _param) { + let find_last_opt = (f, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -773,7 +765,7 @@ function Make(Ord) { continue; }; }; - let find_opt = function (x, _param) { + let find_opt = (x, _param) => { while (true) { let param = _param; if (typeof param !== "object") { @@ -788,14 +780,14 @@ function Make(Ord) { continue; }; }; - let try_join = function (l, v, r) { + let try_join = (l, v, r) => { if ((l === "Empty" || Ord.compare(max_elt(l), v) < 0) && (r === "Empty" || Ord.compare(v, min_elt(r)) < 0)) { return join(l, v, r); } else { return union(l, add(v, r)); } }; - let map = function (f, param) { + let map = (f, param) => { if (typeof param !== "object") { return "Empty"; } @@ -811,8 +803,8 @@ function Make(Ord) { return try_join(l$p, v$p, r$p); } }; - let of_sorted_list = function (l) { - let sub = function (n, l) { + let of_sorted_list = l => { + let sub = (n, l) => { switch (n) { case 0 : return [ @@ -915,7 +907,7 @@ function Make(Ord) { }; return sub(List.length(l), l)[0]; }; - let of_list = function (l) { + let of_list = l => { if (!l) { return "Empty"; } diff --git a/lib/js/sort.js b/lib/js/sort.js index c48404ca4e..d4556f5ccd 100644 --- a/lib/js/sort.js +++ b/lib/js/sort.js @@ -24,7 +24,7 @@ function merge(order, l1, l2) { } function list(order, l) { - let initlist = function (param) { + let initlist = param => { if (!param) { return /* [] */0; } @@ -57,7 +57,7 @@ function list(order, l) { tl: initlist(match.tl) }; }; - let merge2 = function (param) { + let merge2 = param => { if (!param) { return param; } @@ -92,7 +92,7 @@ function swap(arr, i, j) { } function array(cmp, arr) { - let qsort = function (_lo, _hi) { + let qsort = (_lo, _hi) => { while (true) { let hi = _hi; let lo = _lo; diff --git a/lib/js/stream.js b/lib/js/stream.js index e6e3b32d27..ac7705230d 100644 --- a/lib/js/stream.js +++ b/lib/js/stream.js @@ -254,7 +254,7 @@ function empty(s) { } function iter(f, strm) { - let do_rec = function () { + let do_rec = () => { while (true) { let a = peek(strm); if (a === undefined) { @@ -284,12 +284,10 @@ function from(f) { function of_list(l) { return { count: 0, - data: List.fold_right((function (x, l) { - return { - TAG: "Scons", - _0: x, - _1: l - }; + data: List.fold_right((x, l) => ({ + TAG: "Scons", + _0: x, + _1: l }), l, "Sempty") }; } @@ -298,7 +296,7 @@ function of_string(s) { let count = { contents: 0 }; - return from(function (param) { + return from(param => { let c = count.contents; if (c < s.length) { count.contents = count.contents + 1 | 0; @@ -312,7 +310,7 @@ function of_bytes(s) { let count = { contents: 0 }; - return from(function (param) { + return from(param => { let c = count.contents; if (c < s.length) { count.contents = count.contents + 1 | 0; @@ -356,39 +354,31 @@ function ising(i) { } function lapp(f, s) { - let f$1 = function () { - return { - TAG: "Sapp", - _0: data(f()), - _1: data(s) - }; - }; + let f$1 = () => ({ + TAG: "Sapp", + _0: data(f()), + _1: data(s) + }); return { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return f$1(); - }) + _0: CamlinternalLazy.from_fun(() => f$1()) } }; } function lcons(f, s) { - let f$1 = function () { - return { - TAG: "Scons", - _0: f(), - _1: data(s) - }; - }; + let f$1 = () => ({ + TAG: "Scons", + _0: f(), + _1: data(s) + }); return { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return f$1(); - }) + _0: CamlinternalLazy.from_fun(() => f$1()) } }; } @@ -398,13 +388,11 @@ function lsing(f) { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return { - TAG: "Scons", - _0: f(), - _1: "Sempty" - }; - }) + _0: CamlinternalLazy.from_fun(() => ({ + TAG: "Scons", + _0: f(), + _1: "Sempty" + })) } }; } @@ -414,9 +402,7 @@ function slazy(f) { count: 0, data: { TAG: "Slazy", - _0: CamlinternalLazy.from_fun(function () { - return data(f()); - }) + _0: CamlinternalLazy.from_fun(() => data(f())) } }; } diff --git a/lib/js/string.js b/lib/js/string.js index d6be0fd764..7a0052196d 100644 --- a/lib/js/string.js +++ b/lib/js/string.js @@ -55,7 +55,7 @@ function trim(s) { } function escaped(s) { - let needs_escape = function (_i) { + let needs_escape = _i => { while (true) { let i = _i; if (i >= s.length) { diff --git a/lib/js/stringLabels.js b/lib/js/stringLabels.js index d66bfccf31..40f76f7f90 100644 --- a/lib/js/stringLabels.js +++ b/lib/js/stringLabels.js @@ -57,7 +57,7 @@ function trim(s) { } function escaped(s) { - let needs_escape = function (_i) { + let needs_escape = _i => { while (true) { let i = _i; if (i >= s.length) {