Skip to content

Commit 85ae126

Browse files
committed
docs: edit some docs to adjust tone
1 parent 5226348 commit 85ae126

24 files changed

+245
-281
lines changed

markdown-pages/docs/manual/array-and-list.mdx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ order: 12
1010

1111
## Array
1212

13-
Arrays are our main ordered data structure. They work the same way as JavaScript arrays: they can be randomly accessed, dynamically resized, updated, etc.
13+
Arrays are the main ordered data structure in ReScript. They can be randomly accessed, dynamically resized, and updated.
1414

1515
<CodeTab labels={["ReScript", "JS Output"]}>
1616

@@ -82,9 +82,7 @@ myArray[0] = "bye";
8282

8383
### Array spreads
8484

85-
**Since 11.1**
86-
87-
You can spread arrays of the the same type into new arrays, just like in JavaScript:
85+
You can spread arrays of the same type into new arrays:
8886

8987
<CodeTab labels={["ReScript", "JS Output"]}>
9088

@@ -96,21 +94,17 @@ let x3 = [...y]
9694
```
9795

9896
```javascript
99-
var Belt_Array = require("rescript/lib/js/belt_Array.js");
100-
10197
var y = [1, 2];
10298

103-
var x = Belt_Array.concatMany([[4, 5], y]);
99+
var x = [4, 5, ...y];
104100

105-
var x2 = Belt_Array.concatMany([[4, 5], y, [7], y]);
101+
var x2 = [4, 5, ...y, 7, ...y];
106102

107-
var x3 = Belt_Array.concatMany([y]);
103+
var x3 = [...y];
108104
```
109105

110106
</CodeTab>
111107

112-
> Note that array spreads compiles to `Belt.Array.concatMany` right now. This is likely to change to native array spreads in the future.
113-
114108
## List
115109

116110
ReScript provides a singly linked list too. Lists are:

markdown-pages/docs/manual/async-await.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ You will probably notice that this looks very similar to `async` / `await` in JS
6767
- `await` may only be called on a `promise` value
6868
- `await` calls are expressions, therefore they can be used in pattern matching (`switch`)
6969
- A function returning a `promise<'a>` is equivalent to an `async` function returning a value `'a` (important for writing signature files and bindings)
70-
- `promise` values and types returned from an `async` function don't auto-collapse into a "flat promise" like in JS (more on this later)
70+
- `promise` values and types returned from an `async` function don't auto-collapse into a flat promise. See the details below.
7171

7272
## Types and `async` functions
7373

markdown-pages/docs/manual/browser-support-polyfills.mdx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ order: 13
88

99
# Browser Support & Polyfills
1010

11-
ReScript compiles to JavaScript **ES5**, with the exception of optionally allowing to compile to ES6's module import & export.
11+
ReScript compiles to modern JavaScript (ES6+ by default). The generated output targets contemporary browsers and current versions of Node.js, so polyfills are generally not needed.
1212

13-
For [old browsers](https://caniuse.com/#search=typed%20array), you also need to polyfill TypedArray. The following standard library functions require it:
14-
15-
- `Int64.float_of_bits`
16-
- `Int64.bits_of_float`
17-
- `Int32.float_of_bits`
18-
- `Int32.bits_of_float`
19-
20-
If you don't use these functions, you're fine. Otherwise, it'll be a runtime failure.
13+
If you need to support very old browsers that lack ES6+ features, use your bundler's transpilation and polyfill capabilities (for example, Babel or SWC via Webpack, Vite, or esbuild) to downlevel the output as needed.

markdown-pages/docs/manual/build-configuration.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,17 @@ Here, the file `src/MyMainModule.res` is exposed to outside consumers, while all
8181
}
8282
```
8383

84-
## bs-dependencies, bs-dev-dependencies
84+
## dependencies, dev-dependencies
8585

8686
List of ReScript dependencies. Just like `package.json`'s dependencies, they'll be searched in `node_modules`.
8787

88-
Note that only sources marked with `"type":"dev"` will be able to resolve modules from `bs-dev-dependencies`.
88+
Note that only sources marked with `"type":"dev"` will be able to resolve modules from `dev-dependencies`.
89+
90+
> The legacy keys `bs-dependencies` and `bs-dev-dependencies` are still accepted but deprecated.
8991
9092
## external-stdlib
9193

92-
**Since 9.0**: This setting allows depending on an externally built stdlib package (instead of a locally built stdlib runtime). Useful for shipping packages that are only consumed in JS or TS without any dependencies to the ReScript development toolchain.
94+
This setting allows depending on an externally built stdlib package (instead of a locally built stdlib runtime). Useful for shipping packages that are only consumed in JS or TS without any dependencies to the ReScript development toolchain.
9395

9496
More details can be found on our [external stdlib](./build-external-stdlib.mdx) page.
9597

@@ -155,7 +157,7 @@ This configuration only applies to you, when you develop the project. When the p
155157

156158
## suffix
157159

158-
**Since 11.0**: The suffix can now be freely chosen. However, we still suggest you stick to the convention and use
160+
The suffix can be freely chosen. However, we still suggest you stick to the convention and use
159161
one of the following:
160162

161163
- `".js`
@@ -190,12 +192,14 @@ Turn off warning `44` and `102` (polymorphic comparison). Turn warning `5` (part
190192

191193
The warning numbers are shown in the build output when they're triggered. See [Warning Numbers](./warning-numbers.mdx) for the complete list.
192194

193-
## bsc-flags
195+
## compiler-flags
194196

195197
Extra flags to pass to the compiler. For advanced usages.
196198

197199
- `-open ABC` opens the module `ABC` for each file in the project. `ABC` can either be a dependency, namespaced project or local module of the current project.
198200

201+
> The legacy key `bsc-flags` is still accepted but deprecated.
202+
199203
## gentypeconfig
200204

201205
To enable genType, set `"gentypeconfig"` at top level in the project's `rescript.json`.

markdown-pages/docs/manual/build-external-stdlib.mdx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,31 @@ order: 4
99

1010
# External Stdlib
1111

12-
**Since 9.0**
13-
14-
Your ReScript project depends on the `rescript` package as a [`devDependency`](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file), which includes our compiler, build system and runtime like `Belt`. However, you had to move it to `dependency` in `package.json` if you publish your code:
12+
Your ReScript project depends on the `rescript` package as a [`devDependency`](https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file), which includes the compiler, build system, and runtime. However, you may need to move it to `dependency` in `package.json` if you publish your code:
1513

1614
- To Docker or other low-storage deployment devices.
1715
- For pure JS/TS consumers who probably won't install `rescript` in their own project.
1816

19-
In these cases, the size or mere presence of `rescript` can be troublesome, since it includes not just our necessary runtime like `Belt`, but also our compiler and build system.
17+
In these cases, the size or mere presence of `rescript` can be troublesome, since it includes not just the necessary runtime, but also the compiler and build system.
2018

21-
To solve that, we now publish our runtime as a standalone package at [`@rescript/std`](https://www.npmjs.com/package/@rescript/std), whose versions mirror `rescript`'s. Now you can keep `rescript` as a `devDependency` and have only `@rescript/std` as your runtime `dependency`.
19+
To solve that, the runtime is published as a standalone package at [`@rescript/runtime`](https://www.npmjs.com/package/@rescript/runtime), whose versions mirror `rescript`'s. You can keep `rescript` as a `devDependency` and have only `@rescript/runtime` as your runtime `dependency`.
2220

2321
**This is an advanced feature**. Please only use it in the aforementioned scenarios. If you already use a JS bundler with dead code elimination, you might not need this feature.
2422

2523
## Configuration
2624

27-
Say you want to publish a JS-only ReScript 9.0 library. Install the packages like this:
25+
Say you want to publish a JS-only ReScript library. Install the packages like this:
2826

2927
```sh
30-
npm install rescript@11.0.1 --save-dev
31-
npm install @rescript/std@11.0.1
28+
npm install rescript --save-dev
29+
npm install @rescript/runtime
3230
```
3331

3432
Then add this to `rescript.json`:
3533

3634
```json
3735
{
38-
// ...
39-
"external-stdlib": "@rescript/std"
36+
"external-stdlib": "@rescript/runtime"
4037
}
4138
```
4239

@@ -49,14 +46,11 @@ Array.forEach([1, 2, 3], num => Console.log(num))
4946
```
5047

5148
```js
52-
// Note the require path starting with "@rescript/std".
53-
var Belt_Array = require("@rescript/std/lib/js/belt_Array.js");
54-
55-
Belt_Array.forEach([1, 2, 3], function (num) {
49+
[1, 2, 3].forEach(function (num) {
5650
console.log(num);
5751
});
5852
```
5953

6054
</CodeTab>
6155

62-
**Make sure the version number of `rescript` and `@rescript/std` match in your `package.json`** to avoid running into runtime issues due to mismatching stdlib assumptions.
56+
**Make sure the version number of `rescript` and `@rescript/runtime` match in your `package.json`** to avoid running into runtime issues due to mismatching stdlib assumptions.

markdown-pages/docs/manual/build-monorepo-setup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The root `rescript.json` manages the monorepo by listing its packages.
5858
"in-source": true
5959
},
6060
"suffix": ".res.mjs",
61-
"bsc-flags": []
61+
"compiler-flags": []
6262
}
6363
```
6464

markdown-pages/docs/manual/build-performance.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ The watcher is also just a thin file watcher that calls `rescript.exe`. We don't
6868

6969
ReScript doesn't take whole seconds to run every time. The bulk of the build performance comes from incremental build, aka re-building a previously built project when a few files changed.
7070

71-
In short, thanks to our compiler and the build system's architecture, we're able to **only build what's needed**. E.g. if `MyFile.res` isn't changed, then it's not recompiled. You can roughly emulate such incrementalism in languages like JavaScript, but the degree of correctness is unfortunately low. For example, if you rename or move a JS file, then the watcher might get confused and not pick up the "new" file or fail to clean things up correctly, resulting in you needing to clean your build and restart anew, which defeats the purpose.
72-
73-
Say goodbye to stale build from your JavaScript ecosystem!
71+
In short, thanks to our compiler and the build system's architecture, we're able to **only build what's needed**. If `MyFile.res` isn't changed, it isn't recompiled. The build system ensures complete correctness -- renaming or moving files is handled automatically, with no stale builds.
7472

7573
## Speed Up Incremental Build
7674

markdown-pages/docs/manual/control-flow.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ order: 14
1010

1111
ReScript supports `if`, `else`, ternary expression (`a ? b : c`), `for` and `while`.
1212

13-
The `switch` pattern has a default case too, just like many other functional languages. Read more about [pattern-matching & destructuring](./pattern-matching-destructuring.mdx). there.
13+
The `switch` pattern supports a default case. Read more about [pattern-matching & destructuring](./pattern-matching-destructuring.mdx).
1414

1515
## If-Else & Ternary
1616

17-
Unlike its JavaScript counterpart, ReScript's `if` is an expression; they evaluate to their body's content:
17+
ReScript's `if` is an expression; it evaluates to its body's content:
1818

1919
<CodeTab labels={["ReScript", "JS Output"]}>
2020

@@ -94,7 +94,7 @@ var message = isMorning ? "Good morning!" : "Hello!";
9494

9595
</CodeTab>
9696

97-
**`if-else` and ternary are much less used** in ReScript than in other languages; [Pattern-matching](./pattern-matching-destructuring.mdx) kills a whole category of code that previously required conditionals.
97+
`if-else` and ternary are often replaced by [pattern matching](./pattern-matching-destructuring.mdx), which handles a wide range of conditional logic more expressively.
9898

9999
## For Loops
100100

markdown-pages/docs/manual/converting-from-js.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ReScript offers a unique project conversion methodology which:
1212

1313
- Ensures minimal disruption to your teammates (very important!).
1414
- Remove the typical friction of verifying conversion's correctness and performance guarantees.
15-
- Doesn't force you to search for pre-made binding libraries made by others. **ReScript doesn't need the equivalent of TypeScript's `DefinitelyTyped`**.
15+
- Doesn't require pre-made binding libraries -- you can write bindings directly for any JavaScript API.
1616

1717
## Step 1: Install ReScript
1818

markdown-pages/docs/manual/editor-plugins.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ The code analysis provides extra checks for your ReScript project, such as detec
4040
### Configuration
4141

4242
Add a `reanalyze` section to your `rescript.json` to control what the analyzer checks or ignores. You'll get autocomplete for config options in the editor.
43-
More details: [reanalyze config docs](https://github.com/rescript-association/reanalyze#configuration-via-bsconfigjson)
43+
More details: [reanalyze configuration docs](https://github.com/rescript-association/reanalyze#configuration-via-bsconfigjson)
4444

4545
### Exception analysis
4646

4747
The exception analysis is designed to keep track statically of the exceptions that might be thrown at runtime. It works by issuing warnings and recognizing annotations. Warnings are issued whenever an exception is thrown and not immediately caught. Annotations are used to push warnings from he local point where the exception is thrown, to the outside context: callers of the current function.
4848
Nested functions need to be annotated separately.
4949

50-
Instructions on how to run the exception analysis using the `-exception` and `-exception-cmt` command-line arguments, or how to add `"analysis": ["exception"]` in `rescript.json` are contained in the [reanalyze config docs](https://github.com/rescript-association/reanalyze#configuration-via-bsconfigjson).
50+
Instructions on how to run the exception analysis using the `-exception` and `-exception-cmt` command-line arguments, or how to add `"analysis": ["exception"]` in `rescript.json` are contained in the [reanalyze configuration docs](https://github.com/rescript-association/reanalyze#configuration-via-bsconfigjson).
5151

5252
Here's an example, where the analysis reports a warning any time an exception is thrown, and not caught:
5353

@@ -142,12 +142,11 @@ There is a way to enhance this behavior via configuration, described further dow
142142

143143
### Dot completion enhancements
144144

145-
In ReScript, using a dot (`.`) normally means "access record field". But, because using `.` to trigger completions is so pervasive in for example JavaScript, we extend `.` to trigger completions in more scenarios than just for record field access.
145+
In ReScript, using a dot (`.`) normally means "access record field". The editor extends dot (`.`) to trigger completions in more scenarios beyond record field access, providing a more natural completion flow.
146146

147147
This behavior has the following important implications:
148148

149149
- Improves discoverability (E.g. using a `.` will reveal important pipe completions)
150-
- Enables a more natural completion flow for people used to JavaScript, where dots power more completions naturally
151150

152151
Below is a list of all the scenarios where using dots trigger completion in addition to the normal record field completion.
153152

0 commit comments

Comments
 (0)