-
Notifications
You must be signed in to change notification settings - Fork 89
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
[Feature] union type #442
Comments
It depends on whether you want (i) any combination of types, or (ii) just nullable/optional types. I can't see much use for the former, because the operations you can perform on multiple types are limited, basically just If the latter, you might consider allowing a question mark at the end of the type, like C# and Kotlin; so |
any combination of types. question mark after type is already taken, it means that it is fallible |
okay so there has been some controversy about how union types should be equal to other types and each other. i think we should do it like this:
|
Here's how I see this: The union type must function just like the Failable and Generic Array types in #472. This means that:
Additionally, the union type must not allow failable types as part of the union. The union type itself must be failable, instead. Otherwise it won't come together with the error handling logic. The groundwork for the subset logic is already laid out in #472, which I intend to merge before this one. Then you will have to put your union logic on top of it. |
how would it work that the whole union is failable, from the syntax point of view? do we just assert that all types in union are either failable or non failable? or something like |
i assume that you mean in the function arguments, right? |
i think that any singular type can be automatically converted to union with the same type in there |
I'm not exactly sure how the syntax should look, but it should probably be
Yes.
We must not convert any types. The compiler has to keep track of the actual types, so that the |
we could also change failables to |
The
because |
i have a feeling that failable types should not be implemented as types, but rather as a function modifier, like:
|
This is a whole word more verbose than the
That's also quite verbose. |
One idea is that we could move the
|
Question mark right after a word makes it a bit funny to read, lol. Reads like a question. |
so what is your point being? |
The point is that none of them is any better than the
The |
we should discuss failable types further in #478 |
Is your feature request related to a problem? Please describe.
this type definition is valid in typescript:
i'd love to be able to do the same in amber
Describe the solution you'd like
Describe alternatives you've considered
Generic types, but.. meh
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: