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

Enum types #54

Open
thosakwe opened this issue Apr 22, 2018 · 3 comments
Open

Enum types #54

thosakwe opened this issue Apr 22, 2018 · 3 comments

Comments

@thosakwe
Copy link
Contributor

Enums by themselves would be anonymous. Typedefs would be used to provide access to these. To access specific fields, use the :: symbol.

type PromiseState = enum { pending, fulfilled, errored }
type Promise<T> = { state: PromiseState, value: T? }

fn doSomethingAsync<T>(value: T): Promise<T> => { value, state: PromiseState::fulfilled }
@thosakwe thosakwe mentioned this issue Apr 22, 2018
@tejainece
Copy link
Collaborator

Could this be a more compact syntax:

enum PromiseStat { pending, fulfilled, errored }

@thosakwe
Copy link
Contributor Author

That could definitely be doable, and wouldn’t be that hard to parse.

My only concern is consistency. Since all other types are declared with “type foo”, I think it would be smart to also declare enums in the same way.

@thosakwe
Copy link
Contributor Author

Remaining:

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

No branches or pull requests

2 participants