Skip to content

Conversation

@matt-cornell
Copy link
Collaborator

These are tagged enums and unions. They're basically the same, the only difference is that unions have a sorted order, so @union | a | b and @union | b | a are the same type, while @enum | a | b and @enum | b | a are not.
These take place at the type level, and are made to be used with symbols. For example, a unit enum can be created like this:

const my_unit_enum = @enum
| $value1
| $value2
| $value3;

With this, enums with fields can also be created:

const my_field_enum = @enum
| ($int, i64)
| ($float, f64);

@matt-cornell matt-cornell self-assigned this Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants