Skip to content

Support generic type aliases that start with Option #208

@Avat-h

Description

@Avat-h

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions