This is a RFC for a feature we could put in a new major of RescriptRelay. Think of it as a "RescriptRelay 2.0", where we have more wiggle room to introduce breaking changes.
Much better error messages thanks to variants being nominal.
Will allow us to propagate comments/docs from the schema to the union members.
Will let us get rid of a lot of the complexity behind the scenes, because this would let us avoid having to do deep conversion back and forth of runtime values, because the above will match the runtime representation a lot better by default.
Con's:
The name of the enum value might not 100% correspond to the one in the schema, because of the naming rules for variants.
Can't think of one now, but I'm sure one could dig up benefits from polyvariants being structural rather than nominal.
As for migration, we'll need to figure out a good way to allow easy migration from the old to the new representation. This is of course a top priority and while publishing this under a new major RescriptRelay 2.0, I'd never just push out stuff without having a clear idea of how to migrate to it as easily as possible.
What are your thoughts on the above?
If there's anything unclear in the points I make, please feel free to ask and I'll clarify.
ReScript v11 will allow customizing the runtime representation of regular variants. This means we'll be able to easily move from polyvariants to regular variants for unions.
What as previously:
Would now be:
Pro's:
As for migration, we'll need to figure out a good way to allow easy migration from the old to the new representation. This is of course a top priority and while publishing this under a new major RescriptRelay 2.0, I'd never just push out stuff without having a clear idea of how to migrate to it as easily as possible.
What are your thoughts on the above?
If there's anything unclear in the points I make, please feel free to ask and I'll clarify.