Skip to content

Commit 2534a7f

Browse files
committed
Merge upstream
2 parents 00472df + 3c11480 commit 2534a7f

29 files changed

+230
-230
lines changed

pages/docs/manual/v8.0.0/array-and-list.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ canonical: "https://rescript-lang.org/docs/manual/latest/array-and-list"
1010

1111
Arrays are our primary ordered data structure. They work the same way as JavaScript arrays.
1212

13-
<CodeTab labels={["ReScript", "JS Output"]}>
13+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
1414

1515
```re
1616
let myArray = [|"hello", "world", "how are you"|];
@@ -29,7 +29,7 @@ See the [Js.Array](/apis/latest/js/array) API.
2929

3030
Access & update an array item like so:
3131

32-
<CodeTab labels={["ReScript", "JS Output"]}>
32+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
3333

3434
```re
3535
let myArray = [|"hello", "world", "how are you"|];
@@ -57,7 +57,7 @@ ReScript provides a singly linked list too. Lists are:
5757
- fast at getting the tail
5858
- slow at everything else
5959

60-
<CodeTab labels={["ReScript", "JS Output"]}>
60+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
6161

6262
```re
6363
let myList = [1, 2, 3];
@@ -91,7 +91,7 @@ The standard lib provides a [List module](/apis/latest/belt/list).
9191

9292
Use the spread syntax:
9393

94-
<CodeTab labels={["ReScript", "JS Output"]}>
94+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
9595

9696
```re
9797
let myList = [1, 2, 3];
@@ -127,7 +127,7 @@ Updating an arbitrary item in the middle of a list is also discouraged, since it
127127

128128
`switch` (described in the [pattern matching section](pattern-matching-destructuring.md)) is usually used to access list items:
129129

130-
<CodeTab labels={["ReScript", "JS Output"]}>
130+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
131131

