-
Notifications
You must be signed in to change notification settings - Fork 111
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
experiment: make type system more nominal #711
Conversation
Teal Playground URL: https://711--teal-playground-preview.netlify.app |
dfbe151
to
80723dc
Compare
Instead of treating nominal records nominally and all other nominal types structurally, with this commit we treat all nominal types nominally except for unions, which are treated structurally. Give this branch a try in your codebase and let me know your impressions!
What is the benefit of having a more nominal type system? I am quite new to type theory |
@Frityet The two main approaches for type system are: structural or nominal. Structural type systems are like static duck typing: you compare the shapes of data, and if the shapes fit, the types are compatible. Nominal type systems instead, compare names: if you give things the same names, they're the same, if you give them different names, they're different. Nominal systems can be easier to reason about, and avoid accidental compatibility when different things that aren't meant to be the same end up compatible just because they have the same shape. In practice, as you combine features such as subtyping and generics, both of them get very complicated. Even in nominal type systems, if you have generics where the type variables support subtyping, that is proven to be computationally undecidable (that means it's mathematically impossible to make a compiler for them that always works!) For more of the motivations of this PR, please take a look at the discussion at #708 |
Nice! Thank you, the PR worlds great for me |
@Frityet Added these changes to the |
Cheers! I was trying out that branch a few weeks ago, and it is extremely promising! |
Instead of treating nominal records nominally and all other nominal types structurally, with this commit we treat all nominal types nominally except for unions, which are treated structurally.
Give this branch a try in your codebase and let me know your impressions!
[Marked as "draft" because I do not intend to merge this as-is, as there are no test cases for the different behaviors, etc.]