Skip to content

More deprecations in Pervasives; add Stdlib.Pair and Stdlib.Int.Ref #7371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
- Remove `Stdlib_Char` module for now. https://github.com/rescript-lang/rescript/pull/7367
- Convert internal JavaScript codebase into ESM, ReScript package itself is now ESM (`"type": "module"`). https://github.com/rescript-lang/rescript/pull/6899

#### :nail_care: Polish

- More deprecations in `Pervasives`; add `Stdlib.Pair` and `Stdlib.Int.Ref`. https://github.com/rescript-lang/rescript/pull/7371

# 12.0.0-alpha.10

#### :rocket: New Feature
Expand Down
5 changes: 4 additions & 1 deletion lib/es6/Stdlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function assertEqual(a, b) {
RE_EXN_ID: "Assert_failure",
_1: [
"Stdlib.res",
118,
119,
4
],
Error: new Error()
Expand Down Expand Up @@ -63,6 +63,8 @@ let Option;

let Ordering;

let Pair;

let $$Promise;

let $$RegExp;
Expand Down Expand Up @@ -138,6 +140,7 @@ export {
$$Object,
Option,
Ordering,
Pair,
$$Promise,
$$RegExp,
Result,
Expand Down
3 changes: 3 additions & 0 deletions lib/es6/Stdlib_Int.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function bitwiseNot(x) {
return x ^ -1;
}

let Ref = {};

let Constants = {
minValue: -2147483648,
maxValue: 2147483647
Expand All @@ -78,5 +80,6 @@ export {
rangeWithOptions,
clamp,
bitwiseNot,
Ref,
}
/* No side effect */
25 changes: 25 additions & 0 deletions lib/es6/Stdlib_Pair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@



function equal(param, param$1, eq1, eq2) {
if (eq1(param[0], param$1[0])) {
return eq2(param[1], param$1[1]);
} else {
return false;
}
}

function compare(param, param$1, cmp1, cmp2) {
let result = cmp1(param[0], param$1[0]);
if (result !== 0) {
return result;
} else {
return cmp2(param[1], param$1[1]);
}
}

export {
equal,
compare,
}
/* No side effect */
5 changes: 4 additions & 1 deletion lib/js/Stdlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function assertEqual(a, b) {
RE_EXN_ID: "Assert_failure",
_1: [
"Stdlib.res",
118,
119,
4
],
Error: new Error()
Expand Down Expand Up @@ -63,6 +63,8 @@ let Option;

let Ordering;

let Pair;

let $$Promise;

let $$RegExp;
Expand Down Expand Up @@ -137,6 +139,7 @@ exports.Nullable = Nullable;
exports.$$Object = $$Object;
exports.Option = Option;
exports.Ordering = Ordering;
exports.Pair = Pair;
exports.$$Promise = $$Promise;
exports.$$RegExp = $$RegExp;
exports.Result = Result;
Expand Down
3 changes: 3 additions & 0 deletions lib/js/Stdlib_Int.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function bitwiseNot(x) {
return x ^ -1;
}

let Ref = {};

let Constants = {
minValue: -2147483648,
maxValue: 2147483647
Expand All @@ -77,4 +79,5 @@ exports.range = range;
exports.rangeWithOptions = rangeWithOptions;
exports.clamp = clamp;
exports.bitwiseNot = bitwiseNot;
exports.Ref = Ref;
/* No side effect */
23 changes: 23 additions & 0 deletions lib/js/Stdlib_Pair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';


function equal(param, param$1, eq1, eq2) {
if (eq1(param[0], param$1[0])) {
return eq2(param[1], param$1[1]);
} else {
return false;
}
}

function compare(param, param$1, cmp1, cmp2) {
let result = cmp1(param[0], param$1[0]);
if (result !== 0) {
return result;
} else {
return cmp2(param[1], param$1[1]);
}
}

exports.equal = equal;
exports.compare = compare;
/* No side effect */
6 changes: 6 additions & 0 deletions packages/artifacts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ lib/es6/Stdlib_Nullable.js
lib/es6/Stdlib_Object.js
lib/es6/Stdlib_Option.js
lib/es6/Stdlib_Ordering.js
lib/es6/Stdlib_Pair.js
lib/es6/Stdlib_Promise.js
lib/es6/Stdlib_RegExp.js
lib/es6/Stdlib_Result.js
Expand Down Expand Up @@ -358,6 +359,7 @@ lib/js/Stdlib_Nullable.js
lib/js/Stdlib_Object.js
lib/js/Stdlib_Option.js
lib/js/Stdlib_Ordering.js
lib/js/Stdlib_Pair.js
lib/js/Stdlib_Promise.js
lib/js/Stdlib_RegExp.js
lib/js/Stdlib_Result.js
Expand Down Expand Up @@ -1151,6 +1153,10 @@ lib/ocaml/Stdlib_Ordering.cmi
lib/ocaml/Stdlib_Ordering.cmj
lib/ocaml/Stdlib_Ordering.cmt
lib/ocaml/Stdlib_Ordering.res
lib/ocaml/Stdlib_Pair.cmi
lib/ocaml/Stdlib_Pair.cmj
lib/ocaml/Stdlib_Pair.cmt
lib/ocaml/Stdlib_Pair.res
lib/ocaml/Stdlib_Promise.cmi
lib/ocaml/Stdlib_Promise.cmj
lib/ocaml/Stdlib_Promise.cmt
Expand Down
59 changes: 43 additions & 16 deletions runtime/Pervasives.res
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
@deprecated("Do not use. This will be removed in v13")
external /* Internal */

__unsafe_cast: 'a => 'b = "%identity"
external __unsafe_cast: 'a => 'b = "%identity"

/* Exceptions */
@deprecated(
"`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw` instead"
)
external raise: exn => 'a = "%raise"

@deprecated("Use custom exception instead")
let failwith = s => throw(Failure(s))

@deprecated("Use custom exception instead")
let invalid_arg = s => throw(Invalid_argument(s))

@deprecated("Use custom exception instead") exception Exit

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

@deprecated(
"`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw` instead"
)
external raise: exn => 'a = "%raise"

@deprecated("Use custom exception instead")
let failwith = s => throw(Failure(s))

@deprecated("Use custom exception instead")
let invalid_arg = s => throw(Invalid_argument(s))

@deprecated("Use custom exception instead") exception Exit

/* Composition operators */

@deprecated("This will be removed in v13")
external \"|>": ('a, 'a => 'b) => 'b = "%revapply"

@deprecated("This will be removed in v13")
external \"@@": ('a => 'b, 'a) => 'b = "%apply"

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

/* Integer operations */

@deprecated("Use `x => x + 1` instead. This will be removed in v13")
external succ: int => int = "%succint"

@deprecated("Use `x => x - 1` instead. This will be removed in v13")
external pred: int => int = "%predint"

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

@deprecated("Use `Int.bitwiseAnd` instead. This will be removed in v13")
external land: (int, int) => int = "%andint"

@deprecated("Use `Int.bitwiseOr` instead. This will be removed in v13")
external lor: (int, int) => int = "%orint"

@deprecated("Use `Int.bitwiseXor` instead. This will be removed in v13")
external lxor: (int, int) => int = "%xorint"

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

@deprecated("Use `Int.shiftLeft` instead. This will be removed in v13")
external lsl: (int, int) => int = "%lslint"

@deprecated("Use `Int.shiftRightUnsigned` instead. This will be removed in v13")
external lsr: (int, int) => int = "%lsrint"

@deprecated("Use `Int.shiftRight` instead. This will be removed in v13")
external asr: (int, int) => int = "%asrint"

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

/* Pair operations */

@deprecated("Use `Pair.first` instead. This will be removed in v13")
external fst: (('a, 'b)) => 'a = "%field0"

@deprecated("Use `Pair.second` instead. This will be removed in v13")
external snd: (('a, 'b)) => 'b = "%field1"

/* References */

type ref<'a> = {mutable contents: 'a}
external ref: 'a => ref<'a> = "%makeref"
external \"!": ref<'a> => 'a = "%refget"
external \":=": (ref<'a>, 'a) => unit = "%refset"

@deprecated("Do not use. This will be removed in v13")
external \"!": ref<'a> => 'a = "%refget"

@deprecated("Use `Int.Ref.increment` instead. This will be removed in v13")
external incr: ref<int> => unit = "%incr"

@deprecated("Use `Int.Ref.decrement` instead. This will be removed in v13")
external decr: ref<int> => unit = "%decr"

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

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

/* Miscellaneous */

@deprecated("This will be removed in v13")
type int32 = int
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cometkim Do you know why this is here at all? It was added in #7108.

93 changes: 0 additions & 93 deletions runtime/Pervasives_mini.res

This file was deleted.

1 change: 1 addition & 0 deletions runtime/Stdlib.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module Nullable = Stdlib_Nullable
module Object = Stdlib_Object
module Option = Stdlib_Option
module Ordering = Stdlib_Ordering
module Pair = Stdlib_Pair
module Promise = Stdlib_Promise
module RegExp = Stdlib_RegExp
module Result = Stdlib_Result
Expand Down
Loading