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

Refinement of tag unions #5504

Open
ayazhafiz opened this issue Jun 3, 2023 · 0 comments
Open

Refinement of tag unions #5504

ayazhafiz opened this issue Jun 3, 2023 · 0 comments
Labels
enhancement New feature or request intermediate issue Likely good for someone who has completed a few other issues type checking

Comments

@ayazhafiz
Copy link
Sponsor Member

We'd like to implement Union Refinement, a proposal to bring flow-typing-style semantics to Roc. This feature would allow typing code like

canRoleDo : [User, Admin, SuperAdmin] -> Bool
canRoleDo = \role -> when role is
  User -> ...
  other ->
    # here, `other` has type [Admin, SuperAdmin]

whereas the current implementation of Roc would type other as [User, Admin, SuperAdmin].

It's expected that this feature will provide a more natural feel to the behavior of tag unions, similar to how a developer may have experienced unions in other languages - particularly those with structural subtypes!

The full proposal and implementation description is provided in this document: https://rwx.notion.site/Union-Refinement-5bef5072afb84675948f89525a25dbb7. See also this Zulip ideas topic for discussion on the proposal: https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/Narrowing.20types.20in.20when.20expressions.

If you'd like to help out implementing this, please don't hesitate to reach out in the #contributing channel in the Roc Zulip!

@ayazhafiz ayazhafiz added enhancement New feature or request type checking intermediate issue Likely good for someone who has completed a few other issues labels Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request intermediate issue Likely good for someone who has completed a few other issues type checking
Projects
None yet
Development

No branches or pull requests

1 participant