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

Expose FunctionK.liftFunction as a part of the Scala 3 API #4600

Merged
merged 1 commit into from May 13, 2024

Conversation

pomadchin
Copy link
Member

This PR adds liftFunction into the Scala 3 API.

That would help us to remove FunctionKLift from cats-tagless and from a couple of other libraries. Right now I'm just borrowing this file around :D

Closes #4449

cc @joroKr21

@pomadchin pomadchin force-pushed the feature/scala3-functionK-lift-port branch 2 times, most recently from cf011ea to 237a489 Compare May 11, 2024 22:50
@pomadchin pomadchin force-pushed the feature/scala3-functionK-lift-port branch from 237a489 to baec5e0 Compare May 11, 2024 22:55
Copy link
Member

@joroKr21 joroKr21 left a comment

Choose a reason for hiding this comment

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

I'm onboard with this, it will help cross compiling.

Comment on lines +38 to +44
test("lift a function directly using Scala 2 compatible syntax") {
def headOption[A](list: List[A]): Option[A] = list.headOption
val fHeadOption = FunctionK.liftFunction[List, Option](headOption)
forAll { (a: List[Int]) =>
assert(fHeadOption(a) === a.headOption)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to note: I feel this test case should be extracted into a new test suite that would cross-compile for both Scala2 and Scala3. Looks like there's no such test suite available for FunctionK. We can do it in a separate follow up PR though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooh that's a good idea

Copy link
Contributor

@satorg satorg left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

@satorg satorg merged commit 6de2a67 into typelevel:main May 13, 2024
16 checks passed
@pomadchin pomadchin deleted the feature/scala3-functionK-lift-port branch May 13, 2024 01:55
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.

Expose FunctionK.liftFunction as a part of the Scala 3 API
3 participants