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

Scala 3 regression: derivation error for value classes #658

Open
yakivy opened this issue Mar 22, 2024 · 3 comments
Open

Scala 3 regression: derivation error for value classes #658

yakivy opened this issue Mar 22, 2024 · 3 comments

Comments

@yakivy
Copy link

yakivy commented Mar 22, 2024

"org.typelevel" %% "kittens" % "3.3.0"
import cats.derived._
case class MyString(value: String) extends AnyVal
semiauto.monoid[MyString]

this snippet compiles successfully on Scala 2.13, but fails on Scala 3:

No given instance of type cats.derived.DerivedMonoid[Playground.MyString] was found.
I found:

    cats.derived.DerivedMonoid.given_DerivedMonoid_A[Playground.MyString](
      shapeless3.deriving.K0.mkProductInstances[
        [A] =>> cats.derived.Derived.Or[cats.kernel.Monoid[A]], Playground.MyString]
        (
        /* missing */
          summon[shapeless3.deriving.K0.ProductGeneric[Playground.MyString]]
      )
    )

But Failed to synthesize an instance of type shapeless3.deriving.K0.ProductGeneric[Playground.MyString]: class MyString is not a generic product because it is a value class.

The following import might make progress towards fixing the problem:

  import cats.derived.DerivedMonoid.Strict.product

Scastie: https://scastie.scala-lang.org/DqVORi3bSU6rB8JM0PupHw

@joroKr21
Copy link
Member

Interesting, that might be an issue with Shapeless 3 or even Scala 3

@joroKr21 joroKr21 added the Bug label Mar 22, 2024
@joroKr21
Copy link
Member

Looks like Scala 3 behaviour

scala> summon[Mirror.Of[MyString]]
-- [E172] Type Error: ----------------------------------------------------------
1 |summon[Mirror.Of[MyString]]
  |                           ^
  |No given instance of type scala.deriving.Mirror.Of[MyString] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.Of[MyString]:
  |	* class MyString is not a generic product because it is a value class
  |	* class MyString is not a generic sum because it is not a sealed class
1 error found

@joroKr21
Copy link
Member

Looks like people tried and it didn't work: scala/scala3#7000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants