Skip to content

Commit e0a0549

Browse files
committed
[Old docs] Last few pages
1 parent 937eb37 commit e0a0549

File tree

6 files changed

+56
-57
lines changed

6 files changed

+56
-57
lines changed

layouts/ManualDocsLayout8_0_0.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Toc = DocsLayout.Toc;
2424

2525
let overviewNavs = [|
2626
NavItem.{name: "Introduction", href: "/docs/manual/v8.0.0/introduction"},
27-
{name: "Migrate from BuckleScript/Reason", href: "/docs/manual/v8.0.0/migrate-from-bucklescript-reason"},
27+
{name: "Migrate to New Syntax", href: "/docs/manual/v8.0.0/migrate-to-new-syntax"},
2828
{name: "Installation", href: "/docs/manual/v8.0.0/installation"},
2929
{name: "Try", href: "/docs/manual/v8.0.0/try"},
3030
{name: "Editor Plugins", href: "/docs/manual/v8.0.0/editor-plugins"},

pages/docs/manual/v8.0.0/let-binding.mdx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ A "let binding", in other languages, might be called a "variable declaration". `
55
<CodeTab labels={["ReScript", "JS Output"]}>
66

77
```re
8-
let greeting = "hello!"
9-
let score = 10
10-
let newScore = 10 + score
8+
let greeting = "hello!";
9+
let score = 10;
10+
let newScore = 10 + score;
1111
```
1212
```js
1313
var greeting = "hello!";
@@ -25,10 +25,10 @@ Bindings can be scoped through `{}`.
2525

2626
```re
2727
let message = {
28-
let part1 = "hello"
29-
let part2 = "world"
30-
part1 ++ " " ++ part2
31-
}
28+
let part1 = "hello";
29+
let part2 = "world";
30+
part1 ++ " " ++ part2;
31+
};
3232
// `part1` and `part2` not accessible here!
3333
```
3434
```js
@@ -46,9 +46,9 @@ ReScript's `if`, `while` and functions all use the same block scoping mecanism.
4646
<CodeTab labels={["ReScript", "JS Output"]}>
4747

4848
```re
49-
if displayGreeting {
50-
let message = "Enjoying the docs so far?"
51-
Js.log(message)
49+
if (displayGreeting) {
50+
let message = "Enjoying the docs so far?";
51+
Js.log(message);
5252
};
5353
// `message` not accessible here!
5454
```
@@ -89,9 +89,9 @@ In ReScript, this obviously works too:
8989
<CodeTab labels={["ReScript", "JS Output"]}>
9090

9191
```re
92-
let result1 = 0
93-
let result2 = calculate(result1)
94-
let result3 = calculateSomeMore(result2)
92+
let result1 = 0;
93+
let result2 = calculate(result1);
94+
let result3 = calculateSomeMore(result2);
9595
```
9696
```js
9797
var result1 = 0;
@@ -106,9 +106,9 @@ Additionally, reusing the same let binding name overshadows the previous binding
106106
<CodeTab labels={["ReScript", "JS Output"]}>
107107

108108
```re
109-
let result = 0
110-
let result = calculate(result)
111-
let result = calculateSomeMore(result)
109+
let result = 0;
110+
let result = calculate(result);
111+
let result = calculateSomeMore(result);
112112
```
113113
```js
114114
var result = calculate(0);
@@ -124,10 +124,10 @@ As a matter of fact, even this is valid code:
124124
<CodeTab labels={["ReScript", "JS Output"]}>
125125

126126
```re
127-
let result = "hello"
128-
Js.log(result) // prints "hello"
129-
let result = 1
130-
Js.log(result) // prints 1
127+
let result = "hello";
128+
Js.log(result); // prints "hello"
129+
let result = 1;
130+
Js.log(result); // prints 1
131131
```
132132
```js
133133
var result = 1;

pages/docs/manual/v8.0.0/migrate-from-bucklescript-reason.mdx

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Migrate to New Syntax
2+
3+
Starting from `v8.2.0`, BuckleScript and the JS part of Reason are now fused into the new ReScript. We've also introduced a new syntax similar to the old Reason syntax, but [tremendously improved](https://reasonml.org/blog/bucklescript-8-1-new-syntax).
4+
5+
The old ML and Reason syntax are still supported (see our support commitment [here](https://reasonml.org/blog/a-note-on-bucklescripts-future-commitments)). The gist is: this is mostly just a rebranding and shouldn't affect your existing code much.
6+
7+
## Upgrade Your Codebase
8+
9+
There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial, backward-compatible and can be done on a per-file basis:
10+
11+
- Upgrade your project to `bs-platform 8.2.0`.
12+
- `node_modules/.bin/bsc -format MyFile.re > MyFile.res`
13+
14+
**That's it**! `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file.
15+
16+
Enjoy the improved experience!

pages/docs/manual/v8.0.0/record.mdx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To create a `person` record (declared above):
3333
let me = {
3434
age: 5,
3535
name: "Big ReScript"
36-
}
36+
};
3737
```
3838
```js
3939
var me = {
@@ -51,8 +51,8 @@ The type is found by looking above the `me` value. **Note**: if the type instead
5151
<CodeTab labels={["ReScript", "JS Output"]}>
5252

5353
```re
54-
// School.res
55-
type person = {age: int, name: string}
54+
// School.re
55+
type person = {age: int, name: string};
5656
```
5757
```js
5858
// Empty output
@@ -63,11 +63,11 @@ type person = {age: int, name: string}
6363
<CodeTab labels={["ReScript", "JS Output"]}>
6464

6565
```re
66-
// Example.res
66+
// Example.re
6767

68-
let me: School.person = {age: 20, name: "Big ReScript"}
68+
let me: School.person = {age: 20, name: "Big ReScript"};
6969
/* or */
70-
let me2 = {School.age: 20, name: "Big ReScript"}
70+
let me2 = {School.age: 20, name: "Big ReScript"};
7171
```
7272
```js
7373
var me = {
@@ -91,7 +91,7 @@ Use the familiar dot notation:
9191
<CodeTab labels={["ReScript", "JS Output"]}>
9292

9393
```re
94-
let name = me.name
94+
let name = me.name;
9595
```
9696
```js
9797
var name = "Big ReScript";
@@ -106,7 +106,7 @@ New records can be created from old records with the `...` spread operator. The
106106
<CodeTab labels={["ReScript", "JS Output"]}>
107107

108108
```re
109-
let meNextYear = {...me, age: me.age + 1}
109+
let meNextYear = {...me, age: me.age + 1};
110110
```
111111
```js
112112
var meNextYear = {
@@ -129,10 +129,10 @@ Record fields can optionally be mutable. This allows you to efficiently update t
129129
type person = {
130130
name: string,
131131
mutable age: int
132-
}
132+
};
133133

134-
let baby = {name: "Baby ReScript", age: 5}
135-
baby.age = baby.age + 1 // `baby.age` is now 6. Happy birthday!
134+
let baby = {name: "Baby ReScript", age: 5};
135+
baby.age = baby.age + 1; // `baby.age` is now 6. Happy birthday!
136136
```
137137
```js
138138
var baby = {
@@ -152,10 +152,10 @@ baby.age = baby.age + 1 | 0;
152152
<CodeTab labels={["ReScript", "JS Output"]}>
153153

154154
```re
155-
type person = {age: int, name: string}
156-
type monster = {age: int, hasTentacles: bool}
155+
type person = {age: int, name: string};
156+
type monster = {age: int, hasTentacles: bool};
157157

158-
let getAge = (entity) => entity.age
158+
let getAge = (entity) => entity.age;
159159
```
160160
```js
161161
function getAge(entity) {
@@ -168,11 +168,11 @@ function getAge(entity) {
168168
Instead, `getAge` will infer that the parameter `entity` must be of type `monster`, the closest record type with the field `age`. The following code's last line fails:
169169

170170
```re
171-
let kraken = {age: 9999, hasTentacles: true}
172-
let me = {age: 5, name: "Baby ReScript"}
171+
let kraken = {age: 9999, hasTentacles: true};
172+
let me = {age: 5, name: "Baby ReScript"};
173173

174-
getAge(kraken)
175-
getAge(me) // type error!
174+
getAge(kraken);
175+
getAge(me); // type error!
176176
```
177177
178178
The type system will complain that `me` is a `person`, and that `getAge` only works on `monster`. If you need such capability, use ReScript objects, described [here](object.md).

pages/docs/manual/v8.0.0/shared-data-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ReScript's built-in values of type `string`, `float`, `array` and a few others h
55
This means that if you receive e.g. a string from the JS side, you can use it **without conversion** on the ReScript side, and vice-versa.
66

77
**Shared, bidirectionally usable types**:
8-
- String. Backtick strings like `` `hello 👋 ${personName}` `` support unicode and interpolation. Normal `"hello"` strings don't.
8+
- String. Backtick strings like `` `hello ${personName}` `` support interpolation. Normal `"hello"` strings don't.
99
- Float. ReScript floats are JS numbers, vice-versa.
1010
- Array. In addition to the [JS Array API](/apis/latest/js/array), we provide our own [Belt.Array](/apis/latest/belt/array#set) API too.
1111
- Tuple. Compiles to a JS array. You can treat a fixed-sized, heterogenous JS array as ReScript tuple too.

0 commit comments

Comments
 (0)