Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensible variants are undocumented #4869

Closed
ersinakinci opened this issue Dec 14, 2020 · 1 comment
Closed

Extensible variants are undocumented #4869

ersinakinci opened this issue Dec 14, 2020 · 1 comment

Comments

@ersinakinci
Copy link

ersinakinci commented Dec 14, 2020

I encountered the following code in the wild:

type thunk('state) = ..;

type ReduxThunk.thunk(_) +=
  | StringAction (stringAction)
  | CounterAction (action);

This code essentially creates an "extensible variant" called thunk and adds two constructors to it. I'm not certain whether I'm using the right term to explain this feature since it's not described anywhere in the ReasonML or ReScript docs. It should be.

The ReScript docs also don't explain .., which is an elision, which is documented in ReasonML's docs on open objects. ReScript's docs don't talk about open objects at all, let alone elisions, but both sets of docs omit the fact that you can apparently use elisions to define extensible variants.

The use of the += feature isn't described anywhere in either set of docs, either.

It would be great to describe all these features, and while we're at it it would be great to have ReScript docs on polymorphic variants and how they differ from this kind of extensible non-polymorphic variant.

@bobzhang
Copy link
Member

moved to the doc site

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants