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

Encode string enums as polymorphic variants #7

Open
TheSpyder opened this issue May 31, 2021 · 1 comment
Open

Encode string enums as polymorphic variants #7

TheSpyder opened this issue May 31, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@TheSpyder
Copy link
Owner

This is a relatively recent feature of ReScript, and will replace the variant-based code that requires runtime functions, for example:
https://github.com/tinymce/rescript-webapi/blob/0c9e9211785852e69f2d2a17c765e63c5697217f/src/Webapi/Dom/Webapi__Dom__Element.re#L76-L86

@TheSpyder
Copy link
Owner Author

TheSpyder commented May 31, 2021

In fact really what I'm talking about is replacing most of (if not all) of DomTypes with polymorphic variants.
https://github.com/tinymce/rescript-webapi/blob/main/src/Webapi/Dom/Webapi__Dom__Types.re

If we switch to ReScript syntax we can even use numbers as poly variants in the most recent release.
[edit] that's a bad idea because the whole point of variant encoded types is to use names, not numbers.

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

No branches or pull requests

2 participants