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

Allow tuples in untagged variants #6544

Closed
tsnobip opened this issue Jan 2, 2024 · 2 comments · Fixed by #6550
Closed

Allow tuples in untagged variants #6544

tsnobip opened this issue Jan 2, 2024 · 2 comments · Fixed by #6550
Assignees

Comments

@tsnobip
Copy link
Contributor

tsnobip commented Jan 2, 2024

Using tuples is a nice way to model heterogeneous arrays in rescript, but so far they're not allowed in unboxed/untagged variants, even though they're compiled to regular arrays in js, and arrays are allowed in untagged variants.

It'd be cool to add tuples to the allowed types in untagged variants.

See forum post for a use case.

We'd basically allow tuples and we'd check that only one variant case can be of type array or tuple.

@tsnobip tsnobip self-assigned this Jan 2, 2024
@glennsl
Copy link
Contributor

glennsl commented Jan 2, 2024

Related: #6277

@tsnobip
Copy link
Contributor Author

tsnobip commented Jan 4, 2024

Related: #6277

this is interesting, because indeed, we could solve the same issue by allowing objects to be compiled to arrays (it's likely much more work though), something like:

type t =
  | Foo({@as(0) foo: int, @as(1) bar: string})

tsnobip added a commit that referenced this issue Jan 6, 2024
@zth zth closed this as completed in #6550 Jan 7, 2024
zth pushed a commit that referenced this issue Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants