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

Tagged unions with tag-only members #756

Closed
emil14 opened this issue Nov 9, 2024 · 1 comment
Closed

Tagged unions with tag-only members #756

emil14 opened this issue Nov 9, 2024 · 1 comment

Comments

@emil14
Copy link
Collaborator

emil14 commented Nov 9, 2024

Mixed

This will allow to have maybe as a union

type maybe<T> union {
    Some T
    None
}

And maybe will simplify/improve design for #747 because it's no longer special case

Tag-only

Since it's possible to have tag-only members, it's possible to have tag-only unions

type Weekdays union {
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
}

Tags are (most likely) gonna be represented with 1-byte integers, same as enums. This is basically 2 ways of doing the same thing

This is kinds the same thing value unions in TypeScript (despite better memory consumption):

type Weekdays = 'Monday'
    | 'Tuesday'
    | 'Wednesday'
    | 'Thursday'
    | 'Friday'

Naming?

This is basically what's called "enums" in Rust. I don't like that name, honestly, since it's more related to C-like enums to me, but we'll see.

@emil14 emil14 added the Major label Nov 9, 2024
This was referenced Nov 9, 2024
@emil14 emil14 moved this to In Progress in Nevalang Project Dec 19, 2024
@emil14 emil14 moved this from In Progress to Todo in Nevalang Project Dec 21, 2024
@emil14 emil14 moved this from Todo to In Progress in Nevalang Project Jan 5, 2025
@emil14 emil14 moved this from In Progress to Todo in Nevalang Project Jan 6, 2025
@emil14 emil14 moved this from Todo to In Progress in Nevalang Project Jan 11, 2025
@emil14
Copy link
Collaborator Author

emil14 commented Jan 11, 2025

Should be part of #751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant