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

Bool as unboxed variant payload #6231

Closed
wants to merge 2 commits into from
Closed

Bool as unboxed variant payload #6231

wants to merge 2 commits into from

Conversation

zth
Copy link
Collaborator

@zth zth commented Apr 30, 2023

bool didn't seem to be implemented for unboxed variants. This PR is trying to enable this:

@unboxed type value = String(string) | Boolean(bool) | Number(float)

Not sure if this is correct, looking for some guidance @cristianoc .

@zth zth requested a review from cristianoc April 30, 2023 18:56
Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one subtle thing is when there's both a bool literal and "bool".
Just need to know it's been tested.

Second: as a user how do I know what types are supported? (Question about docs, or at these stage info that will go in the website: do we have enough reminders to not forget bool in the docs).

I think the code is very likely all correct as it's just one more pattern following the other patterns.

In terms of overlap, the one thing to double check is that this does not introduce any more overlap than the one mentioned above: bool literal and bool type.

@mununki
Copy link
Member

mununki commented May 1, 2023

If I may cautiously express an opinion, I think it might be a bit different from String and IntNumber. Representing an infinite cardinality of strings as String(string) and the possible cases of integersfloats as Int(int)Number(float) has meaning as an ADT. However, having Bool(bool) with the cardinality of 2, i.e., true | false, seems to have no difference from expressing it with bool literals, so defining it as an ADT might be a bit confusing for users.

@cristianoc
Copy link
Collaborator

cristianoc commented May 1, 2023

I think the idea is to make both expressible.
The question is: is it worth it?

Not 100% sure of the answer.

@zth
Copy link
Collaborator Author

zth commented May 1, 2023

I think it's confusing to allow strings and numbers but not booleans, purely from a "this is what I'd expect as an end user" perspective. Even if it's expressible with the two cases, they both require using as-annotations and adding them both explicitly to cover the bool case. Feels like an odd technicality when the relation a JS dev has to string/number/bool are that they're all primitives, not whether they conceptually fit 100% into an ADT or not.

I'm of course fine with not having it if other's don't agree. We can also just wait and see if this confusion surfaces organically.

@cristianoc
Copy link
Collaborator

I'm excited for the possibility of involving an AI arbiter if we can't reach a consensus!

@zth
Copy link
Collaborator Author

zth commented May 1, 2023

If we can't reach consensus we should just wait for this to potentially surface as an issue from the community. After all this is my "hunch" and it might or might not be correct.

@zth
Copy link
Collaborator Author

zth commented May 21, 2023

Closing this, can re-open if need surfaces organically.

@fhammerschmidt
Copy link
Member

I think this one is worth it as well. Not only because the user expects it, but the handling is a bit nicer if I don't need to convert between True and true and just use the payload of Bool(bool).

@zth zth deleted the unboxed-bool branch January 27, 2024 19:56
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.

4 participants