Skip to content

Add Tuple.fromProduct #6514

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

Merged
merged 2 commits into from
May 16, 2019
Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented May 15, 2019

Based on #6510

@nicolasstucki nicolasstucki force-pushed the add-tuple-fromProduct branch from b802640 to d7aa95e Compare May 16, 2019 05:38
@nicolasstucki nicolasstucki marked this pull request as ready for review May 16, 2019 06:27
@nicolasstucki nicolasstucki requested a review from liufengyun May 16, 2019 06:27
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1,47 @@
import scala.reflect.ClassTag
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: this is not required, I guess

// FIXME ProductN for N > 22 does not extends product
// testProduct((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23))
// testProduct((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24))
// testProduct((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25))
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be an oversight, I made the following changes, it seems to work:

-sealed class *:[+H, +T <: Tuple] extends NonEmptyTuple
+sealed abstract class *:[+H, +T <: Tuple] extends NonEmptyTuple with Product

/cc: @odersky

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'm looking into it as well. But this might not be what we want. The methods on product should also be specialized. For example productArity should do exactly the same as size.

Then there is the same issue for Tuple in general, not only non empty tuples. There the additional complete cation is that Unit is not a product.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Unit probably should be a Product :-)

@liufengyun liufengyun merged commit 49f254a into scala:master May 16, 2019
@liufengyun liufengyun deleted the add-tuple-fromProduct branch May 16, 2019 08:35
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.

3 participants