Skip to content

Commit b5cd518

Browse files
committed
Small adaptions / fixing typos
1 parent 08ac6ad commit b5cd518

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pages/docs/manual/latest/polymorphic-variant.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,15 +412,14 @@ In case you want to define a type that is extensible in polymorphic ways (or in
412412

413413
A lower bound defines the minimum set of constructors a poly variant type is aware of. It is also considered an "open poly variant type", because it doesn't restrict any additional values.
414414

415-
Here is an example on how to make a minimum set of `basicBlueTones` extensible for a new `colors` type:
415+
Here is an example on how to make a minimum set of `basicBlueTones` extensible for a new `color` type:
416416

417417
```res
418418
type basicBlueTone<'a> = [> #Blue | #DeepBlue | #LightBlue ] as 'a
419419
type color = basicBlueTone<[#Blue | #DeepBlue | #LightBlue | #Purple]>
420420
421421
let color: color = #Purple
422422
423-
424423
// This will fail due to missing minimum constructors:
425424
type notWorking = basicBlueTone<[#Purple]>
426425
```
@@ -447,9 +446,9 @@ type notWorking = validRed<[#Purple]>
447446

448447
One might think that polymorphic variants are fastly superior to common [variants](./variant). As always, it depends on the use case:
449448

450-
- Variants allows better encapsulation for your APIs, since they require you to define a type definition that is coupled to a specific module.
449+
- Variants allow better encapsulation for your APIs, because they always come with a type definition that is coupled to a specific module.
451450
- Variants are conceptionally easier to understand, makes your code easy to refactor and provides better exhaustive pattern matching support
452451
- Variants usually deliver better type error messages, especially in recursive type definitions
453452
- Poly variants are useful for expressing strings in JS, and allow different type composition strategies. They can also be defined adhocly in your type definitions.
454453

455-
In most scenarios, we'd recommend to use common variants over polymorphic variants, especially when you are writing plain ReScript code. In case you want to write zero-cost interop bindings, poly variants are a better option.
454+
In most scenarios, we'd recommend to use common variants over polymorphic variants, especially when you are writing plain ReScript code. In case you want to write zero-cost interop bindings or generate clean JS output, poly variants are oftentimes a better option.

0 commit comments

Comments
 (0)