Skip to content

Commit e8e5376

Browse files
authored
Update reason snippets after 3.13 (#203)
1 parent 0613b8a commit e8e5376

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed

docs/communicate-with-javascript.md

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,10 @@ type t = {
11531153
bar: string,
11541154
};
11551155
1156-
let value = {foo: 7, bar: "baz"};
1156+
let value = {
1157+
foo: 7,
1158+
bar: "baz",
1159+
};
11571160
```
11581161

11591162
And its JavaScript generated code:
@@ -1185,7 +1188,10 @@ let john = [%mel.obj { name = "john"; age = 99 }]
11851188
let t = john##name
11861189
```
11871190
```reasonml
1188-
let john = {"name": "john", "age": 99};
1191+
let john = {
1192+
"name": "john",
1193+
"age": 99,
1194+
};
11891195
let t = john##name;
11901196
```
11911197

@@ -1218,8 +1224,16 @@ let two = name_extended [%mel.obj { name = "jane"; address = "1 infinite loop" }
12181224
```reasonml
12191225
let name_extended = obj => obj##name ++ " wayne";
12201226
1221-
let one = name_extended({"name": "john", "age": 99});
1222-
let two = name_extended({"name": "jane", "address": "1 infinite loop"});
1227+
let one =
1228+
name_extended({
1229+
"name": "john",
1230+
"age": 99,
1231+
});
1232+
let two =
1233+
name_extended({
1234+
"name": "jane",
1235+
"address": "1 infinite loop",
1236+
});
12231237
```
12241238

12251239
To read more about objects and polymorphism we recommend checking the [OCaml
@@ -2018,7 +2032,14 @@ let _ = padLeft "Hello World" (`Str "Message from Melange: ")
20182032
```
20192033
```reasonml
20202034
external padLeft:
2021-
(string, [@mel.unwrap] [ | `Str(string) | `Int(int)]) => string =
2035+
(
2036+
string,
2037+
[@mel.unwrap] [
2038+
| `Str(string)
2039+
| `Int(int)
2040+
]
2041+
) =>
2042+
string =
20222043
"padLeft";
20232044
20242045
let _ = padLeft("Hello World", `Int(4));
@@ -2063,7 +2084,14 @@ let _ = read_file_sync ~name:"xx.txt" `ascii
20632084
```reasonml
20642085
[@mel.module "fs"]
20652086
external read_file_sync:
2066-
(~name: string, [@mel.string] [ | `utf8 | `ascii]) => string =
2087+
(
2088+
~name: string,
2089+
[@mel.string] [
2090+
| `utf8
2091+
| `ascii
2092+
]
2093+
) =>
2094+
string =
20672095
"readFileSync";
20682096
20692097
let _ = read_file_sync(~name="xx.txt", `ascii);
@@ -2148,7 +2176,15 @@ let value = test_int_type `on_open
21482176
```
21492177
```reasonml
21502178
external test_int_type:
2151-
([@mel.int] [ | `on_closed | [@mel.as 20] `on_open | `in_bin]) => int =
2179+
(
2180+
[@mel.int]
2181+
[
2182+
| `on_closed
2183+
| [@mel.as 20] `on_open
2184+
| `in_bin
2185+
]
2186+
) =>
2187+
int =
21522188
"testIntType";
21532189
21542190
let value = test_int_type(`on_open);
@@ -2189,7 +2225,10 @@ type readline;
21892225
external on:
21902226
(
21912227
readline,
2192-
[@mel.string] [ | `close(unit => unit) | `line(string => unit)]
2228+
[@mel.string] [
2229+
| `close(unit => unit)
2230+
| `line(string => unit)
2231+
]
21932232
) =>
21942233
readline =
21952234
"on";
@@ -2753,7 +2792,11 @@ type action =
27532792
```
27542793
```reasonml
27552794
[@deriving jsConverter]
2756-
type action = [ | `Click | [@mel.as "submit"] `Submit | `Cancel];
2795+
type action = [
2796+
| `Click
2797+
| [@mel.as "submit"] `Submit
2798+
| `Cancel
2799+
];
27572800
```
27582801

27592802
Akin to the variant example, the following two functions will be generated:
@@ -3465,7 +3508,10 @@ literal directly:
34653508
let person = [%mel.obj { id = 1; name = "Alice" }]
34663509
```
34673510
```reasonml
3468-
let person = {"id": 1, "name": "Alice"};
3511+
let person = {
3512+
"id": 1,
3513+
"name": "Alice",
3514+
};
34693515
```
34703516

34713517
See the [Using `Js.t` objects](#using-jst-objects) section for more information.
@@ -3482,7 +3528,10 @@ type person = {
34823528
id: int,
34833529
name: string,
34843530
};
3485-
let person = {id: 1, name: "Alice"};
3531+
let person = {
3532+
id: 1,
3533+
name: "Alice",
3534+
};
34863535
```
34873536

34883537
See the [Using OCaml records](#using-ocaml-records) section for more
@@ -3545,7 +3594,10 @@ type person = {
35453594
name: string,
35463595
};
35473596
3548-
let person = {id: 1, name: "Alice"};
3597+
let person = {
3598+
id: 1,
3599+
name: "Alice",
3600+
};
35493601
let {id, name} = person;
35503602
```
35513603

documentation-site.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bug-reports: "https://github.com/melange-re/melange-re.github.io"
1515
depends: [
1616
"ocaml"
1717
"dune" {>= "3.8.0"}
18-
"reason" {>= "3.12.0" & < "3.13.0"}
18+
"reason" {>= "3.13.0"}
1919
"reason-react"
2020
"reason-react-ppx"
2121
"ocamlformat"

playground/src/app.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function Sidebar({ onExampleClick }) {
145145
</span>
146146
<span className="Version">
147147
<span className="Text-xs">{"Reason"}</span>
148-
<span className="Text-xs Number">{"3.12.0"}</span>
148+
<span className="Text-xs Number">{"3.14.0"}</span>
149149
</span>
150150
<span className="Version">
151151
<span className="Text-xs">{"ReasonReact"}</span>

0 commit comments

Comments
 (0)