Skip to content

Commit 4872b09

Browse files
authored
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
1 parent f45ad14 commit 4872b09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+629
-392
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Next version
44

5+
## 1.0.0
6+
7+
- Up ReScript dependency to 11+.
8+
- `JSON`, `Null` and `Nullable` untagged variants are now properly exposed.
9+
- 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.
10+
511
## 0.7.0
612

713
- Add `Dict.getUnsafe` https://github.com/rescript-association/rescript-core/pull/167

package-lock.json

+10-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rescript/core",
3-
"version": "0.7.0",
3+
"version": "1.0.0",
44
"scripts": {
55
"clean": "rescript clean",
66
"build": "rescript",
@@ -23,10 +23,10 @@
2323
"src/**/*.mjs"
2424
],
2525
"peerDependencies": {
26-
"rescript": "^10.1.0 || ^11.0.0"
26+
"rescript": ">=11.0.0 || ^11.1.0-rc.2"
2727
},
2828
"devDependencies": {
29-
"rescript": "10.1.4",
29+
"rescript": "11.1.0-rc.2",
3030
"@babel/code-frame": "7.18.6"
3131
}
3232
}

src/Core__Array.mjs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Curry from "rescript/lib/es6/curry.js";
43
import * as Js_math from "rescript/lib/es6/js_math.js";
54
import * as Caml_option from "rescript/lib/es6/caml_option.js";
65

@@ -19,7 +18,7 @@ function fromInitializer(length, f) {
1918
}
2019
var arr = new Array(length);
2120
for(var i = 0; i < length; ++i){
22-
arr[i] = Curry._1(f, i);
21+
arr[i] = f(i);
2322
}
2423
return arr;
2524
}
@@ -33,7 +32,7 @@ function equal(a, b, eq) {
3332
if (i === len) {
3433
return true;
3534
}
36-
if (!Curry._2(eq, a[i], b[i])) {
35+
if (!eq(a[i], b[i])) {
3736
return false;
3837
}
3938
_i = i + 1 | 0;
@@ -58,7 +57,7 @@ function compare(a, b, cmp) {
5857
if (i === lenA) {
5958
return 0;
6059
}
61-
var c = Curry._2(cmp, a[i], b[i]);
60+
var c = cmp(a[i], b[i]);
6261
if (c !== 0) {
6362
return c;
6463
}
@@ -128,7 +127,9 @@ function toShuffled(xs) {
128127
}
129128

130129
function filterMap(a, f) {
131-
var f$1 = Curry.__1(f);
130+
var f$1 = function (a) {
131+
return f(a);
132+
};
132133
var l = a.length;
133134
var r = new Array(l);
134135
var j = 0;
@@ -158,7 +159,7 @@ function findMap(arr, f) {
158159
if (i === arr.length) {
159160
return ;
160161
}
161-
var r = Curry._1(f, arr[i]);
162+
var r = f(arr[i]);
162163
if (r !== undefined) {
163164
return r;
164165
}

src/Core__Array.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ let filterMapU = (a, f) => {
216216
let j = ref(0)
217217
for i in 0 to l - 1 {
218218
let v = getUnsafe(a, i)
219-
switch f(. v) {
219+
switch f(v) {
220220
| None => ()
221221
| Some(v) =>
222222
setUnsafe(r, j.contents, v)
@@ -227,7 +227,7 @@ let filterMapU = (a, f) => {
227227
r
228228
}
229229

230-
let filterMap = (a, f) => filterMapU(a, (. a) => f(a))
230+
let filterMap = (a, f) => filterMapU(a, a => f(a))
231231

232232
let keepSome = filterMap(_, x => x)
233233

src/Core__Error.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var $$TypeError = {};
1414
var $$URIError = {};
1515

1616
function panic(msg) {
17-
throw new Error("Panic! " + msg + "");
17+
throw new Error("Panic! " + msg);
1818
}
1919

2020
export {

src/Core__Int.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Pervasives from "rescript/lib/es6/pervasives.js";
43
import * as Core__Array from "./Core__Array.mjs";
4+
import * as PervasivesU from "rescript/lib/es6/pervasivesU.js";
55

66
function equal(a, b) {
77
return a === b;
@@ -50,7 +50,7 @@ function rangeWithOptions(start, end, options) {
5050
} else {
5151
var range = isInverted ? start - end | 0 : end - start | 0;
5252
var range$1 = options.inclusive === true ? range + 1 | 0 : range;
53-
length = Math.ceil(range$1 / Pervasives.abs(step)) | 0;
53+
length = Math.ceil(range$1 / PervasivesU.abs(step)) | 0;
5454
}
5555
return Core__Array.fromInitializer(length, (function (i) {
5656
return start + Math.imul(i, step) | 0;

src/Core__JSON.mjs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Caml_option from "rescript/lib/es6/caml_option.js";
43

54
function classify(value) {
65
var match = Object.prototype.toString.call(value);
76
switch (match) {
87
case "[object Array]" :
98
return {
10-
TAG: /* Array */4,
9+
TAG: "Array",
1110
_0: value
1211
};
1312
case "[object Boolean]" :
1413
return {
15-
TAG: /* Bool */0,
14+
TAG: "Bool",
1615
_0: value
1716
};
1817
case "[object Null]" :
19-
return /* Null */0;
18+
return "Null";
2019
case "[object Number]" :
2120
return {
22-
TAG: /* Number */2,
21+
TAG: "Number",
2322
_0: value
2423
};
2524
case "[object String]" :
2625
return {
27-
TAG: /* String */1,
26+
TAG: "String",
2827
_0: value
2928
};
3029
default:
3130
return {
32-
TAG: /* Object */3,
31+
TAG: "Object",
3332
_0: value
3433
};
3534
}
@@ -71,7 +70,7 @@ function $$float(json) {
7170

7271
function object(json) {
7372
if (typeof json === "object" && !Array.isArray(json) && json !== null) {
74-
return Caml_option.some(json);
73+
return json;
7574
}
7675

7776
}

src/Core__JSON.res

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
type t = Js.Json.t
1+
@unboxed
2+
type rec t = Js.Json.t =
3+
| Boolean(bool)
4+
| @as(null) Null
5+
| String(string)
6+
| Number(float)
7+
| Object(Core__Dict.t<t>)
8+
| Array(array<t>)
29

310
@raises @val external parseExn: string => t = "JSON.parse"
411
@raises @val external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse"

src/Core__JSON.resi

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ Functions for interacting with JSON.
55
/**
66
A type representing a JSON object.
77
*/
8-
type t = Js.Json.t
8+
@unboxed
9+
type rec t = Js.Json.t =
10+
| Boolean(bool)
11+
| @as(null) Null
12+
| String(string)
13+
| Number(float)
14+
| Object(Core__Dict.t<t>)
15+
| Array(array<t>)
916

1017
/**
1118
`parseExn(string)`

0 commit comments

Comments
 (0)