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

Document Subtyping / Structural Typing / Type Coercion Operator (:>) #150

Open
ryyppy opened this issue Jan 1, 2021 · 1 comment
Open
Labels
help wanted Extra attention is needed manual

Comments

@ryyppy
Copy link
Member

ryyppy commented Jan 1, 2021

ReScript is internally using the object system within Js.t to allow structural typing.

e.g.

type user = { "name": string }

is expressed as Js.t < name : string >. This is kinda an implementation detail, but there are scenarios where you can use the :> operator to coerce between different object shapes explicitly.

e.g. x :> { . }

In ReScript lingo, we call Js.t<...> types Objects. Our current docs are covered in the Objects docs. Not sure if subtyping should be an advanced section here.

@ryyppy ryyppy added manual help wanted Extra attention is needed labels Jan 1, 2021
@ryyppy ryyppy changed the title Subtyping / Structural Typing / Type Coercion Operator (:>) Document Subtyping / Structural Typing / Type Coercion Operator (:>) Jan 1, 2021
@ryyppy ryyppy added this to the 2021 / January Release milestone Jan 3, 2021
@ryyppy
Copy link
Member Author

ryyppy commented May 7, 2021

Update: Js.t got irrelevant with v9.1... so the docs will be even simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed manual
Projects
None yet
Development

No branches or pull requests

1 participant