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

Add experimental TupledFunction #14414

Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Feb 4, 2022

This reverts commit f4e1ca4.

Originally added in #6568.

@nicolasstucki nicolasstucki self-assigned this Feb 4, 2022
@nicolasstucki nicolasstucki force-pushed the add-experimental-tupled-functions branch from 2ddc6dd to 0b91d4e Compare February 4, 2022 09:59
@nicolasstucki nicolasstucki changed the title Add experimental TupleFunction Add experimental TupledFunction Feb 4, 2022
@nicolasstucki nicolasstucki force-pushed the add-experimental-tupled-functions branch from 4542aef to bcc5474 Compare February 14, 2022 14:10
@nicolasstucki
Copy link
Contributor Author

We should also revisit #14138 once this is merged.

@nicolasstucki nicolasstucki force-pushed the add-experimental-tupled-functions branch 2 times, most recently from f0dd2f5 to 64cee08 Compare February 28, 2022 08:29
@milessabin
Copy link
Contributor

Does this generalize to polymorphic functions?

Ie. given [a, b] => (a, b) => C we should be able to get to [a, b] => ((a, b)) => C.

@nicolasstucki
Copy link
Contributor Author

Does this generalize to polymorphic functions?
Ie. given [a, b] => (a, b) => C we should be able to get to [a, b] => ((a, b)) => C.

My intuition tells me it is possible. The interface has nothing that depends on normal lambdas. The compiler should be able to synthesize TupledFunction[[a, b] => (a, b) => C, [a, b] => ((a, b)) => C] as it does for any supported function type. Then we would need to add the erased implementation for those instances or use the ones that are already defined.

@milessabin do you have a concrete where this would be useful?

This reverts commit f4e1ca4.

Also makes TupledFunction experimental
@nicolasstucki nicolasstucki force-pushed the add-experimental-tupled-functions branch from 64cee08 to 4b0906d Compare February 28, 2022 15:50
@milessabin
Copy link
Contributor

@nicolasstucki yes, I do ... various higher-kinded transformations.

But also, more generally, it'd be good to keep parity between monomorphic and polymorphic functions wherever possible.

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Mar 3, 2022

@nicolasstucki yes, I do ... various higher-kinded transformations.

@milessabin could you share a couple of representative examples to include in tests?

@nicolasstucki nicolasstucki marked this pull request as ready for review March 7, 2022 08:50
@nicolasstucki
Copy link
Contributor Author

We should probably start with the non-polymorphic version and extend it later. I do not have time right now to implement the extension. If we have the current version as experimental library authors could start experimenting with it and provide feedback.

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

Are dependent functions supported? e.g. (x: Int, y: Int) => List[x.type]

@nicolasstucki
Copy link
Contributor Author

Are dependent functions supported? e.g. (x: Int, y: Int) => List[x.type]

Not sure. I would have to double-check and possibly improve later.

That would mean the tupled version of the function is (args: (Int, Int)) => List[args._1.type]. This might not scale to functions larger than 22 as we do not have the _N stable paths.

@nicolasstucki nicolasstucki added the release-notes Should be mentioned in the release notes label Mar 24, 2022
@nicolasstucki nicolasstucki merged commit cb824bf into scala:main Mar 24, 2022
@nicolasstucki nicolasstucki deleted the add-experimental-tupled-functions branch March 24, 2022 12:15
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes Should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants