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

Support generic type aliases that start with Option #208

Open
Avat-h opened this issue Dec 6, 2023 · 2 comments
Open

Support generic type aliases that start with Option #208

Avat-h opened this issue Dec 6, 2023 · 2 comments

Comments

@Avat-h
Copy link

Avat-h commented Dec 6, 2023

Let's consider case class containing optional wrapped generic field:

  case class Wrapper[T](value: T)
  case class X(f1: Option[Wrapper[String]])
  val x = X(Option(Wrapper("test")))
  modify(x)(_.f1.each.value).using(duplicate)

It works correctly.

But if we define generic type alias like that:

  case class Wrapper[T](value: T)
  type OptWrap[T] = Option[Wrapper[T]]
  case class X(f1: OptWrap[String])
  val x = X(Option(Wrapper("test")))
  modify(x)(_.f1.each.value).using(duplicate)

then it fails to compile with error:

value each is not a member of ModifyEachTest.this.OptWrap[String].
An extension method was tried, but could not be fully constructed:

    com.softwaremill.quicklens.each[[T] =>> Option[ModifyEachTest.this.Wrapper[T]],
      String](_$8.f1)(
      com.softwaremill.quicklens.QuicklensFunctor.given_QuicklensFunctor_M[K, M])

    failed with:

        No given instance of type com.softwaremill.quicklens.QuicklensFunctor[
          [T] =>> Option[ModifyEachTest.this.Wrapper[T]]] was found for an implicit parameter of method each in package com.softwaremill.quicklens.
        I found:
        
            com.softwaremill.quicklens.QuicklensFunctor.given_QuicklensFunctor_M[K, M]
        
        But given instance given_QuicklensFunctor_M in object QuicklensFunctor does not match type com.softwaremill.quicklens.QuicklensFunctor[
          [T] =>> Option[ModifyEachTest.this.Wrapper[T]]].
  modify(x)(_.f1.each.value).using(duplicate)

Is it possible to support such cases in quicklens?

@adamw
Copy link
Member

adamw commented Dec 6, 2023

This is Scala 3, right? I'd be guessing we're missing a .dealias somewhere, but I might be wrong ...

@Avat-h
Copy link
Author

Avat-h commented Dec 6, 2023

Both scala 3 and 2.13. I think it's not macro-related, but QuicklensFunctor must be defined differently. I tried to add such QuicklensFunctor implementation but failed.

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

No branches or pull requests

2 participants