You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support @as("foo") to customize the representation of tags. (#6095)
* Emit tags as strings.
* Allow more general type for tags.
Compile is_tag to `!== "object"` instead of `=== "string"`.
* Do not special case variants with only 1 case with payload.
Also the comment is not emitted anymore, since there's always a tag.
Not special casing means that the representation is uniform, and does not change when the type is extended. This is important with zero cost ffi, where the runtime representation is exposed to the user, to reduce possible surprises.
* Support @as("foo") to customize the representation of tags.
* Cleanup: chatgpt's suggestion
* Add support for custom representation of the form `@as(12)`
* Add null, undefined, unboxed customization.
null and undefined can only be applied to cases with no payloads
unboxed can only be applied when there is exactly one case with payloads, and that case takes exactly one argument
Some of those checks are possible statically. Not all of them are implemented.
Some checks cannot if one wants to have user-level nullable, null, undefined types with pattern matching. E.g. null type could take null as an argument.
* Add tagged unions example from chatgpt.
* Use custom tags.
* Remove unused set_tag from compiler internals.
* Add support for @tag(...) to customize the property used for the tag.
* Document places needing restriction.
* Add support for @as(true) and @as(false)
- Customization of runtime representation of variants. This is work in progress. E.g. some restrictions on the input. See comments of the form "TODO: put restriction on the variant definitions allowed, to make sure this never happens". https://github.com/rescript-lang/rescript-compiler/pull/6095
0 commit comments