Skip to content

Commit cb82eb4

Browse files
cknittfhammerschmidt
authored andcommitted
More deprecations in Pervasives; add Stdlib.Pair and Stdlib.Int.Ref (#7371)
* More deprecations in Pervasives * Add Stdlib.Pair * Add Int.Ref.increment/decrement * CHANGELOG * Get rid of Pervasives_mini * Fix CHANGELOG category * Add Pair.equal, Pair.compare
1 parent 3e07d26 commit cb82eb4

15 files changed

+222
-112
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
- Remove `Stdlib_Char` module for now. https://github.com/rescript-lang/rescript/pull/7367
2323
- Convert internal JavaScript codebase into ESM, ReScript package itself is now ESM (`"type": "module"`). https://github.com/rescript-lang/rescript/pull/6899
2424

25+
#### :nail_care: Polish
26+
27+
- More deprecations in `Pervasives`; add `Stdlib.Pair` and `Stdlib.Int.Ref`. https://github.com/rescript-lang/rescript/pull/7371
28+
2529
# 12.0.0-alpha.10
2630

2731
#### :rocket: New Feature

lib/es6/Stdlib.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function assertEqual(a, b) {
1212
RE_EXN_ID: "Assert_failure",
1313
_1: [
1414
"Stdlib.res",
15-
118,
15+
119,
1616
4
1717
],
1818
Error: new Error()
@@ -63,6 +63,8 @@ let Option;
6363

6464
let Ordering;
6565

66+
let Pair;
67+
6668
let $$Promise;
6769

6870
let $$RegExp;
@@ -138,6 +140,7 @@ export {
138140
$$Object,
139141
Option,
140142
Ordering,
143+
Pair,
141144
$$Promise,
142145
$$RegExp,
143146
Result,

lib/es6/Stdlib_Int.js

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ function bitwiseNot(x) {
6666
return x ^ -1;
6767
}
6868

69+
let Ref = {};
70+
6971
let Constants = {
7072
minValue: -2147483648,
7173
maxValue: 2147483647
@@ -78,5 +80,6 @@ export {
7880
rangeWithOptions,
7981
clamp,
8082
bitwiseNot,
83+
Ref,
8184
}
8285
/* No side effect */

lib/es6/Stdlib_Pair.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
4+
function equal(param, param$1, eq1, eq2) {
5+
if (eq1(param[0], param$1[0])) {
6+
return eq2(param[1], param$1[1]);
7+
} else {
8+
return false;
9+
}
10+
}
11+
12+
function compare(param, param$1, cmp1, cmp2) {
13+
let result = cmp1(param[0], param$1[0]);
14+
if (result !== 0) {
15+
return result;
16+
} else {
17+
return cmp2(param[1], param$1[1]);
18+
}
19+
}
20+
21+
export {
22+
equal,
23+
compare,
24+
}
25+
/* No side effect */

lib/js/Stdlib.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function assertEqual(a, b) {
1212
RE_EXN_ID: "Assert_failure",
1313
_1: [
1414
"Stdlib.res",
15-
118,
15+
119,
1616
4
1717
],
1818
Error: new Error()
@@ -63,6 +63,8 @@ let Option;
6363

6464
let Ordering;
6565

66+
let Pair;
67+
6668
let $$Promise;
6769

6870
let $$RegExp;
@@ -137,6 +139,7 @@ exports.Nullable = Nullable;
137139
exports.$$Object = $$Object;
138140
exports.Option = Option;
139141
exports.Ordering = Ordering;
142+
exports.Pair = Pair;
140143
exports.$$Promise = $$Promise;
141144
exports.$$RegExp = $$RegExp;
142145
exports.Result = Result;

lib/js/Stdlib_Int.js

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ function bitwiseNot(x) {
6666
return x ^ -1;
6767
}
6868

69+
let Ref = {};
70+
6971
let Constants = {
7072
minValue: -2147483648,
7173
maxValue: 2147483647
@@ -77,4 +79,5 @@ exports.range = range;
7779
exports.rangeWithOptions = rangeWithOptions;
7880
exports.clamp = clamp;
7981
exports.bitwiseNot = bitwiseNot;
82+
exports.Ref = Ref;
8083
/* No side effect */

lib/js/Stdlib_Pair.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
4+
function equal(param, param$1, eq1, eq2) {
5+
if (eq1(param[0], param$1[0])) {
6+
return eq2(param[1], param$1[1]);
7+
} else {
8+
return false;
9+
}
10+
}
11+
12+
function compare(param, param$1, cmp1, cmp2) {
13+
let result = cmp1(param[0], param$1[0]);
14+
if (result !== 0) {
15+
return result;
16+
} else {
17+
return cmp2(param[1], param$1[1]);
18+
}
19+
}
20+
21+
exports.equal = equal;
22+
exports.compare = compare;
23+
/* No side effect */

packages/artifacts.txt

+6
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ lib/es6/Stdlib_Nullable.js
186186
lib/es6/Stdlib_Object.js
187187
lib/es6/Stdlib_Option.js
188188
lib/es6/Stdlib_Ordering.js
189+
lib/es6/Stdlib_Pair.js
189190
lib/es6/Stdlib_Promise.js
190191
lib/es6/Stdlib_RegExp.js
191192
lib/es6/Stdlib_Result.js
@@ -358,6 +359,7 @@ lib/js/Stdlib_Nullable.js
358359
lib/js/Stdlib_Object.js
359360
lib/js/Stdlib_Option.js
360361
lib/js/Stdlib_Ordering.js
362+
lib/js/Stdlib_Pair.js
361363
lib/js/Stdlib_Promise.js
362364
lib/js/Stdlib_RegExp.js
363365
lib/js/Stdlib_Result.js
@@ -1151,6 +1153,10 @@ lib/ocaml/Stdlib_Ordering.cmi
11511153
lib/ocaml/Stdlib_Ordering.cmj
11521154
lib/ocaml/Stdlib_Ordering.cmt
11531155
lib/ocaml/Stdlib_Ordering.res
1156+
lib/ocaml/Stdlib_Pair.cmi
1157+
lib/ocaml/Stdlib_Pair.cmj
1158+
lib/ocaml/Stdlib_Pair.cmt
1159+
lib/ocaml/Stdlib_Pair.res
11541160
lib/ocaml/Stdlib_Promise.cmi
11551161
lib/ocaml/Stdlib_Promise.cmj
11561162
lib/ocaml/Stdlib_Promise.cmt

runtime/Pervasives.res

+43-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
@deprecated("Do not use. This will be removed in v13")
2-
external /* Internal */
3-
4-
__unsafe_cast: 'a => 'b = "%identity"
2+
external __unsafe_cast: 'a => 'b = "%identity"
53

64
/* Exceptions */
7-
@deprecated(
8-
"`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw` instead"
9-
)
10-
external raise: exn => 'a = "%raise"
11-
12-
@deprecated("Use custom exception instead")
13-
let failwith = s => throw(Failure(s))
14-
15-
@deprecated("Use custom exception instead")
16-
let invalid_arg = s => throw(Invalid_argument(s))
17-
18-
@deprecated("Use custom exception instead") exception Exit
195

206
/**
217
Raises the given exception, terminating execution unless caught by a surrounding try/catch block.
@@ -36,9 +22,25 @@ assertEqual(result, "Caught exception: Out of milk")
3622
*/
3723
external throw: exn => 'a = "%raise"
3824

25+
@deprecated(
26+
"`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw` instead"
27+
)
28+
external raise: exn => 'a = "%raise"
29+
30+
@deprecated("Use custom exception instead")
31+
let failwith = s => throw(Failure(s))
32+
33+
@deprecated("Use custom exception instead")
34+
let invalid_arg = s => throw(Invalid_argument(s))
35+
36+
@deprecated("Use custom exception instead") exception Exit
37+
3938
/* Composition operators */
4039

40+
@deprecated("This will be removed in v13")
4141
external \"|>": ('a, 'a => 'b) => 'b = "%revapply"
42+
43+
@deprecated("This will be removed in v13")
4244
external \"@@": ('a => 'b, 'a) => 'b = "%apply"
4345

4446
/* Debugging */
@@ -92,7 +94,10 @@ external \"||": (bool, bool) => bool = "%sequor"
9294

9395
/* Integer operations */
9496

97+
@deprecated("Use `x => x + 1` instead. This will be removed in v13")
9598
external succ: int => int = "%succint"
99+
100+
@deprecated("Use `x => x - 1` instead. This will be removed in v13")
96101
external pred: int => int = "%predint"
97102

98103
@deprecated("Use `Math.abs` instead. This will be removed in v13")
@@ -103,14 +108,25 @@ let abs = x =>
103108
-x
104109
}
105110

111+
@deprecated("Use `Int.bitwiseAnd` instead. This will be removed in v13")
106112
external land: (int, int) => int = "%andint"
113+
114+
@deprecated("Use `Int.bitwiseOr` instead. This will be removed in v13")
107115
external lor: (int, int) => int = "%orint"
116+
117+
@deprecated("Use `Int.bitwiseXor` instead. This will be removed in v13")
108118
external lxor: (int, int) => int = "%xorint"
109119

120+
@deprecated("Use `Int.bitwiseNot` instead. This will be removed in v13")
110121
let lnot = x => lxor(x, -1)
111122

123+
@deprecated("Use `Int.shiftLeft` instead. This will be removed in v13")
112124
external lsl: (int, int) => int = "%lslint"
125+
126+
@deprecated("Use `Int.shiftRightUnsigned` instead. This will be removed in v13")
113127
external lsr: (int, int) => int = "%lsrint"
128+
129+
@deprecated("Use `Int.shiftRight` instead. This will be removed in v13")
114130
external asr: (int, int) => int = "%asrint"
115131

116132
@deprecated("Use `Int.Constants.maxValue` instead. This will be removed in v13")
@@ -266,16 +282,25 @@ external ignore: 'a => unit = "%ignore"
266282

267283
/* Pair operations */
268284

285+
@deprecated("Use `Pair.first` instead. This will be removed in v13")
269286
external fst: (('a, 'b)) => 'a = "%field0"
287+
288+
@deprecated("Use `Pair.second` instead. This will be removed in v13")
270289
external snd: (('a, 'b)) => 'b = "%field1"
271290

272291
/* References */
273292

274293
type ref<'a> = {mutable contents: 'a}
275294
external ref: 'a => ref<'a> = "%makeref"
276-
external \"!": ref<'a> => 'a = "%refget"
277295
external \":=": (ref<'a>, 'a) => unit = "%refset"
296+
297+
@deprecated("Do not use. This will be removed in v13")
298+
external \"!": ref<'a> => 'a = "%refget"
299+
300+
@deprecated("Use `Int.Ref.increment` instead. This will be removed in v13")
278301
external incr: ref<int> => unit = "%incr"
302+
303+
@deprecated("Use `Int.Ref.decrement` instead. This will be removed in v13")
279304
external decr: ref<int> => unit = "%decr"
280305

281306
/* String conversion functions */
@@ -310,6 +335,7 @@ external string_of_int: int => string = "String"
310335
@deprecated("Use `Int.fromString` instead. This will be removed in v13") @scope("Number")
311336
external int_of_string: string => int = "parseInt"
312337

338+
@deprecated("Use `Int.fromString` instead. This will be removed in v13")
313339
let int_of_string_opt = s =>
314340
switch int_of_string(s) {
315341
| n if n == %raw("NaN") => None
@@ -330,4 +356,5 @@ let rec \"@" = (l1, l2) =>
330356

331357
/* Miscellaneous */
332358

359+
@deprecated("This will be removed in v13")
333360
type int32 = int

runtime/Pervasives_mini.res

-93
This file was deleted.

runtime/Stdlib.res

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module Nullable = Stdlib_Nullable
2020
module Object = Stdlib_Object
2121
module Option = Stdlib_Option
2222
module Ordering = Stdlib_Ordering
23+
module Pair = Stdlib_Pair
2324
module Promise = Stdlib_Promise
2425
module RegExp = Stdlib_RegExp
2526
module Result = Stdlib_Result

0 commit comments

Comments
 (0)