132132
```re
133133
let message =

pages/docs/manual/v8.0.0/bind-to-global-js-values.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ canonical: "https://rescript-lang.org/docs/manual/latest/bind-to-global-js-value
1010

1111
Some JS values, like `setTimeout`, live in the global scope. You can bind to them like so:
1212

13-
<CodeTab labels={["ReScript", "JS Output"]}>
13+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
1414

1515
```re
1616
[@bs.val] external setTimeout: (unit => unit, int) => float = "setTimeout";
@@ -36,7 +36,7 @@ This binds to the JavaScript [`setTimeout`](https://developer.mozilla.org/en-US/
3636

3737
We're in a language with a great type system now! Let's leverage a popular feature to solve this problem: abstract types.
3838

39-
<CodeTab labels={["ReScript", "JS Output"]}>
39+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
4040

4141
```re
4242
type timerId;
@@ -64,7 +64,7 @@ Since `external`s are inlined, we end up with JS output as readable as hand-writ
6464

6565
If you want to bind to a value inside a global module, e.g. `Math.random`, attach a `bs.scope` to your `bs.val` external:
6666

67-
<CodeTab labels={["ReScript", "JS Output"]}>
67+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
6868

6969
```re
7070
[@bs.scope "Math"] [@bs.val] external random: unit => float = "random";
@@ -78,7 +78,7 @@ var someNumber = Math.random();
7878

7979
you can bind to an arbitrarily deep object by passing a tuple to `bs.scope`:
8080

81-
<CodeTab labels={["ReScript", "JS Output"]}>
81+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
8282

8383
```re
8484
[@bs.val] [@bs.scope ("window", "___location", "ancestorOrigins")]
@@ -98,7 +98,7 @@ Global values like `__filename` and `__DEV__` don't always exist; you can't even
9898

9999
For these troublesome global values, ReScript provides a special approach: `%external(a_single_identifier)`.
100100

101-
<CodeTab labels={["ReScript", "JS Output"]}>
101+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
102102

103103
```re
104104
switch ([%external __DEV__]) {
@@ -122,7 +122,7 @@ That first line's `typeof` check won't trigger a JS ReferenceError.
122122

123123
Another example:
124124

125-
<CodeTab labels={["ReScript", "JS Output"]}>
125+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
126126

127127
```re
128128
switch ([%external __filename]) {

pages/docs/manual/v8.0.0/bind-to-js-function.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ canonical: "https://rescript-lang.org/docs/manual/latest/bind-to-js-function"
88

99
Binding a JS function is like binding any other value:
1010

11-
<CodeTab labels={["ReScript", "JS Output"]}>
11+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
1212

1313
```re
1414
// Import nodejs' path.dirname
@@ -40,7 +40,7 @@ draw(20, 20, true)
4040

4141
It'd be nice if on ReScript's side, we can bind & call `draw` while labeling things a bit:
4242

43-
<CodeTab labels={["ReScript", "JS Output"]}>
43+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
4444

4545
```re
4646
[@bs.module "MyGame"]
@@ -64,7 +64,7 @@ We've compiled to the same function, but now the usage is much clearer on the Re
6464

6565
Note that you can change the order of labeled arguments on the ReScript side and BuckleScript will ensure that they appear the right way in the JavaScript output:
6666

67-
<CodeTab labels={["ReScript", "JS Output"]}>
67+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
6868

6969
```re
7070
[@bs.module "MyGame"]
@@ -84,7 +84,7 @@ MyGame.draw(10, 20, undefined);
8484

8585
Functions attached to a JS objects (other than JS modules) require a special way of binding to them, using `bs.send`:
8686

87-
<CodeTab labels={["ReScript", "JS Output"]}>
87+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
8888

8989
```re
9090
type document; // abstract type for a document object
@@ -109,7 +109,7 @@ Ever used `foo().bar().baz()` chaining ("fluent api") in JS OOP? We can model th
109109

110110
You might have JS functions that take an arbitrary amount of arguments. BuckleScript supports modeling those, under the condition that the arbitrary arguments part is homogenous (aka of the same type). If so, add `bs.variadic` to your `external`.
111111

112-
<CodeTab labels={["ReScript", "JS Output"]}>
112+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
113113

114114
```re
115115
[@bs.module "path"] [@bs.variadic]
@@ -134,7 +134,7 @@ Apart from the above special-case, JS function in general are often arbitrary ov
134134

135135
If you can exhaustively enumerate the many forms an overloaded JS function can take, simply bind to each differently:
136136

137-
<CodeTab labels={["ReScript", "JS Output"]}>
137+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
138138

139139
```re
140140
[@bs.module "MyGame"] external drawCat: unit => unit = "draw";
@@ -167,7 +167,7 @@ function padLeft(value, padding) {
167167

168168
Here, `padding` is really conceptually a variant. Let's model it as such.
169169

170-
<CodeTab labels={["ReScript", "JS Output"]}>
170+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
171171

172172
```re
173173
[@bs.val]
@@ -194,7 +194,7 @@ Obviously, the JS side couldn't have an argument that's a polymorphic variant! B
194194

195195
Consider the Node `fs.readFileSync`'s second argument. It can take a string, but really only a defined set: `"ascii"`, `"utf8"`, etc. You can still bind it as a string, but we can use poly variants + `bs.string` to ensure that our usage's more correct:
196196

197-
<CodeTab labels={["ReScript", "JS Output"]}>
197+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
198198

199199
```re
200200
[@bs.module "fs"]
@@ -222,7 +222,7 @@ And now, passing something like `"myOwnUnicode"` or other variant constructor na
222222

223223
Aside from string, you can also compile an argument to an int, using `bs.int` instead of `bs.string` in a similar way:
224224

225-
<CodeTab labels={["ReScript", "JS Output"]}>
225+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
226226

227227
```re
228228
[@bs.val]
@@ -247,7 +247,7 @@ testIntType(21);
247247

248248
One last trick with polymorphic variants:
249249

250-
<CodeTab labels={["ReScript", "JS Output"]}>
250+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
251251

252252
```re
253253
type readline
@@ -285,7 +285,7 @@ function register(rl) {
285285

286286
Sometimes it's convenient to bind to a function using an `external`, while passing predetermined argument values to the JS function:
287287

288-
<CodeTab labels={["ReScript", "JS Output"]}>
288+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
289289

290290
```re
291291
[@bs.val]
@@ -341,7 +341,7 @@ ReScript tries to do #1 as much as it can. Even when it bails and uses #2's curr
341341

342342
[Uncurried function](function.md#uncurried-function) annotation also works on `external`:
343343

344-
<CodeTab labels={["ReScript", "JS Output"]}>
344+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
345345

346346
```re
347347
type timerId;
@@ -369,7 +369,7 @@ The above solution is safe, guaranteed, and performant, but sometimes visually a
369369

370370
Then try `@bs.uncurry`:
371371

372-
<CodeTab labels={["ReScript", "JS Output"]}>
372+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
373373

374374
```re
375375
[@bs.send] external map: (array('a), [@bs.uncurry] ('a => 'b)) => array('b) = "map";
@@ -395,7 +395,7 @@ x.onload = function(v) {
395395

396396
Here, `this` would point to `x` (actually, it depends on how `onload` is called, but we digress). It's not correct to declare `x.onload` of type `(. unit) -> unit`. Instead, we introduced a special attribute, `bs.this`, which allows us to type `x` as so:
397397

398-
<CodeTab labels={["ReScript", "JS Output"]}>
398+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
399399

400400
```re
401401
type x
@@ -419,7 +419,7 @@ x.onload = function (v) {
419419

420420
For JS functions that return a value that can also be `undefined` or `null`, we provide `[@bs.return ...]`. To automatically convert that value to an `option` type (recall that ReScript `option` type's `None` value only compiles to `undefined` and not `null`).
421421

422-
<CodeTab labels={["ReScript", "JS Output"]}>
422+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
423423

424424
```re
425425
type element;

pages/docs/manual/v8.0.0/bind-to-js-object.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ReScript cleanly separates the binding methods for JS object based on these 4 us
2323

2424
If your JavaScript object has fixed fields, then it's conceptually like a ReScript record. Since a ReScript record compiles to a clean JavaScript object, you can definitely type a JS object as a ReScript record!
2525

26-
<CodeTab labels={["ReScript", "JS Output"]}>
26+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
2727

2828
```re
2929
type person = {
@@ -50,7 +50,7 @@ External is documented [here](external.md). `@bs.module` is documented [here](im
5050

5151
Alternatively, you can use [ReScript object](object.md) to model a JS object too:
5252

53-
<CodeTab labels={["ReScript", "JS Output"]}>
53+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
5454

5555
```re
5656
type person = {
@@ -76,7 +76,7 @@ var johnName = MySchool.john.name;
7676

7777
Alternatively, you can use `bs.get` and `bs.set` to bind to individual fields of a JS object:
7878

79-
<CodeTab labels={["ReScript", "JS Output"]}>
79+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
8080

8181
```re
8282
type textarea;
@@ -90,7 +90,7 @@ type textarea;
9090

9191
You can also use `bs.get_index` and `bs.set_index` to access a dynamic property or an index:
9292

93-
<CodeTab labels={["ReScript", "JS Output"]}>
93+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
9494

9595
```re
9696
type t;
@@ -123,7 +123,7 @@ Then it's not really an object, it's a hash map. Use [Js.Dict](/apis/latest/js/d
123123

124124
Use `bs.new` to emulate e.g. `new Date()`:
125125

126-
<CodeTab labels={["ReScript", "JS Output"]}>
126+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
127127

128128
```re
129129
type t;
@@ -139,7 +139,7 @@ var date = new Date();
139139

140140
You can chain `bs.new` and `bs.module` if the JS module you're importing is itself a class:
141141

142-
<CodeTab labels={["ReScript", "JS Output"]}>
142+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
143143

144144
```re
145145
type t;

pages/docs/manual/v8.0.0/control-flow.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ReScript also supports our famous pattern matching, which will be covered in [it
1414

1515
Unlike its JavaScript counterpart, ReScript's `if` is an expression; they evaluate to their body's content:
1616

17-
<CodeTab labels={["ReScript", "JS Output"]}>
17+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
1818

1919
```re
2020
let message = if (isMorning) {
@@ -31,7 +31,7 @@ var message = isMorning ? "Good morning!" : "Hello!";
3131

3232
**Note:** an `if-else` expression without the final `else` branch implicitly gives `()` (aka the `unit` type). So this:
3333

34-
<CodeTab labels={["ReScript", "JS Output"]}>
34+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
3535

3636
```re
3737
if (showMenu) {
@@ -48,7 +48,7 @@ if (showMenu) {
4848

4949
is basically the same as:
5050

51-
<CodeTab labels={["ReScript", "JS Output"]}>
51+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
5252

5353
```re
5454
if (showMenu) {
@@ -77,7 +77,7 @@ It'll give a type error, saying basically that the implicit `else` branch has th
7777

7878
We also have ternary sugar, but **we encourage you to prefer if-else when possible**.
7979

80-
<CodeTab labels={["ReScript", "JS Output"]}>
80+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
8181

8282
```re
8383
let message = isMorning ? "Good morning!" : "Hello!"
@@ -94,7 +94,7 @@ var message = isMorning ? "Good morning!" : "Hello!";
9494

9595
For loops iterate from a starting value up to (and including) the ending value.
9696

97-
<CodeTab labels={["ReScript", "JS Output"]}>
97+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
9898

9999
```re
100100
for (i in startValueInclusive to endValueInclusive) {
@@ -109,7 +109,7 @@ for(var i = startValueInclusive; i <= endValueInclusive; ++i){
109109

110110
</CodeTab>
111111

112-
<CodeTab labels={["ReScript", "JS Output"]}>
112+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
113113

114114
```re
115115
// prints: 1 2 3
@@ -129,7 +129,7 @@ for(var x = 1; x <= 3; ++x){
129129

130130
You can make the `for` loop count in the opposite direction by using `downto`.
131131

132-
<CodeTab labels={["ReScript", "JS Output"]}>
132+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
133133

134134
```re
135135
for (i in startValueInclusive downto endValueInclusive) {
@@ -144,7 +144,7 @@ for(var i = startValueInclusive; i >= endValueInclusive; --i){
144144

145145
</CodeTab>
146146

147-
<CodeTab labels={["ReScript", "JS Output"]}>
147+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
148148

149149
```re
150150
// prints: 3 2 1
@@ -166,7 +166,7 @@ for(var x = 3; x >= 1; --x){
166166

167167
While loops execute its body code block while its condition is true.
168168

169-
<CodeTab labels={["ReScript", "JS Output"]}>
169+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
170170

171171
```re
172172
while (testCondition) {
@@ -185,7 +185,7 @@ while (testCondition) {
185185

186186
There's no loop-breaking `break` keyword (nor early `return` from functions, for that matter) in ReScript. However, we can break out of a while loop easily through using a [mutable binding](mutation.md).
187187

188-
<CodeTab labels={["ReScript", "JS Output"]}>
188+
<CodeTab labels={["Reason (Old Syntax)", "JS Output"]}>
189189

190190
```re
191191
let break = ref(false);

0 commit comments

Comments
 (0)