optics-dev / optics-dev/Monocle

Ambient `opaque type` breaks `MkFocus`

Open
#1,306 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Scala
Stars
1.7k
Forks
207
Avg merge
7h 59m
Merged PRs (30d)
5

Description

//> using scala "3.2.0"
//> using lib "dev.optics::monocle-macro::3.1.0"

trait Qux

object Foo {

  opaque type Bar = Qux

  case class Baz(id: String)
  object Baz {
    implicit val bazId: monocle.Lens[Foo.Baz, String] = new monocle.Focus.MkFocus[Foo.Baz].apply(_.id)
  }

}
[error] ./bug.scala:12:57: Found:    monocle.PIso[?1.CAP, ?2.CAP, String, String]
[error] Required: monocle.Lens[Foo.Baz, String]
[error] 
[error] where:    ?1 is an unknown value of type scala.runtime.TypeBox[Nothing, Foo.type{Bar = Qux}#Baz]
[error]           ?2 is an unknown value of type scala.runtime.TypeBox[Nothing, Foo.type{Bar = Qux}#Baz]
[error]     implicit val bazId: monocle.Lens[Foo.Baz, String] = new monocle.Focus.MkFocus[Foo.Baz].apply(_.id)
[error]                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the standalone Scala snippet and its Scala 3.2.0 and monocle-macro 3.1.0 directives. Start by inspecting monocle.Focus.MkFocus and the generated optic type around apply(_.id); done means the example compiles with the declared Lens[Foo.Baz, String] type.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.