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
ReScript is a rebranding and cleanup of BuckleScript & Reason that enables us to ship a tighter compile-to-JS stack with more coherent documentation & tools. If you're an existing user of BuckleScript & Reason, here's the gist:
9
+
ReScript is a rebranding and cleanup of BuckleScript (since `v8.2.0`) & Reason (`v3.6`) that enables us to ship a tighter compile-to-JS stack with more coherent documentation & tools. If you're an existing user of BuckleScript & Reason, here's the gist:
10
10
11
11
- ReScript is mostly just BuckleScript rebranded, with a new syntax that's like the Reason syntax, but catered more toward the JavaScript crowd.
12
12
- All your existing code will keep working even if you don't upgrade.
@@ -15,9 +15,30 @@ ReScript is a rebranding and cleanup of BuckleScript & Reason that enables us to
15
15
16
16
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:
17
17
18
-
- Upgrade your project to `bs-platform 8.2.0`.
18
+
- Upgrade your project to `bs-platform 8.2.0` or later.
**That's it**! `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file.
22
22
23
23
Enjoy the improved experience!
24
+
25
+
## Difference With Old Reason
26
+
27
+
- Complete removal of semicolon (you can still write them).
28
+
- No need for parentheses around `if`, `switch` and `try`.
29
+
- Type arguments: from `option(int)` to `option<int>`.
30
+
- Old interpolated string: from `{j|hello ${name}|j}` to `` j`hello ${name}` ``. Now with proper unicode support!
31
+
- New interpolated string: `` `hello world` ``. Also supports multiline and unicode. `"hello world"` string is now singleline.
32
+
- Polymorphic variants: from `` `red`` to `#red`.
33
+
- Arrays: from `[|1,2,3|]` to `[1,2,3]`. In JS, arrays are the right default.
34
+
- Lists: from `[1,2,3]` to `list[1,2,3]` (_8.1.1 update_: now it is `list{1, 2, 3}`). This ties with upcoming plans to access containers in a uniform way: `set[...]` and `map[...]`. Maybe temporary.
35
+
- Exception: from `try (compute()) { | Not_found => Js.log("oops")}` to `try compute() catch { | Not_found => Js.log("oops")}`.
36
+
- First class module: from `(module S: Student)` to `module(S: Student)`.
37
+
- No custom infix operator for now (including `mod`).
38
+
- Object access: from `settings##visible #= true` to `settings["visible"] = true`. Rejoice!
39
+
- Object: from `Js.t({"age": int})` to just `{"age": int}`. The `Js.t` part is now implicit.
40
+
- Attribute: from `[@bs.deriving accessors]` to `@bs.deriving(accessors)`. From `[%re bla]` to `%re(bla)`.
41
+
- Removed dereference syntax `result^`. Just use `result.contents`.
42
+
-`fun` pattern matching syntax removed.
43
+
- Type declaration is non-recursive by default, consistent with let bindings. To have recursive types, use `type rec myList<'a> = Nil | Cons('a, myList<'a>)`.
44
+
- Use any words, including reserved keywords, as your identifier name: `let \"try" = true`.
Copy file name to clipboardExpand all lines: pages/docs/manual/v8.0.0/migrate-from-bucklescript-reason.mdx
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,30 @@ The old ML and Reason syntax are still supported (see our support commitment [he
14
14
15
15
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:
16
16
17
-
- Upgrade your project to `bs-platform 8.2.0`.
17
+
- Upgrade your project to `bs-platform 8.2.0` or later.
**That's it**! `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file.
21
21
22
22
Enjoy the improved experience!
23
+
24
+
## Difference With Old Reason
25
+
26
+
- Complete removal of semicolon (you can still write them).
27
+
- No need for parentheses around `if`, `switch` and `try`.
28
+
- Type arguments: from `option(int)` to `option<int>`.
29
+
- Old interpolated string: from `{j|hello ${name}|j}` to `` j`hello ${name}` ``. Now with proper unicode support!
30
+
- New interpolated string: `` `hello world` ``. Also supports multiline and unicode. `"hello world"` string is now singleline.
31
+
- Polymorphic variants: from `` `red`` to `#red`.
32
+
- Arrays: from `[|1,2,3|]` to `[1,2,3]`. In JS, arrays are the right default.
33
+
- Lists: from `[1,2,3]` to `list[1,2,3]` (_8.1.1 update_: now it is `list{1, 2, 3}`). This ties with upcoming plans to access containers in a uniform way: `set[...]` and `map[...]`. Maybe temporary.
34
+
- Exception: from `try (compute()) { | Not_found => Js.log("oops")}` to `try compute() catch { | Not_found => Js.log("oops")}`.
35
+
- First class module: from `(module S: Student)` to `module(S: Student)`.
36
+
- No custom infix operator for now (including `mod`).
37
+
- Object access: from `settings##visible #= true` to `settings["visible"] = true`. Rejoice!
38
+
- Object: from `Js.t({"age": int})` to just `{"age": int}`. The `Js.t` part is now implicit.
39
+
- Attribute: from `[@bs.deriving accessors]` to `@bs.deriving(accessors)`. From `[%re bla]` to `%re(bla)`.
40
+
- Removed dereference syntax `result^`. Just use `result.contents`.
41
+
-`fun` pattern matching syntax removed.
42
+
- Type declaration is non-recursive by default, consistent with let bindings. To have recursive types, use `type rec myList<'a> = Nil | Cons('a, myList<'a>)`.
43
+
- Use any words, including reserved keywords, as your identifier name: `let \"try" = true`.
0 commit comments