@@ -1153,7 +1153,10 @@ type t = {
1153
1153
bar: string,
1154
1154
};
1155
1155
1156
- let value = {foo: 7, bar: "baz"};
1156
+ let value = {
1157
+ foo: 7,
1158
+ bar: "baz",
1159
+ };
1157
1160
```
1158
1161
1159
1162
And its JavaScript generated code:
@@ -1185,7 +1188,10 @@ let john = [%mel.obj { name = "john"; age = 99 }]
1185
1188
let t = john##name
1186
1189
```
1187
1190
``` reasonml
1188
- let john = {"name": "john", "age": 99};
1191
+ let john = {
1192
+ "name": "john",
1193
+ "age": 99,
1194
+ };
1189
1195
let t = john##name;
1190
1196
```
1191
1197
@@ -1218,8 +1224,16 @@ let two = name_extended [%mel.obj { name = "jane"; address = "1 infinite loop" }
1218
1224
``` reasonml
1219
1225
let name_extended = obj => obj##name ++ " wayne";
1220
1226
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
+ });
1223
1237
```
1224
1238
1225
1239
To read more about objects and polymorphism we recommend checking the [ OCaml
@@ -2018,7 +2032,14 @@ let _ = padLeft "Hello World" (`Str "Message from Melange: ")
2018
2032
```
2019
2033
``` reasonml
2020
2034
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 =
2022
2043
"padLeft";
2023
2044
2024
2045
let _ = padLeft("Hello World", `Int(4));
@@ -2063,7 +2084,14 @@ let _ = read_file_sync ~name:"xx.txt" `ascii
2063
2084
``` reasonml
2064
2085
[@mel.module "fs"]
2065
2086
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 =
2067
2095
"readFileSync";
2068
2096
2069
2097
let _ = read_file_sync(~name="xx.txt", `ascii);
@@ -2148,7 +2176,15 @@ let value = test_int_type `on_open
2148
2176
```
2149
2177
``` reasonml
2150
2178
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 =
2152
2188
"testIntType";
2153
2189
2154
2190
let value = test_int_type(`on_open);
@@ -2189,7 +2225,10 @@ type readline;
2189
2225
external on:
2190
2226
(
2191
2227
readline,
2192
- [@mel.string] [ | `close(unit => unit) | `line(string => unit)]
2228
+ [@mel.string] [
2229
+ | `close(unit => unit)
2230
+ | `line(string => unit)
2231
+ ]
2193
2232
) =>
2194
2233
readline =
2195
2234
"on";
@@ -2753,7 +2792,11 @@ type action =
2753
2792
```
2754
2793
``` reasonml
2755
2794
[@deriving jsConverter]
2756
- type action = [ | `Click | [@mel.as "submit"] `Submit | `Cancel];
2795
+ type action = [
2796
+ | `Click
2797
+ | [@mel.as "submit"] `Submit
2798
+ | `Cancel
2799
+ ];
2757
2800
```
2758
2801
2759
2802
Akin to the variant example, the following two functions will be generated:
@@ -3465,7 +3508,10 @@ literal directly:
3465
3508
let person = [%mel.obj { id = 1; name = "Alice" }]
3466
3509
```
3467
3510
``` reasonml
3468
- let person = {"id": 1, "name": "Alice"};
3511
+ let person = {
3512
+ "id": 1,
3513
+ "name": "Alice",
3514
+ };
3469
3515
```
3470
3516
3471
3517
See the [ Using ` Js.t ` objects] ( #using-jst-objects ) section for more information.
@@ -3482,7 +3528,10 @@ type person = {
3482
3528
id: int,
3483
3529
name: string,
3484
3530
};
3485
- let person = {id: 1, name: "Alice"};
3531
+ let person = {
3532
+ id: 1,
3533
+ name: "Alice",
3534
+ };
3486
3535
```
3487
3536
3488
3537
See the [ Using OCaml records] ( #using-ocaml-records ) section for more
@@ -3545,7 +3594,10 @@ type person = {
3545
3594
name: string,
3546
3595
};
3547
3596
3548
- let person = {id: 1, name: "Alice"};
3597
+ let person = {
3598
+ id: 1,
3599
+ name: "Alice",
3600
+ };
3549
3601
let {id, name} = person;
3550
3602
```
3551
3603
0 commit comments