Skip to content

Commit c539dd2

Browse files
authored
Merge branch 'master' into 800
2 parents 4812468 + 367a548 commit c539dd2

18 files changed

+54
-50
lines changed

pages/docs/manual/latest/bind-to-js-function.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ReScript has [labeled arguments](function.md#labeled-arguments) (that can also b
2626
// MyGame.js
2727

2828
function draw(x, y, border) {
29-
// suppose `border`` is optional and defaults to false
29+
// suppose `border` is optional and defaults to false
3030
}
3131
draw(10, 20)
3232
draw(20, 20, true)
@@ -259,7 +259,7 @@ external on: (
259259
let register = rl =>
260260
rl
261261
->on(#close(event => ()))
262-
->on(#line(line => print_endline(line)))
262+
->on(#line(line => Js.log(line)));
263263
```
264264
```js
265265
function register(rl) {
@@ -287,13 +287,13 @@ external processOnExit: (
287287
@bs.as("exit") _,
288288
int => unit
289289
) => unit = "process.on"
290-
let () = processOnExit(exit_code =>
291-
Js.log("error code: " ++ string_of_int(exit_code))
290+
let () = processOnExit(exitCode =>
291+
Js.log("error code: " ++ Js.Int.toString(exitCode))
292292
);
293293
```
294294
```js
295-
process.on("exit", function (exit_code) {
296-
console.log("error code: " + String(exit_code));
295+
process.on("exit", function (exitCode) {
296+
console.log("error code: " + exitCode.toString());
297297
});
298298
```
299299

@@ -308,9 +308,9 @@ Curry is a delicious Indian dish. More importantly, in the context of ReScript (
308308
See the `addFive` intermediate function? `add` takes in 3 arguments but received only 1. It's interpreted as "currying" the argument `5` and waiting for the next 2 arguments to be applied later on. Type signatures:
309309

310310
```resi
311-
let add: (int, int, int) => int;
312-
let addFive: (int, int) => int;
313-
let twelve: int;
311+
let add: (int, int, int) => int
312+
let addFive: (int, int) => int
313+
let twelve: int
314314
```
315315

316316
(In a dynamic language such as JS, currying would be dangerous, since accidentally forgetting to pass an argument doesn't error at compile time).

pages/docs/manual/latest/bind-to-js-object.mdx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type person = {
5151
"name": string,
5252
"friends": array<string>,
5353
"age": int,
54-
};
54+
}
5555
5656
@bs.module("MySchool") external john: person = "john"
5757
@@ -77,9 +77,6 @@ type textarea
7777
@bs.get external getName: textarea => string = "name"
7878
```
7979
```js
80-
type textarea
81-
@bs.set external setName: (textarea, string) => unit = "name"
82-
@bs.get external getName: textarea => string = "name"
8380
```
8481

8582
</CodeTab>
@@ -125,7 +122,7 @@ Use `bs.new` to emulate e.g. `new Date()`:
125122
type t
126123
@bs.new external createDate: unit => t = "Date"
127124
128-
let date = createDate();
125+
let date = createDate()
129126
```
130127
```js
131128
var date = new Date();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ In short, thanks to our bsc compiler and bsb build system's architecture, we're
6363

6464
## Speed Up Incremental Build
6565

66-
ReScript uses the concept of interface files (`.resi`) (or, equivalently, [module signatures](/docs/manual/latest/module#signatures)). Exposing only what you need naturally speeds up incremental builds. E.g. if you change a `.res` file whose corresponding `.resi` file doesn't expose the changed part, then you've reduced the amount of dependent files you have to rebuild.
66+
ReScript uses the concept of interface files (`.resi`) (or, equivalently, [module signatures](module.md#signatures)). Exposing only what you need naturally speeds up incremental builds. E.g. if you change a `.res` file whose corresponding `.resi` file doesn't expose the changed part, then you've reduced the amount of dependent files you have to rebuild.
6767

6868
<!-- TODO: validate this -->
6969

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let queryResult = (usePayload, payload) =>
5959

6060
You might still occasionally get syntax errors, but not as drastic as the previous step's.
6161

62-
- Change `foo.bar` to `foo["bar"]`. This escape-hatch [ReScript feature](/docs/reason-compiler/latest/object) will be your medium-term friend.
62+
- Change `foo.bar` to `foo["bar"]`. This escape-hatch [ReScript feature](object.md) will be your medium-term friend.
6363
- To communicate with external JS files, use `external`. They're our [foreign function interface](external.md).
6464
- Inline externals. No need to create clean, well-separated files for externals for now. We'll come back to these.
6565
- If it's too cumbersome to correctly type an `external`'s input/output, use some placeholder polymorphic types, e.g. `external getStudentById: 'whatever => 'whateverElse = ...`.
@@ -75,7 +75,7 @@ let defaultId = 10
7575
7676
let queryResult = (usePayload, payload) =>
7777
if usePayload {
78-
payload["student"] // this will be inferred as `Js.t 'a`
78+
payload["student"] // this will be inferred as `Js.t<'a>`
7979
} else {
8080
getStudentById(defaultId)
8181
};

pages/docs/manual/latest/exception.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Exceptions are just a special kind of variant, thrown in **exceptional** cases (
77
<CodeTab labels={["ReScript", "JS Output"]}>
88

99
```res
10-
let getItem = (theList) =>
10+
let getItem = (items) =>
1111
if callSomeFunctionThatThrows() {
1212
// return the found item here
1313
1
@@ -23,7 +23,7 @@ let result =
2323
}
2424
```
2525
```js
26-
function getItem(theList) {
26+
function getItem(items) {
2727
if (callSomeFunctionThatThrows()) {
2828
return 1;
2929
}
@@ -153,7 +153,7 @@ The `obj` here is of type `Js.Exn.t`, intentionally opaque to disallow illegal o
153153

154154
## Raise a JS Exception
155155

156-
`raise MyException` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Js.Exn.raiseError`:
156+
`raise(MyException)` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Js.Exn.raiseError`:
157157

158158
<CodeTab labels={["ReScript", "JS Output"]}>
159159

pages/docs/manual/latest/faq.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Reason is a syntax layer for OCaml that BuckleScript also adopted. The current R
2020

2121
Please see our [blog post](https://reasonml.org/blog/a-note-on-bucklescripts-future-commitments) on this matter.
2222

23+
**Where can I see the docs in old Reason syntax?**
24+
25+
Switch the doc version to `v8.0.0` in the sidebar on the left!
26+
2327
**Will ReScript support native compilation eventually?**
2428

2529
Our focus is a solid JS story right now. In the future, if there’s strong demand, we might consider it.

pages/docs/manual/latest/function.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ let add = (~first: int=1, ~second: int=2) : int => first + second
458458
// optional
459459
let add = (~first as x: option<int>=?, ~second as y: option<int>=?) : int => switch x {...}
460460
// with punning sugar
461-
// note that the caller would pass an `int`, not `option int`
462-
// Inside the function, `first` and `second` are `option int`.
461+
// note that the caller would pass an `int`, not `option<int>`
462+
// Inside the function, `first` and `second` are `option<int>`.
463463
let add = (~first: option<int>=?, ~second: option<int>=?) : int => switch first {...}
464464
```
465465

pages/docs/manual/latest/import-from-export-to-js.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Technically, since a ReScript file maps to a module, there's no such thing as "d
9494
<CodeTab labels={["ReScript", "JS Output"]}>
9595

9696
```res
97-
/* FavoriteStudent.ml */
97+
/* FavoriteStudent.res */
9898
let default = "Bob"
9999
```
100100
```js

pages/docs/manual/latest/interop-cheatsheet.mdx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ Handling a value that can be `undefined` and `null`, by ditching the `option` ty
6969
<CodeTab labels={["ReScript", "JS Output"]}>
7070

7171
```res
72-
let jsNull = Js.Nullable.null;
73-
let jsUndefined = Js.Nullable.undefined;
74-
let result1: Js.Nullable.t<string> = Js.Nullable.return("hello");
75-
let result2: Js.Nullable.t<int> = Js.Nullable.fromOption(Some(10));
76-
let result3: option<int> = Js.Nullable.toOption(Js.Nullable.return(10));
72+
let jsNull = Js.Nullable.null
73+
let jsUndefined = Js.Nullable.undefined
74+
let result1: Js.Nullable.t<string> = Js.Nullable.return("hello")
75+
let result2: Js.Nullable.t<int> = Js.Nullable.fromOption(Some(10))
76+
let result3: option<int> = Js.Nullable.toOption(Js.Nullable.return(10))
7777
```
7878
```js
7979
var Caml_option = require("./stdlib/caml_option.js");
@@ -196,16 +196,19 @@ var gpa = 2.1 + 10;
196196

197197
## List of `@bs` Decorators
198198

199-
- `@bs.val`
200-
- `@bs.scope`
199+
- `@bs.as`
201200
- `@bs.get`
202-
- `@bs.set`
201+
- `@bs.inline`
202+
- `@bs.int`
203+
- `@bs.meth`
204+
- `@bs.new`
205+
- `@bs.return`
206+
- `@bs.scope`
203207
- `@bs.send`
208+
- `@bs.set`
204209
- `@bs.string`
205-
- `@bs.int`
210+
- `@bs.this`
211+
- `@bs.uncurry`
206212
- `@bs.unwrap`
207-
- `@bs.new`
208-
- `@bs.as`
213+
- `@bs.val`
209214
- `@bs.variadic`
210-
- `@bs.inline`
211-
- `@bs.meth`

pages/docs/manual/latest/lazy-values.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var lazyDoesFileExist = {
109109

110110
</CodeTab>
111111

112-
Whenever we want to wrap a function `unit => 'a`, we use `Lazy.from_fun`, otherwise we use the `lazy([expr])` keyword to wrap an expression or a function with 1 or more arguments.
112+
Whenever we want to wrap a function `unit => 'a`, we use `Lazy.from_fun`, otherwise we use the `lazy(expr)` keyword to wrap an expression or a function with 1 or more arguments.
113113

114114
## Force a lazy computation
115115

0 commit comments

Comments
 (0)