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

Create Empty from EmptyK #4714

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

joan38
Copy link
Contributor

@joan38 joan38 commented Feb 16, 2025

This is solving the case where we have an instance of Empty[T] but looking for a Empty[Option[T]]:
https://scastie.scala-lang.org/Jv24ybPQRQeQ2IEZy5azmA

@reardonj
Copy link
Contributor

Fixes #3617

@joan38
Copy link
Contributor Author

joan38 commented Feb 16, 2025

The tests seem flaky, I think we need a maintainer to rerun only the failed ones

@@ -38,7 +38,7 @@ object Empty extends EmptyInstances0 {
def apply[A](a: => A): Empty[A] =
new Empty[A] { lazy val empty: A = a }

def fromEmptyK[F[_], T](implicit ekf: EmptyK[F]): Empty[F[T]] = ekf.synthesize[T]
implicit def fromEmptyK[F[_], T](implicit ekf: EmptyK[F]): Empty[F[T]] = ekf.synthesize[T]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm worried making this implicit here may create resolution issues. It can certainly change the resolution order. For instance, currently at EmptyInstances0 extends compat.IterableEmptyInstance so the change in this PR will put an EmptyK instance ahead of anything there.

It's hard to say if this is bad or not, because this is a lawless typeclass which is in alleycats. I'm more concerned with the possibility of something compiling that didn't previously due to ambiguous implicit resolution.

I would feel safer to me if we add an EmptyInstances2 which EmptyInstances1 extends and put this implicit there (although, we may or may not need to just add a new function rather than move this function because of MIMA concerns).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed with your suggestion.
MIMA should tell us if it's not ok to move the function right?

Copy link
Contributor Author

@joan38 joan38 Feb 19, 2025

Choose a reason for hiding this comment

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

@armanbilge could you rerun the failing test runs please? :)

@rossabaker
Copy link
Member

Error was:

  [error] Test runner interrupted by fatal signal 11
  [warn] Force close java.lang.RuntimeException: Process /home/runner/work/cats/cats/tests/native/target/scala-2.13/cats-tests-test finished with non-zero value 139 (0x8b)

Rerunning.

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.

4 participants