softwaremill / softwaremill/quicklens
Support generic type aliases that start with Option
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 852
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in the issue and trace the each extension and QuicklensFunctor instance lookup shown in the compiler error. Confirm the behavior for Option[Wrapper[String]], then verify that the OptWrap[T] alias case compiles and supports .each.value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100