You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: markdown-pages/blogposts/2024-01-11-release-11-0-0.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ This release is also introducing uncurried mode, which is a new default mode tha
52
52
53
53
[ReScript Core](https://github.com/rescript-lang/rescript-core) is ReScript's new standard library. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is recommended to use with uncurried mode.
54
54
55
-
The latest docs on [rescript-lang.org](/) already use it for the examples. Have a look at the new [RescriptCore API docs](/docs/manual/api/core).
55
+
The latest docs on [rescript-lang.org](/) already use it for the examples. Have a look at the new [RescriptCore API docs](/docs/manual/api/stdlib).
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/bind-to-global-js-values.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ order: 8
8
8
9
9
# Bind to Global JS Values
10
10
11
-
**First**, make sure the value you'd like to model doesn't already exist in our [provided API](api/core).
11
+
**First**, make sure the value you'd like to model doesn't already exist in our [provided API](api/stdlib).
12
12
13
13
Some JS values, like `setTimeout`, live in the global scope. You can bind to them like so:
14
14
@@ -25,7 +25,7 @@ Some JS values, like `setTimeout`, live in the global scope. You can bind to the
25
25
26
26
</CodeTab>
27
27
28
-
(We already provide `setTimeout`, `clearTimeout` and others in the [Core API](api/core) module).
28
+
(We already provide `setTimeout`, `clearTimeout` and others in the [Core API](api/stdlib) module).
29
29
30
30
This binds to the JavaScript [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrworkerGlobalScope/setTimeout) methods and the corresponding `clearTimeout`. The `external`'s type annotation specifies that `setTimeout`:
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/bind-to-js-object.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,7 +164,7 @@ If your JavaScript object:
164
164
- might or might not add/remove keys
165
165
- contains only values that are of the same type
166
166
167
-
Then it's not really an object, it's a hash map. Use [Dict](api/core/dict), which contains operations like `get`, `set`, etc. and cleanly compiles to a JavaScript object still.
167
+
Then it's not really an object, it's a hash map. Use [Dict](api/stdlib/dict), which contains operations like `get`, `set`, etc. and cleanly compiles to a JavaScript object still.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/exception.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ order: 19
8
8
9
9
# Exception
10
10
11
-
Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!). Consider using the [`option`](null-undefined-option) or [`result`](api/core/result) type for recoverable errors.
11
+
Exceptions are just a special kind of variant, thrown in **exceptional** cases (don't abuse them!). Consider using the [`option`](null-undefined-option) or [`result`](api/stdlib/result) type for recoverable errors.
12
12
13
13
You can create your own exceptions like you'd make a variant (exceptions need to be capitalized too).
14
14
@@ -381,8 +381,8 @@ try {
381
381
}
382
382
```
383
383
384
-
The payload `exn` here is of type `unknown` since in JS you can throw anything. To operate on `exn`, do like the code above by using the standard library's [`JsExn`](api/core/jsexn) module's helpers
385
-
or use [`Type.Classify.classify`](api/core/type/classify#value-classify) to get more information about the runtime type of `exn`.
384
+
The payload `exn` here is of type `unknown` since in JS you can throw anything. To operate on `exn`, do like the code above by using the standard library's [`JsExn`](api/stdlib/jsexn) module's helpers
385
+
or use [`Type.Classify.classify`](api/stdlib/type/classify#value-classify) to get more information about the runtime type of `exn`.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/json.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ Where `data` can be any type you assume the JSON is. As you can see, this compil
37
37
38
38
## Stringify
39
39
40
-
Use [`JSON.stringify`](api/core/json#value-stringify) if your data is of type `JSON.t` or [`JSON.stringifyAny`](api/core/json#value-stringifyAny) if it is not.
40
+
Use [`JSON.stringify`](api/stdlib/json#value-stringify) if your data is of type `JSON.t` or [`JSON.stringifyAny`](api/stdlib/json#value-stringifyAny) if it is not.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/migrate-to-v11.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,11 +68,11 @@ One major change to be aware of is that array access now returns an `option`.
68
68
let firstItem = myArray[0] // Some("hello")
69
69
```
70
70
71
-
If you would like to not use an `option`, you can use [`Array.getUnsafe`](api/core/array#value-getUnsafe).
71
+
If you would like to not use an `option`, you can use [`Array.getUnsafe`](api/stdlib/array#value-getUnsafe).
72
72
73
73
For a detailed explanation on migration to ReScript Core, please refer to its [migration guide](https://github.com/rescript-association/rescript-core#migration). A semi-automated script is available as well.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/null-undefined-option.mdx
+1-40Lines changed: 1 addition & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,50 +126,11 @@ compiles to `undefined`! If you've got e.g. a string in JavaScript that you know
126
126
127
127
### Caveat 1
128
128
129
-
The option-to-undefined translation isn't perfect, because on our side, `option` values can be composed:
130
-
131
-
<CodeTablabels={["ReScript", "JS Output"]}>
132
-
133
-
```res example
134
-
let x = Some(Some(Some(5)))
135
-
```
136
-
137
-
```js
138
-
var x =5;
139
-
```
140
-
141
-
</CodeTab>
142
-
143
-
This still compiles to `5`, but this gets troublesome:
144
-
145
-
<CodeTablabels={["ReScript", "JS Output"]}>
146
-
147
-
```res example
148
-
let x = Some(None)
149
-
```
150
-
151
-
```js
152
-
var Caml_option =require("./stdlib/caml_option.js");
153
-
154
-
var x =Caml_option.some(undefined);
155
-
```
156
-
157
-
(See output tab).
158
-
159
-
</CodeTab>
160
-
161
-
What's this `Caml_option.some` thing? Why can't this compile to `undefined`? Long story short, when dealing with a polymorphic `option` type (aka `option<'a>`, for any `'a`), many operations become tricky if we don't mark the value with some special annotation. If this doesn't make sense, don't worry; just remember the following rule:
162
-
163
-
-**Never, EVER, pass a nested `option` value (e.g. `Some(Some(Some(5)))`) into the JS side.**
164
-
-**Never, EVER, annotate a value coming from JS as `option<'a>`. Always give the concrete, non-polymorphic type.**
165
-
166
-
### Caveat 2
167
-
168
129
Unfortunately, lots of times, your JavaScript value might be _both_`null` or `undefined`. In that case, you unfortunately can't type such value as e.g. `option<int>`, since our `option` type only checks for `undefined` and not `null` when dealing with a `None`.
169
130
170
131
#### Solution: More Sophisticated `undefined` & `null` Interop
171
132
172
-
To solve this, we provide access to more elaborate `null` and `undefined` helpers through the [`Nullable`](api/core/nullable) module. This somewhat works like an `option` type, but is different from it.
133
+
To solve this, we provide access to more elaborate `null` and `undefined` helpers through the [`Nullable`](api/stdlib/nullable) module. This somewhat works like an `option` type, but is different from it.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/primitive-types.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ This is just like JavaScript's backtick string interpolation, except without nee
77
77
78
78
### Usage
79
79
80
-
See the familiar `String` API in the [API docs](api/core/string). Since a ReScript string maps to a JavaScript string, you can mix & match the string operations in all standard libraries.
80
+
See the familiar `String` API in the [API docs](api/stdlib/string). Since a ReScript string maps to a JavaScript string, you can mix & match the string operations in all standard libraries.
81
81
82
82
### Tips & Tricks
83
83
@@ -127,7 +127,7 @@ let r = /b/g;
127
127
128
128
</CodeTab>
129
129
130
-
A regular expression like the above has the type `RegExp.t`. The [RegExp](api/core/regexp) module contains the regular expression helpers you have seen in JS.
130
+
A regular expression like the above has the type `RegExp.t`. The [RegExp](api/stdlib/regexp) module contains the regular expression helpers you have seen in JS.
131
131
132
132
## Boolean
133
133
@@ -146,15 +146,15 @@ ReScript's `true/false` compiles into a JavaScript `true/false`.
146
146
147
147
## Integers
148
148
149
-
32-bits, truncated when necessary. We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [Int](api/core/int) for helper functions.
149
+
32-bits, truncated when necessary. We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [Int](api/stdlib/int) for helper functions.
150
150
151
151
**Be careful when you bind to JavaScript numbers!** Since ReScript integers have a much smaller range than JavaScript numbers, data might get lost when dealing with large numbers. In those cases it’s much safer to bind the numbers as **float**. Be extra mindful of this when binding to JavaScript Dates and their epoch time.
152
152
153
153
To improve readability, you may place underscores in the middle of numeric literals such as `1_000_000`. Note that underscores can be placed anywhere within a number, not just every three digits.
154
154
155
155
## Floats
156
156
157
-
Float requires other operators: `+.`, `-.`, `*.`, `/.`, etc. Like `0.5 +. 0.6`. See [Float](api/core/float) for helper functions.
157
+
Float requires other operators: `+.`, `-.`, `*.`, `/.`, etc. Like `0.5 +. 0.6`. See [Float](api/stdlib/float) for helper functions.
158
158
159
159
As with integers, you may use underscores within literals to improve readability.
160
160
@@ -179,7 +179,7 @@ var result = 1 + 2;
179
179
**Since 11.1**
180
180
181
181
For values which are too large to be represented by Int or Float, there is the `bigint` primitive type.
182
-
We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [BigInt](api/core/bigint) for helper functions.
182
+
We provide the usual operations on them: `+`, `-`, `*`, `/`, etc. See [BigInt](api/stdlib/bigint) for helper functions.
183
183
184
184
A `bigint` number is denoted by a trailing `n` like so: `42n`.
0 commit comments