From 4872b099d56e55c4478a79fc74a8cdbc36884fe2 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 14 Feb 2024 20:13:16 +0100 Subject: [PATCH] ReScript v11+: 1.0.0 (#189) * up to ReScript v11 * expose JSON, Null and Nullable untagged variants * remove dedicated Result.t definition now that result is builtin * point to Core dict * add more tests * 1.0.0 * remove uncurry annotations * fix deps to support latest 11.1 rc * fix deps to support latest 11.1 rc --- CHANGELOG.md | 6 ++ package-lock.json | 18 +++-- package.json | 6 +- src/Core__Array.mjs | 13 ++-- src/Core__Array.res | 4 +- src/Core__Error.mjs | 2 +- src/Core__Int.mjs | 4 +- src/Core__JSON.mjs | 15 ++-- src/Core__JSON.res | 9 ++- src/Core__JSON.resi | 9 ++- src/Core__List.mjs | 117 ++++++++++++++++++++-------- src/Core__List.res | 136 ++++++++++++++++---------------- src/Core__Null.mjs | 9 +-- src/Core__Null.res | 5 +- src/Core__Null.resi | 5 +- src/Core__Nullable.mjs | 9 +-- src/Core__Nullable.res | 5 +- src/Core__Nullable.resi | 6 +- src/Core__Option.mjs | 15 ++-- src/Core__Promise.mjs | 3 +- src/Core__Promise.res | 8 +- src/Core__Promise.resi | 6 +- src/Core__Result.mjs | 49 ++++++------ src/Core__Result.res | 2 - src/Core__Result.resi | 28 ++++--- src/Core__String.res | 14 +--- src/Core__String.resi | 14 +--- src/Core__Type.mjs | 18 ++--- test/ErrorTests.mjs | 4 +- test/FloatTests.mjs | 22 +++--- test/IntTests.mjs | 11 ++- test/JsonTests.mjs | 47 +++++++++++ test/JsonTests.res | 22 ++++++ test/NullableTests.mjs | 55 +++++++++++++ test/NullableTests.res | 39 ++++++++++ test/ObjectTests.mjs | 27 ++++--- test/PromiseTest.mjs | 163 +++++++++++++++++++-------------------- test/PromiseTest.res | 14 ++-- test/ResultTests.mjs | 20 ++--- test/TempTests.mjs | 18 ++--- test/TempTests.res | 4 +- test/Test.mjs | 3 +- test/TestSuite.mjs | 8 ++ test/TestSuite.res | 2 + test/TestTests.mjs | 8 +- test/TestTests.res | 2 +- test/TypedArrayTests.mjs | 17 ++-- 47 files changed, 629 insertions(+), 392 deletions(-) create mode 100644 test/JsonTests.mjs create mode 100644 test/JsonTests.res create mode 100644 test/NullableTests.mjs create mode 100644 test/NullableTests.res diff --git a/CHANGELOG.md b/CHANGELOG.md index 26ccec0f..de05e192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Next version +## 1.0.0 + +- Up ReScript dependency to 11+. +- `JSON`, `Null` and `Nullable` untagged variants are now properly exposed. +- BREAKING: Duplicated definition of `result` in `Result` module removed, as `result` is now a built in. Switch out any `Result.t` type annotations to point to the built in `result` instead. + ## 0.7.0 - Add `Dict.getUnsafe` https://github.com/rescript-association/rescript-core/pull/167 diff --git a/package-lock.json b/package-lock.json index bb3cbefb..37cc44e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "@rescript/core", - "version": "0.7.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rescript/core", - "version": "0.7.0", + "version": "1.0.0", "license": "MIT", "devDependencies": { "@babel/code-frame": "7.18.6", - "rescript": "10.1.4" + "rescript": "11.1.0-rc.2" }, "peerDependencies": { - "rescript": "^10.1.0 || ^11.0.0" + "rescript": ">=11.0.0 || ^11.1.0-rc.2" } }, "node_modules/@babel/code-frame": { @@ -117,16 +117,18 @@ "dev": true }, "node_modules/rescript": { - "version": "10.1.4", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-10.1.4.tgz", - "integrity": "sha512-FFKlS9AG/XrLepWsyw7B+A9DtQBPWEPDPDKghV831Y2KGbie+eeFBOS0xtRHp0xbt7S0N2Dm6hhX+kTZQ/3Ybg==", + "version": "11.1.0-rc.2", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.1.0-rc.2.tgz", + "integrity": "sha512-kCUtmsODEUF1Eth5ppc+yIK79HLI7CwRs1R4iopDek4FC58IqHSLT3K1XHGB39YCWuOuV9WMly+wksHRJcSLcw==", "dev": true, "hasInstallScript": true, "bin": { "bsc": "bsc", - "bsrefmt": "bsrefmt", "bstracing": "lib/bstracing", "rescript": "rescript" + }, + "engines": { + "node": ">=10" } }, "node_modules/supports-color": { diff --git a/package.json b/package.json index 11a1bc9b..3b337a4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/core", - "version": "0.7.0", + "version": "1.0.0", "scripts": { "clean": "rescript clean", "build": "rescript", @@ -23,10 +23,10 @@ "src/**/*.mjs" ], "peerDependencies": { - "rescript": "^10.1.0 || ^11.0.0" + "rescript": ">=11.0.0 || ^11.1.0-rc.2" }, "devDependencies": { - "rescript": "10.1.4", + "rescript": "11.1.0-rc.2", "@babel/code-frame": "7.18.6" } } diff --git a/src/Core__Array.mjs b/src/Core__Array.mjs index 489f569e..d8ee402f 100644 --- a/src/Core__Array.mjs +++ b/src/Core__Array.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as Js_math from "rescript/lib/es6/js_math.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; @@ -19,7 +18,7 @@ function fromInitializer(length, f) { } var arr = new Array(length); for(var i = 0; i < length; ++i){ - arr[i] = Curry._1(f, i); + arr[i] = f(i); } return arr; } @@ -33,7 +32,7 @@ function equal(a, b, eq) { if (i === len) { return true; } - if (!Curry._2(eq, a[i], b[i])) { + if (!eq(a[i], b[i])) { return false; } _i = i + 1 | 0; @@ -58,7 +57,7 @@ function compare(a, b, cmp) { if (i === lenA) { return 0; } - var c = Curry._2(cmp, a[i], b[i]); + var c = cmp(a[i], b[i]); if (c !== 0) { return c; } @@ -128,7 +127,9 @@ function toShuffled(xs) { } function filterMap(a, f) { - var f$1 = Curry.__1(f); + var f$1 = function (a) { + return f(a); + }; var l = a.length; var r = new Array(l); var j = 0; @@ -158,7 +159,7 @@ function findMap(arr, f) { if (i === arr.length) { return ; } - var r = Curry._1(f, arr[i]); + var r = f(arr[i]); if (r !== undefined) { return r; } diff --git a/src/Core__Array.res b/src/Core__Array.res index db67fbde..9059ed4c 100644 --- a/src/Core__Array.res +++ b/src/Core__Array.res @@ -216,7 +216,7 @@ let filterMapU = (a, f) => { let j = ref(0) for i in 0 to l - 1 { let v = getUnsafe(a, i) - switch f(. v) { + switch f(v) { | None => () | Some(v) => setUnsafe(r, j.contents, v) @@ -227,7 +227,7 @@ let filterMapU = (a, f) => { r } -let filterMap = (a, f) => filterMapU(a, (. a) => f(a)) +let filterMap = (a, f) => filterMapU(a, a => f(a)) let keepSome = filterMap(_, x => x) diff --git a/src/Core__Error.mjs b/src/Core__Error.mjs index 5c9e853f..e5334cf8 100644 --- a/src/Core__Error.mjs +++ b/src/Core__Error.mjs @@ -14,7 +14,7 @@ var $$TypeError = {}; var $$URIError = {}; function panic(msg) { - throw new Error("Panic! " + msg + ""); + throw new Error("Panic! " + msg); } export { diff --git a/src/Core__Int.mjs b/src/Core__Int.mjs index c870441b..442f19eb 100644 --- a/src/Core__Int.mjs +++ b/src/Core__Int.mjs @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Pervasives from "rescript/lib/es6/pervasives.js"; import * as Core__Array from "./Core__Array.mjs"; +import * as PervasivesU from "rescript/lib/es6/pervasivesU.js"; function equal(a, b) { return a === b; @@ -50,7 +50,7 @@ function rangeWithOptions(start, end, options) { } else { var range = isInverted ? start - end | 0 : end - start | 0; var range$1 = options.inclusive === true ? range + 1 | 0 : range; - length = Math.ceil(range$1 / Pervasives.abs(step)) | 0; + length = Math.ceil(range$1 / PervasivesU.abs(step)) | 0; } return Core__Array.fromInitializer(length, (function (i) { return start + Math.imul(i, step) | 0; diff --git a/src/Core__JSON.mjs b/src/Core__JSON.mjs index e26011ca..a38ef2c0 100644 --- a/src/Core__JSON.mjs +++ b/src/Core__JSON.mjs @@ -1,35 +1,34 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Caml_option from "rescript/lib/es6/caml_option.js"; function classify(value) { var match = Object.prototype.toString.call(value); switch (match) { case "[object Array]" : return { - TAG: /* Array */4, + TAG: "Array", _0: value }; case "[object Boolean]" : return { - TAG: /* Bool */0, + TAG: "Bool", _0: value }; case "[object Null]" : - return /* Null */0; + return "Null"; case "[object Number]" : return { - TAG: /* Number */2, + TAG: "Number", _0: value }; case "[object String]" : return { - TAG: /* String */1, + TAG: "String", _0: value }; default: return { - TAG: /* Object */3, + TAG: "Object", _0: value }; } @@ -71,7 +70,7 @@ function $$float(json) { function object(json) { if (typeof json === "object" && !Array.isArray(json) && json !== null) { - return Caml_option.some(json); + return json; } } diff --git a/src/Core__JSON.res b/src/Core__JSON.res index 16f28e36..11f65202 100644 --- a/src/Core__JSON.res +++ b/src/Core__JSON.res @@ -1,4 +1,11 @@ -type t = Js.Json.t +@unboxed +type rec t = Js.Json.t = + | Boolean(bool) + | @as(null) Null + | String(string) + | Number(float) + | Object(Core__Dict.t) + | Array(array) @raises @val external parseExn: string => t = "JSON.parse" @raises @val external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" diff --git a/src/Core__JSON.resi b/src/Core__JSON.resi index 32389d70..a5636ed7 100644 --- a/src/Core__JSON.resi +++ b/src/Core__JSON.resi @@ -5,7 +5,14 @@ Functions for interacting with JSON. /** A type representing a JSON object. */ -type t = Js.Json.t +@unboxed +type rec t = Js.Json.t = + | Boolean(bool) + | @as(null) Null + | String(string) + | Number(float) + | Object(Core__Dict.t) + | Array(array) /** `parseExn(string)` diff --git a/src/Core__List.mjs b/src/Core__List.mjs index 2f23f3d0..cc778f56 100644 --- a/src/Core__List.mjs +++ b/src/Core__List.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as Belt_Array from "rescript/lib/es6/belt_Array.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; import * as Core__Array from "./Core__Array.mjs"; @@ -511,7 +510,9 @@ function concat(xs, ys) { } function map(xs, f) { - var f$1 = Curry.__1(f); + var f$1 = function (x) { + return f(x); + }; if (!xs) { return /* [] */0; } @@ -524,7 +525,9 @@ function map(xs, f) { } function zipBy(l1, l2, f) { - var f$1 = Curry.__2(f); + var f$1 = function (x, y) { + return f(x, y); + }; if (!l1) { return /* [] */0; } @@ -540,7 +543,9 @@ function zipBy(l1, l2, f) { } function mapWithIndex(xs, f) { - var f$1 = Curry.__2(f); + var f$1 = function (i, x) { + return f(i, x); + }; if (!xs) { return /* [] */0; } @@ -553,7 +558,9 @@ function mapWithIndex(xs, f) { } function makeBy(n, f) { - var f$1 = Curry.__1(f); + var f$1 = function (x) { + return f(x); + }; if (n <= 0) { return /* [] */0; } @@ -728,7 +735,9 @@ function concatMany(xs) { } function mapReverse(l, f) { - var f$1 = Curry.__1(f); + var f$1 = function (x) { + return f(x); + }; var _accu = /* [] */0; var _xs = l; while(true) { @@ -748,7 +757,9 @@ function mapReverse(l, f) { function forEach(xs, f) { var _xs = xs; - var f$1 = Curry.__1(f); + var f$1 = function (x) { + return f(x); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -761,9 +772,11 @@ function forEach(xs, f) { } function forEachWithIndex(l, f) { + var f$1 = function (i, x) { + return f(i, x); + }; var _xs = l; var _i = 0; - var f$1 = Curry.__2(f); while(true) { var i = _i; var xs = _xs; @@ -780,7 +793,9 @@ function forEachWithIndex(l, f) { function reduce(l, accu, f) { var _l = l; var _accu = accu; - var f$1 = Curry.__2(f); + var f$1 = function (acc, x) { + return f(acc, x); + }; while(true) { var accu$1 = _accu; var l$1 = _l; @@ -802,7 +817,9 @@ function reduceReverseUnsafeU(l, accu, f) { } function reduceReverse(l, accu, f) { - var f$1 = Curry.__2(f); + var f$1 = function (a, b) { + return f(a, b); + }; var len = length(l); if (len < 1000) { return reduceReverseUnsafeU(l, accu, f$1); @@ -812,7 +829,9 @@ function reduceReverse(l, accu, f) { } function reduceWithIndex(l, acc, f) { - var f$1 = Curry.__3(f); + var f$1 = function (acc, x, i) { + return f(acc, x, i); + }; var _l = l; var _acc = acc; var _i = 0; @@ -831,7 +850,9 @@ function reduceWithIndex(l, acc, f) { } function mapReverse2(l1, l2, f) { - var f$1 = Curry.__2(f); + var f$1 = function (a, b) { + return f(a, b); + }; var _l1 = l1; var _l2 = l2; var _accu = /* [] */0; @@ -858,7 +879,9 @@ function mapReverse2(l1, l2, f) { function forEach2(l1, l2, f) { var _l1 = l1; var _l2 = l2; - var f$1 = Curry.__2(f); + var f$1 = function (a, b) { + return f(a, b); + }; while(true) { var l2$1 = _l2; var l1$1 = _l1; @@ -879,7 +902,9 @@ function reduce2(l1, l2, acc, f) { var _l1 = l1; var _l2 = l2; var _accu = acc; - var f$1 = Curry.__3(f); + var f$1 = function (a, b, c) { + return f(a, b, c); + }; while(true) { var accu = _accu; var l2$1 = _l2; @@ -906,7 +931,9 @@ function reduceReverse2UnsafeU(l1, l2, accu, f) { } function reduceReverse2(l1, l2, acc, f) { - var f$1 = Curry.__3(f); + var f$1 = function (a, b, c) { + return f(a, b, c); + }; var len = length(l1); if (len < 1000) { return reduceReverse2UnsafeU(l1, l2, acc, f$1); @@ -917,7 +944,9 @@ function reduceReverse2(l1, l2, acc, f) { function every(xs, p) { var _xs = xs; - var p$1 = Curry.__1(p); + var p$1 = function (x) { + return p(x); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -933,7 +962,9 @@ function every(xs, p) { function some(xs, p) { var _xs = xs; - var p$1 = Curry.__1(p); + var p$1 = function (x) { + return p(x); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -950,7 +981,9 @@ function some(xs, p) { function every2(l1, l2, p) { var _l1 = l1; var _l2 = l2; - var p$1 = Curry.__2(p); + var p$1 = function (a, b) { + return p(a, b); + }; while(true) { var l2$1 = _l2; var l1$1 = _l1; @@ -1003,7 +1036,7 @@ function compare(_l1, _l2, p) { if (!l2) { return 1; } - var c = Curry._2(p, l1.hd, l2.hd); + var c = p(l1.hd, l2.hd); if (c !== 0) { return c; } @@ -1027,7 +1060,7 @@ function equal(_l1, _l2, p) { if (!l2) { return false; } - if (!Curry._2(p, l1.hd, l2.hd)) { + if (!p(l1.hd, l2.hd)) { return false; } _l2 = l2.tl; @@ -1039,7 +1072,9 @@ function equal(_l1, _l2, p) { function some2(l1, l2, p) { var _l1 = l1; var _l2 = l2; - var p$1 = Curry.__2(p); + var p$1 = function (a, b) { + return p(a, b); + }; while(true) { var l2$1 = _l2; var l1$1 = _l1; @@ -1060,7 +1095,9 @@ function some2(l1, l2, p) { function has(xs, x, eq) { var _xs = xs; - var eq$1 = Curry.__2(eq); + var eq$1 = function (a, b) { + return eq(a, b); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -1076,7 +1113,9 @@ function has(xs, x, eq) { function getAssoc(xs, x, eq) { var _xs = xs; - var eq$1 = Curry.__2(eq); + var eq$1 = function (a, b) { + return eq(a, b); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -1093,7 +1132,9 @@ function getAssoc(xs, x, eq) { function hasAssoc(xs, x, eq) { var _xs = xs; - var eq$1 = Curry.__2(eq); + var eq$1 = function (a, b) { + return eq(a, b); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -1108,7 +1149,9 @@ function hasAssoc(xs, x, eq) { } function removeAssoc(xs, x, eq) { - var eq$1 = Curry.__2(eq); + var eq$1 = function (a, b) { + return eq(a, b); + }; if (!xs) { return /* [] */0; } @@ -1130,7 +1173,9 @@ function removeAssoc(xs, x, eq) { } function setAssoc(xs, x, k, eq) { - var eq$1 = Curry.__2(eq); + var eq$1 = function (a, b) { + return eq(a, b); + }; if (!xs) { return { hd: [ @@ -1177,7 +1222,9 @@ function sort(xs, cmp) { function getBy(xs, p) { var _xs = xs; - var p$1 = Curry.__1(p); + var p$1 = function (a) { + return p(a); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -1194,7 +1241,9 @@ function getBy(xs, p) { function filter(xs, p) { var _xs = xs; - var p$1 = Curry.__1(p); + var p$1 = function (x) { + return p(x); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -1216,7 +1265,9 @@ function filter(xs, p) { } function filterWithIndex(xs, p) { - var p$1 = Curry.__2(p); + var p$1 = function (x, i) { + return p(x, i); + }; var _xs = xs; var _i = 0; while(true) { @@ -1243,7 +1294,9 @@ function filterWithIndex(xs, p) { function filterMap(xs, p) { var _xs = xs; - var p$1 = Curry.__1(p); + var p$1 = function (x) { + return p(x); + }; while(true) { var xs$1 = _xs; if (!xs$1) { @@ -1265,7 +1318,9 @@ function filterMap(xs, p) { } function partition(l, p) { - var p$1 = Curry.__1(p); + var p$1 = function (x) { + return p(x); + }; if (!l) { return [ /* [] */0, diff --git a/src/Core__List.res b/src/Core__List.res index 44d92857..e4d4edef 100644 --- a/src/Core__List.res +++ b/src/Core__List.res @@ -154,7 +154,7 @@ let rec partitionAux = (p, cell, precX, precY) => | list{} => () | list{h, ...t} => let next = mutableCell(h, list{}) - if p(. h) { + if p(h) { unsafeMutateTail(precX, next) partitionAux(p, t, next, precY) } else { @@ -190,7 +190,7 @@ let rec copyAuxWitFilter = (f, cellX, prec) => switch cellX { | list{} => () | list{h, ...t} => - if f(. h) { + if f(h) { let next = mutableCell(h, list{}) unsafeMutateTail(prec, next) copyAuxWitFilter(f, t, next) @@ -203,7 +203,7 @@ let rec copyAuxWithFilterIndex = (f, cellX, prec, i) => switch cellX { | list{} => () | list{h, ...t} => - if f(. h, i) { + if f(h, i) { let next = mutableCell(h, list{}) unsafeMutateTail(prec, next) copyAuxWithFilterIndex(f, t, next, i + 1) @@ -216,7 +216,7 @@ let rec copyAuxWitFilterMap = (f, cellX, prec) => switch cellX { | list{} => () | list{h, ...t} => - switch f(. h) { + switch f(h) { | Some(h) => let next = mutableCell(h, list{}) unsafeMutateTail(prec, next) @@ -229,7 +229,7 @@ let rec removeAssocAuxWithMap = (cellX, x, prec, f) => switch cellX { | list{} => false | list{(a, _) as h, ...t} => - if f(. a, x) { + if f(a, x) { unsafeMutateTail(prec, t) true } else { @@ -243,7 +243,7 @@ let rec setAssocAuxWithMap = (cellX, x, k, prec, eq) => switch cellX { | list{} => false | list{(a, _) as h, ...t} => - if eq(. a, x) { + if eq(a, x) { unsafeMutateTail(prec, list{(x, k), ...t}) true } else { @@ -257,7 +257,7 @@ let rec copyAuxWithMap = (cellX, prec, f) => switch cellX { | list{} => () | list{h, ...t} => - let next = mutableCell(f(. h), list{}) + let next = mutableCell(f(h), list{}) unsafeMutateTail(prec, next) copyAuxWithMap(t, next, f) } @@ -274,7 +274,7 @@ let rec zipAux = (cellX, cellY, prec) => let rec copyAuxWithMap2 = (f, cellX, cellY, prec) => switch (cellX, cellY) { | (list{h1, ...t1}, list{h2, ...t2}) => - let next = mutableCell(f(. h1, h2), list{}) + let next = mutableCell(f(h1, h2), list{}) unsafeMutateTail(prec, next) copyAuxWithMap2(f, t1, t2, next) | (list{}, _) | (_, list{}) => () @@ -283,7 +283,7 @@ let rec copyAuxWithMap2 = (f, cellX, cellY, prec) => let rec copyAuxWithMapI = (f, i, cellX, prec) => switch cellX { | list{h, ...t} => - let next = mutableCell(f(. i, h), list{}) + let next = mutableCell(f(i, h), list{}) unsafeMutateTail(prec, next) copyAuxWithMapI(f, i + 1, t, next) | list{} => () @@ -383,44 +383,44 @@ let mapU = (xs, f) => switch xs { | list{} => list{} | list{h, ...t} => - let cell = mutableCell(f(. h), list{}) + let cell = mutableCell(f(h), list{}) copyAuxWithMap(t, cell, f) cell } -let map = (xs, f) => mapU(xs, (. x) => f(x)) +let map = (xs, f) => mapU(xs, x => f(x)) let zipByU = (l1, l2, f) => switch (l1, l2) { | (list{a1, ...l1}, list{a2, ...l2}) => - let cell = mutableCell(f(. a1, a2), list{}) + let cell = mutableCell(f(a1, a2), list{}) copyAuxWithMap2(f, l1, l2, cell) cell | (list{}, _) | (_, list{}) => list{} } -let zipBy = (l1, l2, f) => zipByU(l1, l2, (. x, y) => f(x, y)) +let zipBy = (l1, l2, f) => zipByU(l1, l2, (x, y) => f(x, y)) let mapWithIndexU = (xs, f) => switch xs { | list{} => list{} | list{h, ...t} => - let cell = mutableCell(f(. 0, h), list{}) + let cell = mutableCell(f(0, h), list{}) copyAuxWithMapI(f, 1, t, cell) cell } -let mapWithIndex = (xs, f) => mapWithIndexU(xs, (. i, x) => f(i, x)) +let mapWithIndex = (xs, f) => mapWithIndexU(xs, (i, x) => f(i, x)) let makeByU = (n, f) => if n <= 0 { list{} } else { - let headX = mutableCell(f(. 0), list{}) + let headX = mutableCell(f(0), list{}) let cur = ref(headX) let i = ref(1) while i.contents < n { - let v = mutableCell(f(. i.contents), list{}) + let v = mutableCell(f(i.contents), list{}) unsafeMutateTail(cur.contents, v) cur.contents = v i.contents = i.contents + 1 @@ -429,7 +429,7 @@ let makeByU = (n, f) => headX } -let makeBy = (n, f) => makeByU(n, (. x) => f(x)) +let makeBy = (n, f) => makeByU(n, x => f(x)) let make = (type a, n, v: a): list => if n <= 0 { @@ -547,46 +547,46 @@ let concatMany = xs => let rec mapRevAux = (f, accu, xs) => switch xs { | list{} => accu - | list{a, ...l} => mapRevAux(f, list{f(. a), ...accu}, l) + | list{a, ...l} => mapRevAux(f, list{f(a), ...accu}, l) } let mapReverseU = (l, f) => mapRevAux(f, list{}, l) -let mapReverse = (l, f) => mapReverseU(l, (. x) => f(x)) +let mapReverse = (l, f) => mapReverseU(l, x => f(x)) let rec forEachU = (xs, f) => switch xs { | list{} => () | list{a, ...l} => - f(. a)->ignore + f(a)->ignore forEachU(l, f) } -let forEach = (xs, f) => forEachU(xs, (. x) => f(x)) +let forEach = (xs, f) => forEachU(xs, x => f(x)) let rec iteri = (xs, i, f) => switch xs { | list{} => () | list{a, ...l} => - f(. i, a)->ignore + f(i, a)->ignore iteri(l, i + 1, f) } let forEachWithIndexU = (l, f) => iteri(l, 0, f) -let forEachWithIndex = (l, f) => forEachWithIndexU(l, (. i, x) => f(i, x)) +let forEachWithIndex = (l, f) => forEachWithIndexU(l, (i, x) => f(i, x)) let rec reduceU = (l, accu, f) => switch l { | list{} => accu - | list{a, ...l} => reduceU(l, f(. accu, a), f) + | list{a, ...l} => reduceU(l, f(accu, a), f) } -let reduce = (l, accu, f) => reduceU(l, accu, (. acc, x) => f(acc, x)) +let reduce = (l, accu, f) => reduceU(l, accu, (acc, x) => f(acc, x)) let rec reduceReverseUnsafeU = (l, accu, f) => switch l { | list{} => accu - | list{a, ...l} => f(. reduceReverseUnsafeU(l, accu, f), a) + | list{a, ...l} => f(reduceReverseUnsafeU(l, accu, f), a) } let reduceReverseU = (type a b, l: list, acc: b, f) => { @@ -598,50 +598,50 @@ let reduceReverseU = (type a b, l: list, acc: b, f) => { } } -let reduceReverse = (l, accu, f) => reduceReverseU(l, accu, (. a, b) => f(a, b)) +let reduceReverse = (l, accu, f) => reduceReverseU(l, accu, (a, b) => f(a, b)) let rec reduceWithIndexAuxU = (l, acc, f, i) => switch l { | list{} => acc - | list{x, ...xs} => reduceWithIndexAuxU(xs, f(. acc, x, i), f, i + 1) + | list{x, ...xs} => reduceWithIndexAuxU(xs, f(acc, x, i), f, i + 1) } let reduceWithIndexU = (l, acc, f) => reduceWithIndexAuxU(l, acc, f, 0) -let reduceWithIndex = (l, acc, f) => reduceWithIndexU(l, acc, (. acc, x, i) => f(acc, x, i)) +let reduceWithIndex = (l, acc, f) => reduceWithIndexU(l, acc, (acc, x, i) => f(acc, x, i)) let rec mapRevAux2 = (l1, l2, accu, f) => switch (l1, l2) { - | (list{a1, ...l1}, list{a2, ...l2}) => mapRevAux2(l1, l2, list{f(. a1, a2), ...accu}, f) + | (list{a1, ...l1}, list{a2, ...l2}) => mapRevAux2(l1, l2, list{f(a1, a2), ...accu}, f) | (_, list{}) | (list{}, _) => accu } let mapReverse2U = (l1, l2, f) => mapRevAux2(l1, l2, list{}, f) -let mapReverse2 = (l1, l2, f) => mapReverse2U(l1, l2, (. a, b) => f(a, b)) +let mapReverse2 = (l1, l2, f) => mapReverse2U(l1, l2, (a, b) => f(a, b)) let rec forEach2U = (l1, l2, f) => switch (l1, l2) { | (list{a1, ...l1}, list{a2, ...l2}) => - f(. a1, a2)->ignore + f(a1, a2)->ignore forEach2U(l1, l2, f) | (list{}, _) | (_, list{}) => () } -let forEach2 = (l1, l2, f) => forEach2U(l1, l2, (. a, b) => f(a, b)) +let forEach2 = (l1, l2, f) => forEach2U(l1, l2, (a, b) => f(a, b)) let rec reduce2U = (l1, l2, accu, f) => switch (l1, l2) { - | (list{a1, ...l1}, list{a2, ...l2}) => reduce2U(l1, l2, f(. accu, a1, a2), f) + | (list{a1, ...l1}, list{a2, ...l2}) => reduce2U(l1, l2, f(accu, a1, a2), f) | (list{}, _) | (_, list{}) => accu } -let reduce2 = (l1, l2, acc, f) => reduce2U(l1, l2, acc, (. a, b, c) => f(a, b, c)) +let reduce2 = (l1, l2, acc, f) => reduce2U(l1, l2, acc, (a, b, c) => f(a, b, c)) let rec reduceReverse2UnsafeU = (l1, l2, accu, f) => switch (l1, l2) { | (list{}, list{}) => accu - | (list{a1, ...l1}, list{a2, ...l2}) => f(. reduceReverse2UnsafeU(l1, l2, accu, f), a1, a2) + | (list{a1, ...l1}, list{a2, ...l2}) => f(reduceReverse2UnsafeU(l1, l2, accu, f), a1, a2) | (_, list{}) | (list{}, _) => accu } @@ -654,31 +654,31 @@ let reduceReverse2U = (type a b c, l1: list, l2: list, acc: c, f) => { } } -let reduceReverse2 = (l1, l2, acc, f) => reduceReverse2U(l1, l2, acc, (. a, b, c) => f(a, b, c)) +let reduceReverse2 = (l1, l2, acc, f) => reduceReverse2U(l1, l2, acc, (a, b, c) => f(a, b, c)) let rec everyU = (xs, p) => switch xs { | list{} => true - | list{a, ...l} => p(. a) && everyU(l, p) + | list{a, ...l} => p(a) && everyU(l, p) } -let every = (xs, p) => everyU(xs, (. x) => p(x)) +let every = (xs, p) => everyU(xs, x => p(x)) let rec someU = (xs, p) => switch xs { | list{} => false - | list{a, ...l} => p(. a) || someU(l, p) + | list{a, ...l} => p(a) || someU(l, p) } -let some = (xs, p) => someU(xs, (. x) => p(x)) +let some = (xs, p) => someU(xs, x => p(x)) let rec every2U = (l1, l2, p) => switch (l1, l2) { | (_, list{}) | (list{}, _) => true - | (list{a1, ...l1}, list{a2, ...l2}) => p(. a1, a2) && every2U(l1, l2, p) + | (list{a1, ...l1}, list{a2, ...l2}) => p(a1, a2) && every2U(l1, l2, p) } -let every2 = (l1, l2, p) => every2U(l1, l2, (. a, b) => p(a, b)) +let every2 = (l1, l2, p) => every2U(l1, l2, (a, b) => p(a, b)) let rec compareLength = (l1, l2) => switch (l1, l2) { @@ -718,45 +718,45 @@ let rec equal = (l1, l2, p) => let rec some2U = (l1, l2, p) => switch (l1, l2) { | (list{}, _) | (_, list{}) => false - | (list{a1, ...l1}, list{a2, ...l2}) => p(. a1, a2) || some2U(l1, l2, p) + | (list{a1, ...l1}, list{a2, ...l2}) => p(a1, a2) || some2U(l1, l2, p) } -let some2 = (l1, l2, p) => some2U(l1, l2, (. a, b) => p(a, b)) +let some2 = (l1, l2, p) => some2U(l1, l2, (a, b) => p(a, b)) let rec hasU = (xs, x, eq) => switch xs { | list{} => false - | list{a, ...l} => eq(. a, x) || hasU(l, x, eq) + | list{a, ...l} => eq(a, x) || hasU(l, x, eq) } -let has = (xs, x, eq) => hasU(xs, x, (. a, b) => eq(a, b)) +let has = (xs, x, eq) => hasU(xs, x, (a, b) => eq(a, b)) let rec getAssocU = (xs, x, eq) => switch xs { | list{} => None | list{(a, b), ...l} => - if eq(. a, x) { + if eq(a, x) { Some(b) } else { getAssocU(l, x, eq) } } -let getAssoc = (xs, x, eq) => getAssocU(xs, x, (. a, b) => eq(a, b)) +let getAssoc = (xs, x, eq) => getAssocU(xs, x, (a, b) => eq(a, b)) let rec hasAssocU = (xs, x, eq) => switch xs { | list{} => false - | list{(a, _), ...l} => eq(. a, x) || hasAssocU(l, x, eq) + | list{(a, _), ...l} => eq(a, x) || hasAssocU(l, x, eq) } -let hasAssoc = (xs, x, eq) => hasAssocU(xs, x, (. a, b) => eq(a, b)) +let hasAssoc = (xs, x, eq) => hasAssocU(xs, x, (a, b) => eq(a, b)) let removeAssocU = (xs, x, eq) => switch xs { | list{} => list{} | list{(a, _) as pair, ...l} => - if eq(. a, x) { + if eq(a, x) { l } else { let cell = mutableCell(pair, list{}) @@ -769,13 +769,13 @@ let removeAssocU = (xs, x, eq) => } } -let removeAssoc = (xs, x, eq) => removeAssocU(xs, x, (. a, b) => eq(a, b)) +let removeAssoc = (xs, x, eq) => removeAssocU(xs, x, (a, b) => eq(a, b)) let setAssocU = (xs, x, k, eq) => switch xs { | list{} => list{(x, k)} | list{(a, _) as pair, ...l} => - if eq(. a, x) { + if eq(a, x) { list{(x, k), ...l} } else { let cell = mutableCell(pair, list{}) @@ -788,7 +788,7 @@ let setAssocU = (xs, x, k, eq) => } } -let setAssoc = (xs, x, k, eq) => setAssocU(xs, x, k, (. a, b) => eq(a, b)) +let setAssoc = (xs, x, k, eq) => setAssocU(xs, x, k, (a, b) => eq(a, b)) let sort = (xs, cmp) => { let arr = toArray(xs) @@ -800,20 +800,20 @@ let rec getByU = (xs, p) => switch xs { | list{} => None | list{x, ...l} => - if p(. x) { + if p(x) { Some(x) } else { getByU(l, p) } } -let getBy = (xs, p) => getByU(xs, (. a) => p(a)) +let getBy = (xs, p) => getByU(xs, a => p(a)) let rec filterU = (xs, p) => switch xs { | list{} => list{} | list{h, ...t} => - if p(. h) { + if p(h) { let cell = mutableCell(h, list{}) copyAuxWitFilter(p, t, cell) cell @@ -822,14 +822,14 @@ let rec filterU = (xs, p) => } } -let filter = (xs, p) => filterU(xs, (. x) => p(x)) +let filter = (xs, p) => filterU(xs, x => p(x)) let filterWithIndexU = (xs, p) => { let rec auxFilterWithIndex = (xs, p, i) => switch xs { | list{} => list{} | list{h, ...t} => - if p(. h, i) { + if p(h, i) { let cell = mutableCell(h, list{}) copyAuxWithFilterIndex(p, t, cell, i + 1) cell @@ -840,13 +840,13 @@ let filterWithIndexU = (xs, p) => { auxFilterWithIndex(xs, p, 0) } -let filterWithIndex = (xs, p) => filterWithIndexU(xs, (. x, i) => p(x, i)) +let filterWithIndex = (xs, p) => filterWithIndexU(xs, (x, i) => p(x, i)) let rec filterMapU = (xs, p) => switch xs { | list{} => list{} | list{h, ...t} => - switch p(. h) { + switch p(h) { | Some(h) => let cell = mutableCell(h, list{}) copyAuxWitFilterMap(p, t, cell) @@ -855,7 +855,7 @@ let rec filterMapU = (xs, p) => } } -let filterMap = (xs, p) => filterMapU(xs, (. x) => p(x)) +let filterMap = (xs, p) => filterMapU(xs, x => p(x)) let partitionU = (l, p) => switch l { @@ -863,28 +863,28 @@ let partitionU = (l, p) => | list{h, ...t} => let nextX = mutableCell(h, list{}) let nextY = mutableCell(h, list{}) - let b = p(. h) + let b = p(h) partitionAux(p, t, nextX, nextY) if b { ( nextX, switch nextY { | list{_, ...tail} => tail - | list{} => assert false + | list{} => assert(false) }, ) } else { ( switch nextX { | list{_, ...tail} => tail - | list{} => assert false + | list{} => assert(false) }, nextY, ) } } -let partition = (l, p) => partitionU(l, (. x) => p(x)) +let partition = (l, p) => partitionU(l, x => p(x)) let unzip = xs => switch xs { diff --git a/src/Core__Null.mjs b/src/Core__Null.mjs index 30844973..8e8674b4 100644 --- a/src/Core__Null.mjs +++ b/src/Core__Null.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; import * as Core__Option from "./Core__Option.mjs"; @@ -41,14 +40,14 @@ function getExn(value) { function forEach(value, f) { if (value !== null) { - return Curry._1(f, value); + return f(value); } } function map(value, f) { if (value !== null) { - return Curry._1(f, value); + return f(value); } else { return null; } @@ -56,7 +55,7 @@ function map(value, f) { function mapOr(value, $$default, f) { if (value !== null) { - return Curry._1(f, value); + return f(value); } else { return $$default; } @@ -64,7 +63,7 @@ function mapOr(value, $$default, f) { function flatMap(value, f) { if (value !== null) { - return Curry._1(f, value); + return f(value); } else { return null; } diff --git a/src/Core__Null.res b/src/Core__Null.res index cad912d6..1bc9d34b 100644 --- a/src/Core__Null.res +++ b/src/Core__Null.res @@ -1,4 +1,7 @@ -type t<'a> = Js.Null.t<'a> +@unboxed +type t<'a> = Js.Null.t<'a> = + | Value('a) + | @as(null) Null external asNullable: t<'a> => Core__Nullable.t<'a> = "%identity" diff --git a/src/Core__Null.resi b/src/Core__Null.resi index 33149518..ffa7b5d5 100644 --- a/src/Core__Null.resi +++ b/src/Core__Null.resi @@ -7,7 +7,10 @@ If you also need to cover `undefined`, check out `Nullable` instead. /** A type representing a value that can be either `'a` or `null`. */ -type t<'a> = Js.Null.t<'a> +@unboxed +type t<'a> = Js.Null.t<'a> = + | Value('a) + | @as(null) Null /** Converts a `Null.t` into a `Nullable.t`. diff --git a/src/Core__Nullable.mjs b/src/Core__Nullable.mjs index edfbe37e..ea87d827 100644 --- a/src/Core__Nullable.mjs +++ b/src/Core__Nullable.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; import * as Core__Option from "./Core__Option.mjs"; @@ -40,7 +39,7 @@ function getExn(value) { function forEach(value, f) { if (!(value == null)) { - return Curry._1(f, value); + return f(value); } } @@ -49,7 +48,7 @@ function map(value, f) { if (value == null) { return value; } else { - return Curry._1(f, value); + return f(value); } } @@ -57,7 +56,7 @@ function mapOr(value, $$default, f) { if (value == null) { return $$default; } else { - return Curry._1(f, value); + return f(value); } } @@ -65,7 +64,7 @@ function flatMap(value, f) { if (value == null) { return value; } else { - return Curry._1(f, value); + return f(value); } } diff --git a/src/Core__Nullable.res b/src/Core__Nullable.res index a639671d..c6ca2ace 100644 --- a/src/Core__Nullable.res +++ b/src/Core__Nullable.res @@ -1,4 +1,7 @@ -type t<'a> = Js.Nullable.t<'a> +type t<'a> = Js.Nullable.t<'a> = + | Value('a) + | @as(null) Null + | @as(undefined) Undefined external null: t<'a> = "#null" diff --git a/src/Core__Nullable.resi b/src/Core__Nullable.resi index f303ca73..5b840b5f 100644 --- a/src/Core__Nullable.resi +++ b/src/Core__Nullable.resi @@ -8,7 +8,11 @@ Primarily useful when interoping with JavaScript when you don't know whether you Type representing a nullable value. A nullable value can be the value `'a`, `null` or `undefined`. */ -type t<'a> = Js.Nullable.t<'a> +@unboxed +type t<'a> = Js.Nullable.t<'a> = + | Value('a) + | @as(null) Null + | @as(undefined) Undefined /** The value `null`. diff --git a/src/Core__Option.mjs b/src/Core__Option.mjs index a98a6572..776bc0bf 100644 --- a/src/Core__Option.mjs +++ b/src/Core__Option.mjs @@ -1,10 +1,9 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; function filter(opt, p) { - if (opt !== undefined && Curry._1(p, Caml_option.valFromOption(opt))) { + if (opt !== undefined && p(Caml_option.valFromOption(opt))) { return opt; } @@ -12,7 +11,7 @@ function filter(opt, p) { function forEach(opt, f) { if (opt !== undefined) { - return Curry._1(f, Caml_option.valFromOption(opt)); + return f(Caml_option.valFromOption(opt)); } } @@ -29,7 +28,7 @@ function getExn(x) { function mapOr(opt, $$default, f) { if (opt !== undefined) { - return Curry._1(f, Caml_option.valFromOption(opt)); + return f(Caml_option.valFromOption(opt)); } else { return $$default; } @@ -37,14 +36,14 @@ function mapOr(opt, $$default, f) { function map(opt, f) { if (opt !== undefined) { - return Caml_option.some(Curry._1(f, Caml_option.valFromOption(opt))); + return Caml_option.some(f(Caml_option.valFromOption(opt))); } } function flatMap(opt, f) { if (opt !== undefined) { - return Curry._1(f, Caml_option.valFromOption(opt)); + return f(Caml_option.valFromOption(opt)); } } @@ -76,7 +75,7 @@ function isNone(x) { function equal(a, b, eq) { if (a !== undefined) { if (b !== undefined) { - return Curry._2(eq, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return eq(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return false; } @@ -88,7 +87,7 @@ function equal(a, b, eq) { function compare(a, b, cmp) { if (a !== undefined) { if (b !== undefined) { - return Curry._2(cmp, Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + return cmp(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); } else { return 1; } diff --git a/src/Core__Promise.mjs b/src/Core__Promise.mjs index f5b4be50..56ad017f 100644 --- a/src/Core__Promise.mjs +++ b/src/Core__Promise.mjs @@ -1,11 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; function $$catch(promise, callback) { return promise.catch(function (err) { - return Curry._1(callback, Caml_js_exceptions.internalToOCamlException(err)); + return callback(Caml_js_exceptions.internalToOCamlException(err)); }); } diff --git a/src/Core__Promise.res b/src/Core__Promise.res index ab5bf589..35b1b898 100644 --- a/src/Core__Promise.res +++ b/src/Core__Promise.res @@ -1,15 +1,15 @@ type t<+'a> = promise<'a> @new -external make: ((@uncurry (. 'a) => unit, (. 'e) => unit) => unit) => t<'a> = "Promise" +external make: (('a => unit, 'e => unit) => unit) => t<'a> = "Promise" @val @scope("Promise") external resolve: 'a => t<'a> = "resolve" -@send external then: (t<'a>, @uncurry ('a => t<'b>)) => t<'b> = "then" +@send external then: (t<'a>, 'a => t<'b>) => t<'b> = "then" @send -external thenResolve: (t<'a>, @uncurry ('a => 'b)) => t<'b> = "then" +external thenResolve: (t<'a>, 'a => 'b) => t<'b> = "then" @send external finally: (t<'a>, unit => unit) => t<'a> = "finally" @@ -35,7 +35,7 @@ external all5: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>)) => t<('a, 'b, 'c, 'd, 'e)> external all6: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>)) => t<('a, 'b, 'c, 'd, 'e, 'f)> = "all" @send -external _catch: (t<'a>, @uncurry (exn => t<'a>)) => t<'a> = "catch" +external _catch: (t<'a>, exn => t<'a>) => t<'a> = "catch" let catch = (promise: promise<'a>, callback: exn => promise<'a>): promise<'a> => { _catch(promise, err => { diff --git a/src/Core__Promise.resi b/src/Core__Promise.resi index d97b4caa..ec482ff9 100644 --- a/src/Core__Promise.resi +++ b/src/Core__Promise.resi @@ -73,7 +73,7 @@ Promise.make((resolve, reject) => { ``` */ @new -external make: ((@uncurry (. 'a) => unit, (. 'e) => unit) => unit) => t<'a> = "Promise" +external make: (('a => unit, 'e => unit) => unit) => t<'a> = "Promise" /** `catch(promise, errorCallback)` registers an exception handler in a promise chain. @@ -139,7 +139,7 @@ Promise.resolve(5) ``` */ @send -external then: (t<'a>, @uncurry ('a => t<'b>)) => t<'b> = "then" +external then: (t<'a>, 'a => t<'b>) => t<'b> = "then" /** `thenResolve(promise, callback)` converts an encapsulated value of a promise @@ -163,7 +163,7 @@ In case you want to return another promise in your `callback`, consider using `then` instead. */ @send -external thenResolve: (t<'a>, @uncurry ('a => 'b)) => t<'b> = "then" +external thenResolve: (t<'a>, 'a => 'b) => t<'b> = "then" /** `finally(promise, callback)` is used to execute a function that is called no diff --git a/src/Core__Result.mjs b/src/Core__Result.mjs index 5f7e0c28..6ec9cb05 100644 --- a/src/Core__Result.mjs +++ b/src/Core__Result.mjs @@ -1,9 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Curry from "rescript/lib/es6/curry.js"; function getExn(x) { - if (x.TAG === /* Ok */0) { + if (x.TAG === "Ok") { return x._0; } throw { @@ -13,18 +12,18 @@ function getExn(x) { } function mapOr(opt, $$default, f) { - if (opt.TAG === /* Ok */0) { - return Curry._1(f, opt._0); + if (opt.TAG === "Ok") { + return f(opt._0); } else { return $$default; } } function map(opt, f) { - if (opt.TAG === /* Ok */0) { + if (opt.TAG === "Ok") { return { - TAG: /* Ok */0, - _0: Curry._1(f, opt._0) + TAG: "Ok", + _0: f(opt._0) }; } else { return opt; @@ -32,15 +31,15 @@ function map(opt, f) { } function flatMap(opt, f) { - if (opt.TAG === /* Ok */0) { - return Curry._1(f, opt._0); + if (opt.TAG === "Ok") { + return f(opt._0); } else { return opt; } } function getOr(opt, $$default) { - if (opt.TAG === /* Ok */0) { + if (opt.TAG === "Ok") { return opt._0; } else { return $$default; @@ -48,7 +47,7 @@ function getOr(opt, $$default) { } function isOk(x) { - if (x.TAG === /* Ok */0) { + if (x.TAG === "Ok") { return true; } else { return false; @@ -56,7 +55,7 @@ function isOk(x) { } function isError(x) { - if (x.TAG === /* Ok */0) { + if (x.TAG === "Ok") { return false; } else { return true; @@ -64,13 +63,13 @@ function isError(x) { } function equal(a, b, f) { - if (a.TAG === /* Ok */0) { - if (b.TAG === /* Ok */0) { - return Curry._2(f, a._0, b._0); + if (a.TAG === "Ok") { + if (b.TAG === "Ok") { + return f(a._0, b._0); } else { return false; } - } else if (b.TAG === /* Ok */0) { + } else if (b.TAG === "Ok") { return false; } else { return true; @@ -78,13 +77,13 @@ function equal(a, b, f) { } function compare(a, b, f) { - if (a.TAG === /* Ok */0) { - if (b.TAG === /* Ok */0) { - return Curry._2(f, a._0, b._0); + if (a.TAG === "Ok") { + if (b.TAG === "Ok") { + return f(a._0, b._0); } else { return 1; } - } else if (b.TAG === /* Ok */0) { + } else if (b.TAG === "Ok") { return -1; } else { return 0; @@ -92,19 +91,19 @@ function compare(a, b, f) { } function forEach(r, f) { - if (r.TAG === /* Ok */0) { - return Curry._1(f, r._0); + if (r.TAG === "Ok") { + return f(r._0); } } function mapError(r, f) { - if (r.TAG === /* Ok */0) { + if (r.TAG === "Ok") { return r; } else { return { - TAG: /* Error */1, - _0: Curry._1(f, r._0) + TAG: "Error", + _0: f(r._0) }; } } diff --git a/src/Core__Result.res b/src/Core__Result.res index 375ceafa..a2abc3d0 100644 --- a/src/Core__Result.res +++ b/src/Core__Result.res @@ -22,8 +22,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -type t<'a, 'b> = result<'a, 'b> = Ok('a) | Error('b) - let getExn = x => switch x { | Ok(x) => x diff --git a/src/Core__Result.resi b/src/Core__Result.resi index e8ba766d..8d626053 100644 --- a/src/Core__Result.resi +++ b/src/Core__Result.resi @@ -38,15 +38,13 @@ ```res example type responseError = NotAvailable | NotFound - type queryResult = t + type queryResult = result let failQueryUser = (username: string): queryResult => { Error(NotAvailable) } ``` */ -type t<'a, 'b> = result<'a, 'b> = Ok('a) | Error('b) - /** `getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception @@ -56,7 +54,7 @@ type t<'a, 'b> = result<'a, 'b> = Ok('a) | Error('b) Result.getExn(Result.Error("Invalid data")) /* raises exception */ ``` */ -let getExn: t<'a, 'b> => 'a +let getExn: result<'a, 'b> => 'a /** `mapOr(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, @@ -70,10 +68,10 @@ let getExn: t<'a, 'b> => 'a Result.mapOr(error, 0, (x) => x / 2) == 0 ``` */ -let mapOr: (t<'a, 'c>, 'b, 'a => 'b) => 'b +let mapOr: (result<'a, 'c>, 'b, 'a => 'b) => 'b @deprecated("Use mapOr instead") -let mapWithDefault: (t<'a, 'c>, 'b, 'a => 'b) => 'b +let mapWithDefault: (result<'a, 'c>, 'b, 'a => 'b) => 'b /** `map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res @@ -88,7 +86,7 @@ let mapWithDefault: (t<'a, 'c>, 'b, 'a => 'b) => 'b Result.map(Error("Invalid data"), f) == Error("Invalid data") ``` */ -let map: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> +let map: (result<'a, 'c>, 'a => 'b) => result<'b, 'c> /** `flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res @@ -110,7 +108,7 @@ let map: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> Result.flatMap(Error("Already bad"), recip) == Error("Already bad") ``` */ -let flatMap: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c> +let flatMap: (result<'a, 'c>, 'a => result<'b, 'c>) => result<'b, 'c> /** `getOr(res, defaultValue)`: If `res` is `Ok(n)`, returns `n`, @@ -122,22 +120,22 @@ let flatMap: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c> Result.getOr(Error("Invalid Data"), 0) == 0 ``` */ -let getOr: (t<'a, 'b>, 'a) => 'a +let getOr: (result<'a, 'b>, 'a) => 'a @deprecated("Use getOr instead") -let getWithDefault: (t<'a, 'b>, 'a) => 'a +let getWithDefault: (result<'a, 'b>, 'a) => 'a /** `isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is the `Error(e)` variant. */ -let isOk: t<'a, 'b> => bool +let isOk: result<'a, 'b> => bool /** `isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if it is the `Ok(n)` variant. */ -let isError: t<'a, 'b> => bool +let isError: result<'a, 'b> => bool /** `equal(res1, res2, f)`: Determine if two `Result` variables are equal with @@ -166,7 +164,7 @@ let isError: t<'a, 'b> => bool Result.equal(bad1, bad2, mod10equal) == true ``` */ -let equal: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool +let equal: (result<'a, 'c>, result<'b, 'd>, ('a, 'b) => bool) => bool /** `compare(res1, res2, f)`: Compare two `Result` variables with respect to a @@ -202,7 +200,7 @@ let equal: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool Result.compare(Error("x"), Error("y"), mod10cmp) == 0. ``` */ -let compare: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => Core__Ordering.t) => Core__Ordering.t +let compare: (result<'a, 'c>, result<'b, 'd>, ('a, 'b) => Core__Ordering.t) => Core__Ordering.t /** `forEach(res, f)` runs the provided function `f` on the `Ok` value. If `res` is `Error`, nothing happens. @@ -214,7 +212,7 @@ Result.forEach(Ok(3), Console.log) // Logs "3", returns () Result.forEach(Error("x"), Console.log) // Does nothing, returns () ``` */ -let forEach: (t<'a, 'b>, 'a => unit) => unit +let forEach: (result<'a, 'b>, 'a => unit) => unit /** `mapError(r, f)` generates a new `result` by applying the function `f` to the `Error` value. If the source is `Ok`, return it as-is. diff --git a/src/Core__String.res b/src/Core__String.res index 8fb56863..4d75467b 100644 --- a/src/Core__String.res +++ b/src/Core__String.res @@ -61,27 +61,21 @@ type normalizeForm = [#NFC | #NFD | #NFKC | #NFKD] external unsafeReplaceRegExpBy0: ( string, Core__RegExp.t, - (@uncurry ~match: string, ~offset: int, ~input: string) => string, + (~match: string, ~offset: int, ~input: string) => string, ) => string = "replace" @send external unsafeReplaceRegExpBy1: ( string, Core__RegExp.t, - (@uncurry ~match: string, ~group1: string, ~offset: int, ~input: string) => string, + (~match: string, ~group1: string, ~offset: int, ~input: string) => string, ) => string = "replace" @send external unsafeReplaceRegExpBy2: ( string, Core__RegExp.t, - ( - @uncurry ~match: string, - ~group1: string, - ~group2: string, - ~offset: int, - ~input: string, - ) => string, + (~match: string, ~group1: string, ~group2: string, ~offset: int, ~input: string) => string, ) => string = "replace" @send @@ -89,7 +83,7 @@ external unsafeReplaceRegExpBy3: ( string, Core__RegExp.t, ( - @uncurry ~match: string, + ~match: string, ~group1: string, ~group2: string, ~group3: string, diff --git a/src/Core__String.resi b/src/Core__String.resi index 89b574fa..c3cdce44 100644 --- a/src/Core__String.resi +++ b/src/Core__String.resi @@ -579,7 +579,7 @@ String.unsafeReplaceRegExpBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" external unsafeReplaceRegExpBy0: ( string, Core__RegExp.t, - (@uncurry ~match: string, ~offset: int, ~input: string) => string, + (~match: string, ~offset: int, ~input: string) => string, ) => string = "replace" /** @@ -602,7 +602,7 @@ String.unsafeReplaceRegExpBy1(str, re, matchFn) == "Jony is 41" external unsafeReplaceRegExpBy1: ( string, Core__RegExp.t, - (@uncurry ~match: string, ~group1: string, ~offset: int, ~input: string) => string, + (~match: string, ~group1: string, ~offset: int, ~input: string) => string, ) => string = "replace" /** @@ -628,13 +628,7 @@ String.unsafeReplaceRegExpBy2(str, re, matchFn) == "42" external unsafeReplaceRegExpBy2: ( string, Core__RegExp.t, - ( - @uncurry ~match: string, - ~group1: string, - ~group2: string, - ~offset: int, - ~input: string, - ) => string, + (~match: string, ~group1: string, ~group2: string, ~offset: int, ~input: string) => string, ) => string = "replace" /** @@ -647,7 +641,7 @@ external unsafeReplaceRegExpBy3: ( string, Core__RegExp.t, ( - @uncurry ~match: string, + ~match: string, ~group1: string, ~group2: string, ~group3: string, diff --git a/src/Core__Type.mjs b/src/Core__Type.mjs index ec38c9ca..a27e6e74 100644 --- a/src/Core__Type.mjs +++ b/src/Core__Type.mjs @@ -6,43 +6,43 @@ function classify(value) { switch (match) { case "[object BigInt]" : return { - TAG: /* BigInt */6, + TAG: "BigInt", _0: value }; case "[object Boolean]" : return { - TAG: /* Bool */0, + TAG: "Bool", _0: value }; case "[object AsyncFunction]" : case "[object Function]" : case "[object GeneratorFunction]" : return { - TAG: /* Function */4, + TAG: "Function", _0: value }; case "[object Null]" : - return /* Null */0; + return "Null"; case "[object Number]" : return { - TAG: /* Number */2, + TAG: "Number", _0: value }; case "[object String]" : return { - TAG: /* String */1, + TAG: "String", _0: value }; case "[object Symbol]" : return { - TAG: /* Symbol */5, + TAG: "Symbol", _0: value }; case "[object Undefined]" : - return /* Undefined */1; + return "Undefined"; default: return { - TAG: /* Object */3, + TAG: "Object", _0: value }; } diff --git a/test/ErrorTests.mjs b/test/ErrorTests.mjs index a9af7afb..dcced1d5 100644 --- a/test/ErrorTests.mjs +++ b/test/ErrorTests.mjs @@ -5,7 +5,7 @@ import * as Js_exn from "rescript/lib/es6/js_exn.js"; import * as RescriptCore from "../src/RescriptCore.mjs"; import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; -function panicTest(param) { +function panicTest() { var caught; try { caught = RescriptCore.panic("uh oh"); @@ -31,7 +31,7 @@ function panicTest(param) { }), "Panic! uh oh"); } -panicTest(undefined); +panicTest(); export { panicTest , diff --git a/test/FloatTests.mjs b/test/FloatTests.mjs index 31bdae36..013aaabb 100644 --- a/test/FloatTests.mjs +++ b/test/FloatTests.mjs @@ -2,8 +2,8 @@ import * as Test from "./Test.mjs"; import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; -import * as Pervasives from "rescript/lib/es6/pervasives.js"; import * as Core__Float from "../src/Core__Float.mjs"; +import * as PervasivesU from "rescript/lib/es6/pervasivesU.js"; var eq = Caml_obj.equal; @@ -115,7 +115,7 @@ Test.run([ 38 ], "clamp - infinity" - ], Core__Float.clamp(4.1, 4.3, Pervasives.infinity), eq, 4.3); + ], Core__Float.clamp(4.1, 4.3, PervasivesU.infinity), eq, 4.3); Test.run([ [ @@ -125,7 +125,7 @@ Test.run([ 39 ], "clamp - -infinity" - ], Core__Float.clamp(4.1, 4.3, Pervasives.neg_infinity), eq, 4.1); + ], Core__Float.clamp(4.1, 4.3, PervasivesU.neg_infinity), eq, 4.1); Test.run([ [ @@ -165,7 +165,7 @@ Test.run([ 42 ], "clamp - min infinity" - ], Core__Float.clamp(Pervasives.infinity, undefined, 4.2), eq, Pervasives.infinity); + ], Core__Float.clamp(PervasivesU.infinity, undefined, 4.2), eq, PervasivesU.infinity); Test.run([ [ @@ -175,7 +175,7 @@ Test.run([ 42 ], "clamp - max infinity" - ], Core__Float.clamp(undefined, Pervasives.infinity, 4.2), eq, 4.2); + ], Core__Float.clamp(undefined, PervasivesU.infinity, 4.2), eq, 4.2); Test.run([ [ @@ -185,7 +185,7 @@ Test.run([ 43 ], "clamp - min -infinity" - ], Core__Float.clamp(Pervasives.neg_infinity, undefined, 4.2), eq, 4.2); + ], Core__Float.clamp(PervasivesU.neg_infinity, undefined, 4.2), eq, 4.2); Test.run([ [ @@ -195,7 +195,7 @@ Test.run([ 43 ], "clamp - max -infinity" - ], Core__Float.clamp(undefined, Pervasives.neg_infinity, 4.2), eq, Pervasives.neg_infinity); + ], Core__Float.clamp(undefined, PervasivesU.neg_infinity, 4.2), eq, PervasivesU.neg_infinity); Test.run([ [ @@ -205,7 +205,7 @@ Test.run([ 49 ], "clamp - min infinity, max infinity" - ], Core__Float.clamp(Pervasives.infinity, Pervasives.infinity, 4.2), eq, Pervasives.infinity); + ], Core__Float.clamp(PervasivesU.infinity, PervasivesU.infinity, 4.2), eq, PervasivesU.infinity); Test.run([ [ @@ -215,7 +215,7 @@ Test.run([ 50 ], "clamp - min -infinity, max infinity" - ], Core__Float.clamp(Pervasives.neg_infinity, Pervasives.infinity, 4.2), eq, 4.2); + ], Core__Float.clamp(PervasivesU.neg_infinity, PervasivesU.infinity, 4.2), eq, 4.2); Test.run([ [ @@ -225,7 +225,7 @@ Test.run([ 50 ], "clamp - min infinity, max -infinity" - ], Core__Float.clamp(Pervasives.infinity, Pervasives.neg_infinity, 4.2), eq, Pervasives.infinity); + ], Core__Float.clamp(PervasivesU.infinity, PervasivesU.neg_infinity, 4.2), eq, PervasivesU.infinity); Test.run([ [ @@ -235,7 +235,7 @@ Test.run([ 51 ], "clamp - min -infinity, max -infinity" - ], Core__Float.clamp(Pervasives.neg_infinity, Pervasives.neg_infinity, 4.2), eq, Pervasives.neg_infinity); + ], Core__Float.clamp(PervasivesU.neg_infinity, PervasivesU.neg_infinity, 4.2), eq, PervasivesU.neg_infinity); export { eq , diff --git a/test/IntTests.mjs b/test/IntTests.mjs index 794b8ca3..45815345 100644 --- a/test/IntTests.mjs +++ b/test/IntTests.mjs @@ -1,19 +1,18 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Curry from "rescript/lib/es6/curry.js"; import * as Js_exn from "rescript/lib/es6/js_exn.js"; import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; import * as Core__Int from "../src/Core__Int.mjs"; -import * as Pervasives from "rescript/lib/es6/pervasives.js"; +import * as PervasivesU from "rescript/lib/es6/pervasivesU.js"; import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js"; var eq = Caml_obj.equal; function $$catch(f) { try { - Curry._1(f, undefined); - return Pervasives.failwith("no exception raised"); + f(); + return PervasivesU.failwith("no exception raised"); } catch (raw_err){ var err = Caml_js_exceptions.internalToOCamlException(raw_err); @@ -170,7 +169,7 @@ Test.run([ 62 ], "rangeWithOptions - positive, increasing, step 0" - ], $$catch(function (param) { + ], $$catch(function () { return Core__Int.rangeWithOptions(3, 6, { step: 0 }); @@ -347,7 +346,7 @@ Test.run([ 73 ], "rangeWithOptions - positive, increasing, step 0, inclusive" - ], $$catch(function (param) { + ], $$catch(function () { return Core__Int.rangeWithOptions(3, 6, { step: 0, inclusive: true diff --git a/test/JsonTests.mjs b/test/JsonTests.mjs new file mode 100644 index 00000000..ab1b95c9 --- /dev/null +++ b/test/JsonTests.mjs @@ -0,0 +1,47 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Test from "./Test.mjs"; + +function decodeJsonTest() { + var json = {"someProp":{"otherProp": null, "thirdProp": [true, false]}}; + var decodedCorrectly; + if (!Array.isArray(json) && (json === null || typeof json !== "object") && typeof json !== "number" && typeof json !== "string" && typeof json !== "boolean" || !(typeof json === "object" && !Array.isArray(json))) { + decodedCorrectly = false; + } else { + var match = json["someProp"]; + if (match !== undefined && !(!Array.isArray(match) && (match === null || typeof match !== "object") && typeof match !== "number" && typeof match !== "string" && typeof match !== "boolean" || !(typeof match === "object" && !Array.isArray(match)))) { + var match$1 = match["thirdProp"]; + if (match$1 !== undefined && !(!Array.isArray(match$1) && (match$1 === null || typeof match$1 !== "object") && typeof match$1 !== "number" && typeof match$1 !== "string" && typeof match$1 !== "boolean" || !(Array.isArray(match$1) && match$1.length === 2))) { + var match$2 = match$1[0]; + if (!Array.isArray(match$2) && (match$2 === null || typeof match$2 !== "object") && typeof match$2 !== "number" && typeof match$2 !== "string" && typeof match$2 !== "boolean" || !(typeof match$2 === "boolean" && match$2)) { + decodedCorrectly = false; + } else { + var match$3 = match$1[1]; + decodedCorrectly = !Array.isArray(match$3) && (match$3 === null || typeof match$3 !== "object") && typeof match$3 !== "number" && typeof match$3 !== "string" && typeof match$3 !== "boolean" || !(typeof match$3 === "boolean" && !match$3) ? false : true; + } + } else { + decodedCorrectly = false; + } + } else { + decodedCorrectly = false; + } + } + Test.run([ + [ + "JsonTests.res", + 19, + 22, + 55 + ], + "Should decode JSON successfully" + ], decodedCorrectly, (function (prim0, prim1) { + return prim0 === prim1; + }), true); +} + +decodeJsonTest(); + +export { + decodeJsonTest , +} +/* Not a pure module */ diff --git a/test/JsonTests.res b/test/JsonTests.res new file mode 100644 index 00000000..03b90720 --- /dev/null +++ b/test/JsonTests.res @@ -0,0 +1,22 @@ +open RescriptCore + +let decodeJsonTest = () => { + let json: JSON.t = %raw(`{"someProp":{"otherProp": null, "thirdProp": [true, false]}}`) + + let decodedCorrectly = switch json { + | Object(dict) => + switch dict->Dict.get("someProp") { + | Some(Object(dict)) => + switch dict->Dict.get("thirdProp") { + | Some(Array([Boolean(true), Boolean(false)])) => true + | _ => false + } + | _ => false + } + | _ => false + } + + Test.run(__POS_OF__("Should decode JSON successfully"), decodedCorrectly, \"==", true) +} + +decodeJsonTest() diff --git a/test/NullableTests.mjs b/test/NullableTests.mjs new file mode 100644 index 00000000..70100f24 --- /dev/null +++ b/test/NullableTests.mjs @@ -0,0 +1,55 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Test from "./Test.mjs"; + +function shouldHandleNullableValues() { + var tNull = null; + var tUndefined = undefined; + var tValue = "hello"; + var tmp; + tmp = (tNull === null || tNull === undefined) && tNull === null ? true : false; + Test.run([ + [ + "NullableTests.res", + 9, + 15, + 35 + ], + "Should handle null" + ], tmp, (function (prim0, prim1) { + return prim0 === prim1; + }), true); + var tmp$1; + tmp$1 = (tUndefined === null || tUndefined === undefined) && tUndefined !== null ? true : false; + Test.run([ + [ + "NullableTests.res", + 19, + 15, + 40 + ], + "Should handle undefined" + ], tmp$1, (function (prim0, prim1) { + return prim0 === prim1; + }), true); + var tmp$2; + tmp$2 = tValue === null || tValue === undefined || tValue !== "hello" ? false : true; + Test.run([ + [ + "NullableTests.res", + 29, + 15, + 36 + ], + "Should handle value" + ], tmp$2, (function (prim0, prim1) { + return prim0 === prim1; + }), true); +} + +shouldHandleNullableValues(); + +export { + shouldHandleNullableValues , +} +/* Not a pure module */ diff --git a/test/NullableTests.res b/test/NullableTests.res new file mode 100644 index 00000000..ca97174d --- /dev/null +++ b/test/NullableTests.res @@ -0,0 +1,39 @@ +open RescriptCore + +let shouldHandleNullableValues = () => { + let tNull: Nullable.t = %raw("null") + let tUndefined: Nullable.t = %raw("undefined") + let tValue: Nullable.t = %raw(`"hello"`) + + Test.run( + __POS_OF__("Should handle null"), + switch tNull { + | Null => true + | Value(_) | Undefined => false + }, + \"==", + true, + ) + + Test.run( + __POS_OF__("Should handle undefined"), + switch tUndefined { + | Undefined => true + | Value(_) | Null => false + }, + \"==", + true, + ) + + Test.run( + __POS_OF__("Should handle value"), + switch tValue { + | Value("hello") => true + | _ => false + }, + \"==", + true, + ) +} + +shouldHandleNullableValues() diff --git a/test/ObjectTests.mjs b/test/ObjectTests.mjs index fe5c70a6..2ad5a9a1 100644 --- a/test/ObjectTests.mjs +++ b/test/ObjectTests.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Curry from "rescript/lib/es6/curry.js"; import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; import * as Core__Option from "../src/Core__Option.mjs"; @@ -430,7 +429,7 @@ function assignOverwritesTarget(title, source) { 22, 39 ], - "assign " + title + "" + "assign " + title ], Object.assign({ a: 1 }, sourceObj), eq, sourceObj); @@ -441,7 +440,7 @@ function assignOverwritesTarget(title, source) { 22, 39 ], - "assign " + title + "" + "assign " + title ], Object.assign({ a: undefined }, sourceObj), eq, sourceObj); @@ -452,7 +451,7 @@ function assignOverwritesTarget(title, source) { 22, 39 ], - "assign " + title + "" + "assign " + title ], Object.assign({ a: null }, sourceObj), eq, sourceObj); @@ -474,13 +473,13 @@ function runGetTest(i) { 22, 46 ], - "Object.get: " + i.title + "" - ], Curry._1(i.get, Curry._1(i.source, undefined)), eq, i.expected); + "Object.get: " + i.title + ], i.get(i.source()), eq, i.expected); } runGetTest({ title: "prop exists, return Some", - source: (function (param) { + source: (function () { return { a: 1 }; @@ -493,7 +492,7 @@ runGetTest({ runGetTest({ title: "prop NOT exist, return None", - source: (function (param) { + source: (function () { return { a: 1 }; @@ -506,7 +505,7 @@ runGetTest({ runGetTest({ title: "prop like toString, return Some", - source: (function (param) { + source: (function () { return { a: 1 }; @@ -519,7 +518,7 @@ runGetTest({ runGetTest({ title: "prop exist but explicitly undefined, return None", - source: (function (param) { + source: (function () { return { a: undefined }; @@ -532,7 +531,7 @@ runGetTest({ runGetTest({ title: "prop exist but explicitly null, return None", - source: (function (param) { + source: (function () { return { a: null }; @@ -545,7 +544,7 @@ runGetTest({ runGetTest({ title: "prop exists and is an array, can get it", - source: (function (param) { + source: (function () { return { a: [ 1, @@ -571,7 +570,7 @@ runGetTest({ ] }); -function getSymbolTestWhenExists(param) { +function getSymbolTestWhenExists() { var obj = {}; var fruit = Symbol("fruit"); obj[fruit] = "banana"; @@ -587,7 +586,7 @@ function getSymbolTestWhenExists(param) { ], retrieved, eq, "banana"); } -getSymbolTestWhenExists(undefined); +getSymbolTestWhenExists(); Test.run([ [ diff --git a/test/PromiseTest.mjs b/test/PromiseTest.mjs index e8ab3d41..ffdb1df1 100644 --- a/test/PromiseTest.mjs +++ b/test/PromiseTest.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Curry from "rescript/lib/es6/curry.js"; import * as Js_exn from "rescript/lib/es6/js_exn.js"; import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; import * as Core__Promise from "../src/Core__Promise.mjs"; @@ -13,7 +12,7 @@ var fail = Js_exn.raiseError; var equal = Caml_obj.equal; -function resolveTest(param) { +function resolveTest() { Promise.resolve("test").then(function (str) { Test.run([ [ @@ -24,12 +23,12 @@ function resolveTest(param) { ], "Should resolve test" ], str, equal, "test"); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function runTests(param) { - resolveTest(undefined); +function runTests() { + resolveTest(); } var Creation = { @@ -37,7 +36,7 @@ var Creation = { runTests: runTests }; -function testThen(param) { +function testThen() { return Promise.resolve(1).then(function (first) { return Promise.resolve(first + 1 | 0); }).then(function (value) { @@ -50,11 +49,11 @@ function testThen(param) { ], "Should be 2" ], value, equal, 2); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testInvalidThen(param) { +function testInvalidThen() { return Promise.resolve(1).then(function (first) { return Promise.resolve(Promise.resolve(first + 1 | 0)); }).then(function (p) { @@ -68,11 +67,11 @@ function testInvalidThen(param) { ], "Should not be a promise" ], isPromise, equal, false); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testThenResolve(param) { +function testThenResolve() { return Promise.resolve(1).then(function (num) { return num + 1 | 0; }).then(function (ret) { @@ -88,7 +87,7 @@ function testThenResolve(param) { }); } -function testInvalidThenResolve(param) { +function testInvalidThenResolve() { return Promise.resolve(1).then(function (num) { return Promise.resolve(num); }).then(function (p) { @@ -102,15 +101,15 @@ function testInvalidThenResolve(param) { ], "Should not be a promise" ], isPromise, equal, false); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function runTests$1(param) { - testThen(undefined); - testInvalidThen(undefined); - testThenResolve(undefined); - testInvalidThenResolve(undefined); +function runTests$1() { + testThen(); + testInvalidThen(); + testThenResolve(); + testInvalidThenResolve(); } var ThenChaining = { @@ -121,7 +120,7 @@ var ThenChaining = { runTests: runTests$1 }; -function testExnRejection(param) { +function testExnRejection() { Core__Promise.$$catch(Promise.reject({ RE_EXN_ID: TestError, _1: "oops" @@ -138,12 +137,12 @@ function testExnRejection(param) { RE_EXN_ID: TestError, _1: "oops" }); - return Promise.resolve(undefined); + return Promise.resolve(); })); } -function runTests$2(param) { - testExnRejection(undefined); +function runTests$2() { + testExnRejection(); } var Rejection = { @@ -158,9 +157,9 @@ var asyncParseFail = (function() { }) }); -function testExternalPromiseThrow(param) { - return Core__Promise.$$catch(Curry._1(asyncParseFail, undefined).then(function (param) { - return Promise.resolve(undefined); +function testExternalPromiseThrow() { + return Core__Promise.$$catch(asyncParseFail().then(function (param) { + return Promise.resolve(); }), (function (e) { var success = e.RE_EXN_ID === Js_exn.$$Error ? Caml_obj.equal(e._1.name, "SyntaxError") : false; Test.run([ @@ -172,12 +171,12 @@ function testExternalPromiseThrow(param) { ], "Should be a parser error with Unexpected token ." ], success, equal, true); - return Promise.resolve(undefined); + return Promise.resolve(); })); } -function testExnThrow(param) { - return Core__Promise.$$catch(Promise.resolve(undefined).then(function (param) { +function testExnThrow() { + return Core__Promise.$$catch(Promise.resolve().then(function () { throw { RE_EXN_ID: TestError, _1: "Thrown exn", @@ -194,12 +193,12 @@ function testExnThrow(param) { ], "Should be a TestError" ], isTestErr, equal, true); - return Promise.resolve(undefined); + return Promise.resolve(); })); } -function testRaiseErrorThrow(param) { - return Core__Promise.$$catch(Promise.resolve(undefined).then(function (param) { +function testRaiseErrorThrow() { + return Core__Promise.$$catch(Promise.resolve().then(function () { return Js_exn.raiseError("Some JS error"); }), (function (e) { var isTestErr = e.RE_EXN_ID === Js_exn.$$Error ? Caml_obj.equal(e._1.message, "Some JS error") : false; @@ -212,12 +211,12 @@ function testRaiseErrorThrow(param) { ], "Should be some JS error" ], isTestErr, equal, true); - return Promise.resolve(undefined); + return Promise.resolve(); })); } -function thenAfterCatch(param) { - return Core__Promise.$$catch(Promise.resolve(undefined).then(function (param) { +function thenAfterCatch() { + return Core__Promise.$$catch(Promise.resolve().then(function () { return Promise.reject({ RE_EXN_ID: TestError, _1: "some rejected value" @@ -236,11 +235,11 @@ function thenAfterCatch(param) { ], "Should be success" ], msg, equal, "success"); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testCatchFinally(param) { +function testCatchFinally() { var wasCalled = { contents: false }; @@ -252,8 +251,8 @@ function testCatchFinally(param) { }).then(function (v) { return Promise.resolve(v); }), (function (param) { - return Promise.resolve(undefined); - })).finally(function (param) { + return Promise.resolve(); + })).finally(function () { wasCalled.contents = true; }).then(function (v) { Test.run([ @@ -274,17 +273,17 @@ function testCatchFinally(param) { ], "finally should have been called" ], wasCalled.contents, equal, true); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testResolveFinally(param) { +function testResolveFinally() { var wasCalled = { contents: false }; Promise.resolve(5).then(function (v) { return Promise.resolve(v + 5 | 0); - }).finally(function (param) { + }).finally(function () { wasCalled.contents = true; }).then(function (v) { Test.run([ @@ -305,17 +304,17 @@ function testResolveFinally(param) { ], "finally should have been called" ], wasCalled.contents, equal, true); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function runTests$3(param) { - testExternalPromiseThrow(undefined); - testExnThrow(undefined); - testRaiseErrorThrow(undefined); - thenAfterCatch(undefined); - testCatchFinally(undefined); - testResolveFinally(undefined); +function runTests$3() { + testExternalPromiseThrow(); + testExnThrow(); + testRaiseErrorThrow(); + thenAfterCatch(); + testCatchFinally(); + testResolveFinally(); } var Catching = { @@ -329,13 +328,13 @@ var Catching = { runTests: runTests$3 }; -function testParallel(param) { +function testParallel() { var place = { contents: 0 }; var delayedMsg = function (ms, msg) { return new Promise((function (resolve, param) { - setTimeout((function (param) { + setTimeout((function () { place.contents = place.contents + 1 | 0; resolve([ place.contents, @@ -375,14 +374,14 @@ function testParallel(param) { ], "Should have correct placing" ], arr, equal, exp); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testRace(param) { +function testRace() { var racer = function (ms, name) { return new Promise((function (resolve, param) { - setTimeout((function (param) { + setTimeout((function () { resolve(name); }), ms); })); @@ -402,17 +401,17 @@ function testRace(param) { ], "Eagle should win" ], winner, equal, "Eagle"); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testParallel2(param) { +function testParallel2() { var place = { contents: 0 }; var delayedMsg = function (ms, msg) { return new Promise((function (resolve, param) { - setTimeout((function (param) { + setTimeout((function () { place.contents = place.contents + 1 | 0; resolve([ place.contents, @@ -445,17 +444,17 @@ function testParallel2(param) { "myName" ] ]); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testParallel3(param) { +function testParallel3() { var place = { contents: 0 }; var delayedMsg = function (ms, msg) { return new Promise((function (resolve, param) { - setTimeout((function (param) { + setTimeout((function () { place.contents = place.contents + 1 | 0; resolve([ place.contents, @@ -494,17 +493,17 @@ function testParallel3(param) { "Hi" ] ]); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testParallel4(param) { +function testParallel4() { var place = { contents: 0 }; var delayedMsg = function (ms, msg) { return new Promise((function (resolve, param) { - setTimeout((function (param) { + setTimeout((function () { place.contents = place.contents + 1 | 0; resolve([ place.contents, @@ -549,17 +548,17 @@ function testParallel4(param) { "Hi" ] ]); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testParallel5(param) { +function testParallel5() { var place = { contents: 0 }; var delayedMsg = function (ms, msg) { return new Promise((function (resolve, param) { - setTimeout((function (param) { + setTimeout((function () { place.contents = place.contents + 1 | 0; resolve([ place.contents, @@ -610,17 +609,17 @@ function testParallel5(param) { "Hi" ] ]); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function testParallel6(param) { +function testParallel6() { var place = { contents: 0 }; var delayedMsg = function (ms, msg) { return new Promise((function (resolve, param) { - setTimeout((function (param) { + setTimeout((function () { place.contents = place.contents + 1 | 0; resolve([ place.contents, @@ -677,18 +676,18 @@ function testParallel6(param) { "Hi" ] ]); - return Promise.resolve(undefined); + return Promise.resolve(); }); } -function runTests$4(param) { - testParallel(undefined); - testRace(undefined); - testParallel2(undefined); - testParallel3(undefined); - testParallel4(undefined); - testParallel5(undefined); - testParallel6(undefined); +function runTests$4() { + testParallel(); + testRace(); + testParallel2(); + testParallel3(); + testParallel4(); + testParallel5(); + testParallel6(); } var Concurrently = { @@ -702,15 +701,15 @@ var Concurrently = { runTests: runTests$4 }; -resolveTest(undefined); +resolveTest(); -runTests$1(undefined); +runTests$1(); -testExnRejection(undefined); +testExnRejection(); -runTests$3(undefined); +runTests$3(); -runTests$4(undefined); +runTests$4(); export { TestError , diff --git a/test/PromiseTest.res b/test/PromiseTest.res index 17cc561c..35197fea 100644 --- a/test/PromiseTest.res +++ b/test/PromiseTest.res @@ -268,7 +268,7 @@ module Concurrently = { Promise.make((resolve, _) => { setTimeout(() => { place := place.contents + 1 - resolve(. (place.contents, msg)) + resolve((place.contents, msg)) }, ms)->ignore }) } @@ -290,7 +290,7 @@ module Concurrently = { let racer = (ms, name) => { Promise.make((resolve, _) => { setTimeout(() => { - resolve(. name) + resolve(name) }, ms)->ignore }) } @@ -312,7 +312,7 @@ module Concurrently = { Promise.make((resolve, _) => { setTimeout(() => { place := place.contents + 1 - resolve(. (place.contents, msg)) + resolve((place.contents, msg)) }, ms)->ignore }) } @@ -336,7 +336,7 @@ module Concurrently = { Promise.make((resolve, _) => { setTimeout(() => { place := place.contents + 1 - resolve(. (place.contents, msg)) + resolve((place.contents, msg)) }, ms)->ignore }) } @@ -361,7 +361,7 @@ module Concurrently = { Promise.make((resolve, _) => { setTimeout(() => { place := place.contents + 1 - resolve(. (place.contents, msg)) + resolve((place.contents, msg)) }, ms)->ignore }) } @@ -387,7 +387,7 @@ module Concurrently = { Promise.make((resolve, _) => { setTimeout(() => { place := place.contents + 1 - resolve(. (place.contents, msg)) + resolve((place.contents, msg)) }, ms)->ignore }) } @@ -414,7 +414,7 @@ module Concurrently = { Promise.make((resolve, _) => { setTimeout(() => { place := place.contents + 1 - resolve(. (place.contents, msg)) + resolve((place.contents, msg)) }, ms)->ignore }) } diff --git a/test/ResultTests.mjs b/test/ResultTests.mjs index d7f8245a..a191b784 100644 --- a/test/ResultTests.mjs +++ b/test/ResultTests.mjs @@ -6,12 +6,12 @@ import * as Core__Result from "../src/Core__Result.mjs"; var eq = Caml_obj.equal; -function forEachIfOkCallFunction(param) { +function forEachIfOkCallFunction() { var called = { contents: [] }; Core__Result.forEach({ - TAG: /* Ok */0, + TAG: "Ok", _0: 3 }, (function (i) { called.contents.push(i); @@ -27,14 +27,14 @@ function forEachIfOkCallFunction(param) { ], called.contents, eq, [3]); } -forEachIfOkCallFunction(undefined); +forEachIfOkCallFunction(); -function forEachIfErrorDoNotCallFunction(param) { +function forEachIfErrorDoNotCallFunction() { var called = { contents: [] }; Core__Result.forEach({ - TAG: /* Error */1, + TAG: "Error", _0: 3 }, (function (i) { called.contents.push(i); @@ -50,7 +50,7 @@ function forEachIfErrorDoNotCallFunction(param) { ], called.contents, eq, []); } -forEachIfErrorDoNotCallFunction(undefined); +forEachIfErrorDoNotCallFunction(); Test.run([ [ @@ -61,12 +61,12 @@ Test.run([ ], "mapError: if ok, return it" ], Core__Result.mapError({ - TAG: /* Ok */0, + TAG: "Ok", _0: 5 }, (function (i) { return Math.imul(i, 3); })), eq, { - TAG: /* Ok */0, + TAG: "Ok", _0: 5 }); @@ -79,12 +79,12 @@ Test.run([ ], "mapError: if error, apply f" ], Core__Result.mapError({ - TAG: /* Error */1, + TAG: "Error", _0: 5 }, (function (i) { return Math.imul(i, 3); })), eq, { - TAG: /* Error */1, + TAG: "Error", _0: 15 }); diff --git a/test/TempTests.mjs b/test/TempTests.mjs index 9807a51a..753da260 100644 --- a/test/TempTests.mjs +++ b/test/TempTests.mjs @@ -62,13 +62,13 @@ console.info("Error"); console.info("---"); -function f(param) { +function f() { var error = new Error("hello"); var typeError = new TypeError("error"); - var g = function (param) { + var g = function () { throw error; }; - var h = function (param) { + var h = function () { throw typeError; }; return [ @@ -121,11 +121,11 @@ var json$1 = Core__JSON.Classify.classify(json); var tmp; -if (typeof json$1 === "number" || json$1.TAG !== /* Object */3) { +if (typeof json$1 !== "object" || json$1.TAG !== "Object") { tmp = undefined; } else { var value = Core__JSON.Classify.classify(json$1._0["foo"]); - tmp = typeof value === "number" || value.TAG !== /* String */1 ? undefined : value._0; + tmp = typeof value !== "object" || value.TAG !== "String" ? undefined : value._0; } console.log(tmp); @@ -201,7 +201,7 @@ console.info("Promise"); console.info("---"); var promise = new Promise((function (resolve, _reject) { - setTimeout((function (param) { + setTimeout((function () { resolve(1); }), 100); })); @@ -212,8 +212,8 @@ promise.then(function (x) { return Promise.resolve(x + 2 | 0); }).then(function (x) { console.log(x); - return Promise.resolve(undefined); - }).finally(function (param) { + return Promise.resolve(); + }).finally(function () { console.log("Promise finally"); }); @@ -295,7 +295,7 @@ console.info("---"); console.log("number"); -var timeout = setTimeout((function (param) { +var timeout = setTimeout((function () { console.log("Hello!"); }), 100); diff --git a/test/TempTests.res b/test/TempTests.res index f7bf9d3b..56bdcc40 100644 --- a/test/TempTests.res +++ b/test/TempTests.res @@ -111,7 +111,7 @@ Console.info("Promise") Console.info("---") let promise: promise = Promise.make((resolve, _reject) => { let _ = setTimeout(() => { - resolve(. 1) + resolve(1) }, 100) }) @@ -171,7 +171,7 @@ Console.info("Symbol") Console.info("---") let x = Symbol.getFor("Foo") Console.log(x) -let array: array = String.getSymbolUnsafe("foo", Symbol.iterator)(.)->Iterator.toArray +let array: array = String.getSymbolUnsafe("foo", Symbol.iterator)()->Iterator.toArray Console.log(array) Console.info("") diff --git a/test/Test.mjs b/test/Test.mjs index dac61739..1fe28b2a 100644 --- a/test/Test.mjs +++ b/test/Test.mjs @@ -3,7 +3,6 @@ import * as Fs from "fs"; import * as Path from "path"; import * as Util from "util"; -import * as Curry from "rescript/lib/es6/curry.js"; import * as Core__Option from "../src/Core__Option.mjs"; import * as CodeFrame from "@babel/code-frame"; @@ -21,7 +20,7 @@ function print(value) { } function run(loc, left, comparator, right) { - if (Curry._2(comparator, left, right)) { + if (comparator(left, right)) { return ; } var match = loc[0]; diff --git a/test/TestSuite.mjs b/test/TestSuite.mjs index f8005b37..9c620d48 100644 --- a/test/TestSuite.mjs +++ b/test/TestSuite.mjs @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as IntTests from "./IntTests.mjs"; +import * as JsonTests from "./JsonTests.mjs"; import * as TestTests from "./TestTests.mjs"; import * as ArrayTests from "./ArrayTests.mjs"; import * as ErrorTests from "./ErrorTests.mjs"; @@ -8,6 +9,7 @@ import * as FloatTests from "./FloatTests.mjs"; import * as ObjectTests from "./ObjectTests.mjs"; import * as PromiseTest from "./PromiseTest.mjs"; import * as ResultTests from "./ResultTests.mjs"; +import * as NullableTests from "./NullableTests.mjs"; import * as TypedArrayTests from "./TypedArrayTests.mjs"; var bign = TestTests.bign; @@ -66,6 +68,10 @@ var o = TypedArrayTests.o; var eq = FloatTests.eq; +var decodeJsonTest = JsonTests.decodeJsonTest; + +var shouldHandleNullableValues = NullableTests.shouldHandleNullableValues; + export { bign , TestError , @@ -95,5 +101,7 @@ export { areSame , o , eq , + decodeJsonTest , + shouldHandleNullableValues , } /* IntTests Not a pure module */ diff --git a/test/TestSuite.res b/test/TestSuite.res index 62e51b02..90b89666 100644 --- a/test/TestSuite.res +++ b/test/TestSuite.res @@ -7,3 +7,5 @@ include ObjectTests include ResultTests include TypedArrayTests include FloatTests +include JsonTests +include NullableTests diff --git a/test/TestTests.mjs b/test/TestTests.mjs index 20de5b92..f33f478c 100644 --- a/test/TestTests.mjs +++ b/test/TestTests.mjs @@ -2,7 +2,7 @@ import * as Test from "./Test.mjs"; import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; -import * as Pervasives from "rescript/lib/es6/pervasives.js"; +import * as PervasivesU from "rescript/lib/es6/pervasivesU.js"; var eq = Caml_obj.equal; @@ -48,7 +48,7 @@ Test.run([ 36 ], "print infinity" - ], Test.print(Pervasives.infinity), eq, "Infinity"); + ], Test.print(PervasivesU.infinity), eq, "Infinity"); Test.run([ [ @@ -144,9 +144,9 @@ Test.run([ 29 ], "print function" - ], Test.print(function (param) { + ], Test.print(function () { return 42; - }), eq, "function (param) {\n return 42;\n }"); + }), eq, "function () {\n return 42;\n }"); Test.run([ [ diff --git a/test/TestTests.res b/test/TestTests.res index 754de992..97a35c95 100644 --- a/test/TestTests.res +++ b/test/TestTests.res @@ -21,7 +21,7 @@ Test.run( __POS_OF__("print function"), Test.print(() => 42), eq, - "function (param) {\n return 42;\n }", + "function () {\n return 42;\n }", ) Test.run(__POS_OF__("print es6 function"), Test.print(%raw("() => 42")), eq, "() => 42") Test.run( diff --git a/test/TypedArrayTests.mjs b/test/TypedArrayTests.mjs index d9e8b8fc..78fac269 100644 --- a/test/TypedArrayTests.mjs +++ b/test/TypedArrayTests.mjs @@ -1,7 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Test from "./Test.mjs"; -import * as Curry from "rescript/lib/es6/curry.js"; import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; import * as Core__Option from "../src/Core__Option.mjs"; @@ -25,7 +24,7 @@ var num3 = BigInt("555555555"); function assertTrue(message, predicate) { try { - if (Curry._1(predicate, undefined)) { + if (predicate()) { return ; } throw new Error(message); @@ -38,7 +37,7 @@ function assertTrue(message, predicate) { function assertWillThrow(message, f) { var didThrow = false; try { - Curry._1(f, undefined); + f(); } catch (exn){ didThrow = true; @@ -53,38 +52,38 @@ function areSame(x, y) { return x.toString() === y.toString(); } -assertTrue("fromArray", (function (param) { +assertTrue("fromArray", (function () { return areSame(Core__Option.getExn(new BigInt64Array([ num1, num2 ])[1]), num2); })); -assertTrue("fromBuffer", (function (param) { +assertTrue("fromBuffer", (function () { var x = new BigInt64Array(new ArrayBuffer(16)); x[1] = num2; return areSame(Core__Option.getExn(x[1]), num2); })); -assertWillThrow("fromBuffer when too short can throw when used", (function (param) { +assertWillThrow("fromBuffer when too short can throw when used", (function () { var x = new BigInt64Array(new ArrayBuffer(1)); x[0] = num1; areSame(Core__Option.getExn(x[0]), num1); })); -assertTrue("fromBufferWithRange", (function (param) { +assertTrue("fromBufferWithRange", (function () { var x = new BigInt64Array(new ArrayBuffer(16), 0, 1); x[0] = num1; return areSame(Core__Option.getExn(x[0]), num1); })); -assertWillThrow("fromBufferWithRange is unsafe, out of range", (function (param) { +assertWillThrow("fromBufferWithRange is unsafe, out of range", (function () { var x = new BigInt64Array(new ArrayBuffer(16), 13, 1); x[0] = num1; areSame(Core__Option.getExn(x[0]), num1); })); -assertTrue("fromLength is NOT in bytes", (function (param) { +assertTrue("fromLength is NOT in bytes", (function () { var x = new BigInt64Array(1); return x.byteLength === 8; }));