Skip to content

Commit e89c13e

Browse files
DZakhcristianoc
authored andcommitted
Convert Reason generix syntax to ReScript
1 parent 8b5ef34 commit e89c13e

12 files changed

+45
-45
lines changed

pages/docs/gentype/latest/supported-types.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ ReScript values e.g. `"a"`, `"b"`, `"c"` are unchanged. So they are exported to
2626

2727
## Optionals
2828

29-
ReScript values of type e.g. `option(int)`, such as `None`, `Some(0)`, `Some(1)`, `Some(2)`, are exported to JS values `null`, `undefined`, `0`, `1`, `2`.
29+
ReScript values of type e.g. `option<int>`, such as `None`, `Some(0)`, `Some(1)`, `Some(2)`, are exported to JS values `null`, `undefined`, `0`, `1`, `2`.
3030
The JS values are unboxed, and `null`/`undefined` are conflated.
3131
So the option type is exported to JS type `null` or `undefined` or `number`.
3232

3333
## Nullables
3434

35-
ReScript values of type e.g. `Js.Nullable.t(int)`, such as `Js.Nullable.null`, `Js.Nullable.undefined`, `Js.Nullable.return(0)`, `Js.Nullable.return(1)`, `Js.Nullable.return(2)`, are exported to JS values `null`, `undefined`, `0`, `1`, `2`.
35+
ReScript values of type e.g. `Js.Nullable.t<int>`, such as `Js.Nullable.null`, `Js.Nullable.undefined`, `Js.Nullable.return(0)`, `Js.Nullable.return(1)`, `Js.Nullable.return(2)`, are exported to JS values `null`, `undefined`, `0`, `1`, `2`.
3636
The JS values are identical: there is no conversion unless the argument type needs conversion.
3737

3838
## Records
@@ -44,7 +44,7 @@ Since records are immutable by default, their fields will be exported to readonl
4444

4545
The `@genType.as` annotation can be used to change the name of a field on the JS side of things. So e.g. `{[@genType.as "y"] x:int}` is exported as JS type `{y:int}`.
4646

47-
If one field of the ReScript record has option type, this is exported to an optional JS field. So for example ReScript type `{x: option(int)}` is exported as JS type `{x?: number}`.
47+
If one field of the ReScript record has option type, this is exported to an optional JS field. So for example ReScript type `{x: option<int>}` is exported as JS type `{x?: number}`.
4848

4949
## Objects
5050

@@ -53,7 +53,7 @@ A conversion is required only when the type of some field requires conversions.
5353

5454
Since objects are immutable by default, their fields will be exported to readonly property types in Flow/TS. Mutable fields are specified in ReScript by e.g. `{ @set "mutableField": string }`.
5555

56-
It is possible to mix object and option types, so for example the ReScript type `{. "x":int, "y":option(string)}` exports to JS type `{x:number, ?y: string}`, requires no conversion, and allows option pattern matching on the ReScript side.
56+
It is possible to mix object and option types, so for example the ReScript type `{. "x":int, "y":option<string>}` exports to JS type `{x:number, ?y: string}`, requires no conversion, and allows option pattern matching on the ReScript side.
5757

5858
Object field names follow ReScript's mangling convention (so e.g. `_type` in ReScript represents `type` in JS):
5959

@@ -104,7 +104,7 @@ Arrays with elements of ReScript type `t` are exported to JS arrays with element
104104

105105
Immutable arrays are supported with the additional ReScript library
106106
[ImmutableArray.res/.resi](https://github.com/reason-association/genType/tree/master/examples/typescript-react-example/src/ImmutableArray.resi), which currently needs to be added to your project.
107-
The type `ImmutableArray.t(+'a)` is covariant, and is mapped to readonly array types in TS/Flow. As opposed to TS/Flow, `ImmutableArray.t` does not allow casting in either direction with normal arrays. Instead, a copy must be performed using `fromArray` and `toArray`.
107+
The type `ImmutableArray.t<+'a>` is covariant, and is mapped to readonly array types in TS/Flow. As opposed to TS/Flow, `ImmutableArray.t` does not allow casting in either direction with normal arrays. Instead, a copy must be performed using `fromArray` and `toArray`.
108108

109109
## Functions and Function Components
110110

@@ -213,5 +213,5 @@ const none = <T1>(a: T1): ?T1 => OptionBS.none;
213213
214214
## Promises
215215
216-
Values of type `Js.Promise.t(arg)` are exported to JS promises of type `Promise<argJS>` where `argJS` is the JS type corresponding to `arg`.
216+
Values of type `Js.Promise.t<arg>` are exported to JS promises of type `Promise<argJS>` where `argJS` is the JS type corresponding to `arg`.
217217
If a conversion for the argument is required, the conversion functions are chained via `.then(promise => ...)`.

pages/docs/manual/latest/api/belt/result.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type t<'a, 'b> =
1717
| Error('b)
1818
```
1919

20-
The type `Result.t(result, err)` describes a variant of two states:
20+
The type `Result.t<result, err>` describes a variant of two states:
2121
`Ok(someResult)` represents a successful operation, whereby
2222
``Error(someError)` signals an erronous operation.
2323

pages/docs/manual/latest/api/js/null-undefined.mdx

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Provide utilities around `Js.null_undefined`.
1212
type t<'a> = Js.null_undefined<'a>
1313
```
1414

15-
Local alias for `Js.null_undefined('a)`.
15+
Local alias for `Js.null_undefined<'a>`.
1616

1717
## return
1818

1919
```res sig
2020
let return: 'a => t<'a>
2121
```
2222

23-
Constructs a value of `Js.null_undefined('a)` containing a value of `'a`.
23+
Constructs a value of `Js.null_undefined<'a>` containing a value of `'a`.
2424

2525
## test
2626

@@ -42,15 +42,15 @@ Returns `true` if the given value is null or undefined, `false` otherwise.
4242
let null: t<'a>
4343
```
4444

45-
The null value of type `Js.null_undefined('a)`.
45+
The null value of type `Js.null_undefined<'a>`.
4646

4747
## undefined
4848

4949
```res sig
5050
let undefined: t<'a>
5151
```
5252

53-
The undefined value of type `Js.null_undefined('a)`.
53+
The undefined value of type `Js.null_undefined<'a>`.
5454

5555
## bind
5656

@@ -59,7 +59,7 @@ let bind: (t<'a>, (. 'a) => 'b) => t<'b>
5959
```
6060

6161
Maps the contained value using the given function.
62-
If `Js.null_undefined('a)` contains a value, that value is unwrapped, mapped to a `'b` using the given function `a' => 'b`, then wrapped back up and returned as `Js.null_undefined('b)`.
62+
If `Js.null_undefined<'a>` contains a value, that value is unwrapped, mapped to a `'b` using the given function `a' => 'b`, then wrapped back up and returned as `Js.null_undefined<'b>`.
6363

6464
```res example
6565
let maybeGreetWorld = (maybeGreeting: Js.null_undefined<string>) =>
@@ -73,7 +73,7 @@ let iter: (t<'a>, (. 'a) => unit) => unit
7373
```
7474

7575
Iterates over the contained value with the given function.
76-
If `Js.null_undefined('a)` contains a value, that value is unwrapped and applied to the given function.
76+
If `Js.null_undefined<'a>` contains a value, that value is unwrapped and applied to the given function.
7777

7878
```res example
7979
let maybeSay = (maybeMessage: Js.null_undefined<string>) =>
@@ -86,7 +86,7 @@ let maybeSay = (maybeMessage: Js.null_undefined<string>) =>
8686
let fromOption: option<'a> => t<'a>
8787
```
8888

89-
Maps `option('a)` to `Js.null_undefined('a)`.
89+
Maps `option<'a>` to `Js.null_undefined<'a>`.
9090
`Some(a)` => `a`
9191
`None` => `undefined`
9292

@@ -102,7 +102,7 @@ let from_opt: option<'a> => t<'a>
102102
let toOption: t<'a> => option<'a>
103103
```
104104

105-
Maps `Js.null_undefined('a)` to `option('a)`.
105+
Maps `Js.null_undefined<'a>` to `option<'a>`.
106106
`a` => `Some(a)`
107107
`undefined` => `None`
108108
`null` => `None`

pages/docs/manual/latest/api/js/null.mdx

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
<Intro>
44

5-
Provide utilities around `null('a)`.
5+
Provide utilities around `null<'a>`.
66

77
</Intro>
88

99
```res prelude
1010
type t<'a> = Js.null<'a>
1111
```
1212

13-
Local alias for `Js.null('a)`.
13+
Local alias for `Js.null<'a>`.
1414

1515
```res sig
1616
let return: 'a => t<'a>
1717
```
1818

19-
Constructs a value of `Js.null('a)` containing a value of `'a`.
19+
Constructs a value of `Js.null<'a>` containing a value of `'a`.
2020

2121
## test
2222

@@ -53,7 +53,7 @@ let bind: (t<'a>, (. 'a) => 'b) => t<'b>
5353
```
5454

5555
Maps the contained value using the given function.
56-
If `Js.null('a)` contains a value, that value is unwrapped, mapped to a `'b` using the given function `'a => 'b`, then wrapped back up and returned as `Js.null('b)`.
56+
If `Js.null<'a>` contains a value, that value is unwrapped, mapped to a `'b` using the given function `'a => 'b`, then wrapped back up and returned as `Js.null<'b>`.
5757

5858
```res example
5959
let maybeGreetWorld = (maybeGreeting: Js.null<string>) =>
@@ -67,7 +67,7 @@ let iter: (t<'a>, (. 'a) => unit) => unit
6767
```
6868

6969
Iterates over the contained value with the given function.
70-
If `Js.null('a)` contains a value, that value is unwrapped and applied to the given function.
70+
If `Js.null<'a>` contains a value, that value is unwrapped and applied to the given function.
7171

7272
```res example
7373
let maybeSay = (maybeMessage: Js.null<string>) =>
@@ -80,7 +80,7 @@ let maybeSay = (maybeMessage: Js.null<string>) =>
8080
let fromOption: option<'a> => t<'a>
8181
```
8282

83-
Maps `option('a)` to `Js.null('a)`.
83+
Maps `option<'a>` to `Js.null<'a>`.
8484
`Some(a)` => `a`
8585
`None` => `empty`
8686

@@ -96,7 +96,7 @@ let from_opt: option<'a> => t<'a>
9696
let toOption: t<'a> => option<'a>
9797
```
9898

99-
Maps `Js.null('a)` to `option('a)`.
99+
Maps `Js.null<'a>` to `option<'a>`.
100100
`a` => `Some(a)`
101101
`empty` => `None`
102102

pages/docs/manual/latest/api/js/nullable.mdx

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Provide utilities around `Js.null_undefined`.
1212
type t<'a> = Js.null_undefined<'a>
1313
```
1414

15-
Local alias for `Js.null_undefined('a)`.
15+
Local alias for `Js.null_undefined<'a>`.
1616

1717
## return
1818

1919
```res sig
2020
let return: 'a => t<'a>
2121
```
2222

23-
Constructs a value of `Js.null_undefined('a)` containing a value of `'a`.
23+
Constructs a value of `Js.null_undefined<'a>` containing a value of `'a`.
2424

2525
## test
2626

@@ -42,15 +42,15 @@ Returns `true` if the given value is null or undefined, `false` otherwise.
4242
let null: t<'a>
4343
```
4444

45-
The null value of type `Js.null_undefined('a)`.
45+
The null value of type `Js.null_undefined<'a>`.
4646

4747
## undefined
4848

4949
```res sig
5050
let undefined: t<'a>
5151
```
5252

53-
The undefined value of type `Js.null_undefined('a)`.
53+
The undefined value of type `Js.null_undefined<'a>`.
5454

5555
## bind
5656

@@ -59,7 +59,7 @@ let bind: (t<'a>, (. 'a) => 'b) => t<'b>
5959
```
6060

6161
Maps the contained value using the given function.
62-
If `Js.null_undefined('a)` contains a value, that value is unwrapped, mapped to a `'b` using the given function `a' => 'b`, then wrapped back up and returned as `Js.null_undefined('b)`.
62+
If `Js.null_undefined<'a>` contains a value, that value is unwrapped, mapped to a `'b` using the given function `a' => 'b`, then wrapped back up and returned as `Js.null_undefined<'b>`.
6363

6464
```res example
6565
let maybeGreetWorld = (maybeGreeting: Js.null_undefined<string>) =>
@@ -73,7 +73,7 @@ let iter: (t<'a>, (. 'a) => unit) => unit
7373
```
7474

7575
Iterates over the contained value with the given function.
76-
If `Js.null_undefined('a)` contains a value, that value is unwrapped and applied to the given function.
76+
If `Js.null_undefined<'a>` contains a value, that value is unwrapped and applied to the given function.
7777

7878
```res example
7979
let maybeSay = (maybeMessage: Js.null_undefined<string>) =>
@@ -86,7 +86,7 @@ let maybeSay = (maybeMessage: Js.null_undefined<string>) =>
8686
let fromOption: option<'a> => t<'a>
8787
```
8888

89-
Maps `option('a)` to `Js.null_undefined('a)`.
89+
Maps `option<'a>` to `Js.null_undefined<'a>`.
9090
`Some(a)` => `a`
9191
`None` => `undefined`
9292

@@ -102,7 +102,7 @@ let from_opt: option<'a> => t<'a>
102102
let toOption: t<'a> => option<'a>
103103
```
104104

105-
Maps `Js.null_undefined('a)` to `option('a)`.
105+
Maps `Js.null_undefined<'a>` to `option<'a>`.
106106
`a` => `Some(a)`
107107
`undefined` => `None`
108108
`null` => `None`

pages/docs/manual/latest/api/js/string-2.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ let get: (t, int) => t
9797
```
9898

9999
`get(s, n)` returns as a `string` the character at the given index number.
100-
If `n` is out of range, this function returns `undefined`,so at some point this function may be modified to return `option(string)`.
100+
If `n` is out of range, this function returns `undefined`, so at some point this function may be modified to return `option<string>`.
101101

102102
```res example
103103
Js.String2.get("Reason", 0) == "R"

pages/docs/manual/latest/api/js/string.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ let get: (t, int) => t
9797
```
9898

9999
`get(s, n)` returns as a `string` the character at the given index number.
100-
If `n` is out of range, this function returns `undefined`, so at some point this function may be modified to return `option(string)`.
100+
If `n` is out of range, this function returns `undefined`, so at some point this function may be modified to return `option<string>`.
101101

102102
```res example
103103
Js.String2.get("Reason", 0) == "R"

pages/docs/manual/latest/api/js/undefined.mdx

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Local alias for 'a Js.undefined.
2020
let return: 'a => t<'a>
2121
```
2222

23-
Constructs a value of `Js.undefined('a)` containing a value of `'a`.
23+
Constructs a value of `Js.undefined<'a>` containing a value of `'a`.
2424

2525
## test
2626

@@ -65,7 +65,7 @@ let bind: (t<'a>, (. 'a) => 'b) => t<'b>
6565
```
6666

6767
Maps the contained value using the given function.
68-
If `Js.undefined('a)` contains a value, that value is unwrapped, mapped to a `'b` using the given function `a' => 'b`, then wrapped back up and returned as `Js.undefined('b)`.
68+
If `Js.undefined<'a>` contains a value, that value is unwrapped, mapped to a `'b` using the given function `a' => 'b`, then wrapped back up and returned as `Js.undefined<'b>`.
6969

7070
```res example
7171
let maybeGreetWorld = (maybeGreeting: Js.undefined<string>) =>
@@ -79,7 +79,7 @@ let iter: (t<'a>, (. 'a) => unit) => unit
7979
```
8080

8181
Iterates over the contained value with the given function.
82-
If `Js.undefined('a)` contains a value, that value is unwrapped and applied to the given function.
82+
If `Js.undefined<'a>` contains a value, that value is unwrapped and applied to the given function.
8383

8484
```res example
8585
let maybeSay = (maybeMessage: Js.undefined<string>) =>
@@ -92,7 +92,7 @@ let maybeSay = (maybeMessage: Js.undefined<string>) =>
9292
let fromOption: option<'a> => t<'a>
9393
```
9494

95-
Maps `option('a)` to `Js.undefined('a)`.
95+
Maps `option<'a>` to `Js.undefined<'a>`.
9696
`Some(a)` => `a`
9797
`None` => `empty`
9898

@@ -108,7 +108,7 @@ let from_opt: option<'a> => t<'a>
108108
let toOption: t<'a> => option<'a>
109109
```
110110

111-
Maps `Js.undefined('a)` to `option('a)`
111+
Maps `Js.undefined<'a>` to `option<'a>`
112112
`a` => `Some(a)`
113113
`empty` => `None`
114114

pages/docs/manual/latest/generate-converters-accessors.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ This option causes `jsConverter` to, again, generate functions of the following
130130
```resi
131131
let fruitToJs: fruit => int;
132132
133-
let fruitFromJs: int => option(fruit);
133+
let fruitFromJs: int => option<fruit>;
134134
```
135135

136136
For `fruitToJs`, each fruit variant constructor would map into an integer, starting at 0, in the order they're declared.

pages/docs/manual/latest/promise.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ export {
119119
120120
ReScript has built-in support for [JavaScript promises](api/js/promise). The 3 functions you generally need are:
121121

122-
- `Js.Promise.resolve: 'a => Js.Promise.t('a)`
123-
- `Js.Promise.then_: ('a => Js.Promise.t('b), Js.Promise.t('a)) => Js.Promise.t('b)`
124-
- `Js.Promise.catch: (Js.Promise.error => Js.Promise.t('a), Js.Promise.t('a)) => Js.Promise.t('a)`
122+
- `Js.Promise.resolve: 'a => Js.Promise.t<'a>`
123+
- `Js.Promise.then_: ('a => Js.Promise.t<'b>, Js.Promise.t<'a>) => Js.Promise.t<'b>`
124+
- `Js.Promise.catch: (Js.Promise.error => Js.Promise.t<'a>, Js.Promise.t<'a>) => Js.Promise.t<'a>`
125125

126126
Additionally, here's the type signature for creating a promise on the ReScript side:
127127

src/layouts/DocsLayout.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ let make = (
157157
}
158158

159159
module type StaticContent = {
160-
/* let categories: array(SidebarLayout.Sidebar.Category.t); */
160+
/* let categories: array<SidebarLayout.Sidebar.Category.t>; */
161161
let tocData: SidebarLayout.Toc.raw
162162
}
163163

@@ -171,7 +171,7 @@ module Make = (Content: StaticContent) => {
171171
~frontmatter=?,
172172
~version: option<string>=?,
173173
~availableVersions: option<array<(string, string)>>=?,
174-
/* ~activeToc: option(SidebarLayout.Toc.t)=?, */
174+
/* ~activeToc: option<SidebarLayout.Toc.t>=?, */
175175
~components: option<Mdx.Components.t>=?,
176176
~theme: option<ColorTheme.t>=?,
177177
~children: React.element,

src/layouts/DocsLayout.resi

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let make: (
1717
) => React.element
1818

1919
module type StaticContent = {
20-
/* let categories: array(SidebarLayout.Sidebar.Category.t); */
20+
/* let categories: array<SidebarLayout.Sidebar.Category.t>; */
2121
let tocData: SidebarLayout.Toc.raw
2222
}
2323

@@ -31,7 +31,7 @@ module Make: (Content: StaticContent) =>
3131
~frontmatter: Js.Json.t=?,
3232
~version: string=?,
3333
~availableVersions: array<(string, string)>=?,
34-
/* ~activeToc: option(SidebarLayout.Toc.t)=?, */
34+
/* ~activeToc: option<SidebarLayout.Toc.t>=?, */
3535
~components: Mdx.Components.t=?,
3636
~theme: ColorTheme.t=?,
3737
~children: React.element,

0 commit comments

Comments
 (0)