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
Here's the discussion on why it was added to OCaml: ocaml/ocaml#7583
The short summary is that it's seen as less of an addition and more of an omission that was necessitated by how type inference used to work. Since type-based disambiguation was introduced, there is no longer a strong practical reason for disallowing what's seen as a natural base case for variants.
The more practical use cases cited:
Since it is a natural base case for variants, many other languages and protocols support it, and it would make interaction with those more natural as well.
Combined with refutation cases (which also seem not to be supported syntactically in ReScript, but can also apply implicitly), empty variants can be used in place of type parameters that aren't needed to avoid having to cover unreachable cases by sprinkling assert(false) or the like everywhere.
I could definitely see myself using it as I think being able to show in type signatures that a type parameter, and therefore certain parts of an implementation, isn't used or needed is much clearer than hiding that in various parts of the implementation and comments.
I also think it fits quite naturally and the cost is small.
But it's also not something I've missed, so I certainly wouldn't make it much of a priority.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
zth commentedon Aug 28, 2024
What are the real world use cases for empty variants?
soanvig commentedon Sep 3, 2024
https://discuss.ocaml.org/t/empty-polymorphic-variant-type-use-case/8371/2
Very niche actually.
It resembles never type in TypeScript in some sense
glennsl commentedon Sep 5, 2024
Here's the discussion on why it was added to OCaml: ocaml/ocaml#7583
The short summary is that it's seen as less of an addition and more of an omission that was necessitated by how type inference used to work. Since type-based disambiguation was introduced, there is no longer a strong practical reason for disallowing what's seen as a natural base case for variants.
The more practical use cases cited:
assert(false)or the like everywhere.zth commentedon Sep 5, 2024
@glennsl what's your opinion on its usefulness for ReScript? Is it something you'd like to see supported?
glennsl commentedon Sep 5, 2024
I could definitely see myself using it as I think being able to show in type signatures that a type parameter, and therefore certain parts of an implementation, isn't used or needed is much clearer than hiding that in various parts of the implementation and comments.
I also think it fits quite naturally and the cost is small.
But it's also not something I've missed, so I certainly wouldn't make it much of a priority.
github-actions commentedon Sep 1, 2025
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.