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

Arbitrary arity tuple #435

Merged
merged 11 commits into from
May 22, 2024
Merged

Conversation

Primetalk
Copy link
Contributor

Fixes #411

Problem

To support Scala 3-style tuples, a few changes are needed:

  • support at Quat level;
  • decode to Scala 3 tuples;
  • support pattern matching inside quotes;
  • tuple construction (*:) inside quotes.

Solution

So far Quat and decoding are implemented.

There are two variants of decoding:

  • using recursive approach;
  • using runtime.Tuples.fromIArray.

The latter might be more performant.

Checklist

  • Unit test all changes
  • Update README.md if applicable
  • Add [WIP] to the pull request title if it's work in progress
  • Squash commits that aren't meaningful changes

@getquill/maintainers

@CLAassistant
Copy link

CLAassistant commented Apr 15, 2024

CLA assistant check
All committers have signed the CLA.

@Primetalk Primetalk force-pushed the arbitrary-arity-tuple branch 2 times, most recently from a62ad2a to a2f11a1 Compare April 15, 2024 06:53
@Primetalk Primetalk marked this pull request as ready for review May 7, 2024 20:31
@Primetalk Primetalk changed the title [WIP] Arbitrary arity tuple Arbitrary arity tuple May 7, 2024
'{EmptyTuple}
} else if (tpe <:< TypeRepr.of[Tuple]) {
'{scala.runtime.Tuples.fromIArray(IArray(${Varargs(terms)})).asInstanceOf[T]}
// Alternative version:
Copy link
Member

Choose a reason for hiding this comment

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

Why keeping commented code? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to consult which version is preferred - array based or recursion-based.

t match {
case
Inlined(
// Some(Apply(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Question: should we also match on call part or is it enough to match just the body?

@deusaquilus
Copy link
Contributor

This is really amazing work! Thank you!

@deusaquilus deusaquilus merged commit 4a336ec into zio:master May 22, 2024
5 checks passed
@Primetalk Primetalk deleted the arbitrary-arity-tuple branch May 29, 2024 08:40
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.

Arbitrary long Tuples (*:) produce Quat.Generic instead of Quat.Product
4 participants