Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/pattern-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ type point = {

type t =
| A((string, int))
| B(r)
| B(point)
| C(array(int))
| D(list(r));
| D(list(point));

let x = D([{x: 2, y: 1.2}]);
let x = D([{x: 2, y: 1}]);

switch (x) {
| A(("hi", num)) => num
| B({x, y: 1.2}) => x
| B({x, y: 1}) => x
| C([|x|]) => x
| C([|2, 3, x|]) => x
| D([]) => 2
Expand All @@ -156,8 +156,8 @@ switch (x) {
```reason
switch (x) {
| A(("hi", num)) as v => f(v)
| B({x: _, y: 1.2} as r) => g(r)
| D([{x: _, y: 1.2} as r, ..._]) => g(r)
| B({x: _, y: 1} as r) => g(r)
| D([{x: _, y: 1} as r, ..._]) => g(r)
| _ => 42
};
```
Expand Down
6 changes: 4 additions & 2 deletions docs/recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ Opt-out of recursive types using the `nonrec` keyword:

```reason
type t = string;
type nonrec t = list(t);
module M = {
type nonrec t = list(t);
};

/* t is now list(string) */
let x: t = ["hello", "world"];
let x: M.t = ["Hello", "World"]
```

## Mutually Recursive Types
Expand Down