LensMacro

dev.constructive.eo.generics.LensMacro
object LensMacro

Compile-time derivation of a Lens (or Iso on full coverage) from one or more case-class accessors.

case class Person(age: Int, name: String)

val ageL = lens[Person](_.age)                // SimpleLens, complement = remaining fields NT
val asTuple = lens[Person](_.name, _.age)     // BijectionIso (full cover)
  • Single-selector, partial cover → SimpleLens[S, A, XA] with XA the structural complement (gives transform / place / transfer for free).
  • Multi-selector, partial cover → SimpleLens with NamedTuple focus (SELECTOR order) and NamedTuple complement (DECLARATION order among non-focused fields).
  • Full cover at any arity → BijectionIso[S, S, NT, NT].

Constructor synthesis routes through Hearth's CaseClass.parse[S] + construct[Id], so parameterised / recursive types and Scala 3 enum cases (which lack .copy) work uniformly via new S(...).

Attributes

Source
LensMacro.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
LensMacro.type

Members list

Value members

Concrete methods

def deriveMultiImpl[S](selectorsExpr: Expr[Seq[S => Any]])(using evidence$1: Type[S], q: Quotes): Expr[Optic[S, S, _, _, _[_, _]]]

Quoted-macro implementation behind the package-level lens[S](…) entry (spliced directly by PartiallyAppliedLens.apply) — instantiates the Hearth-backed derivation against the call-site Quotes.

Quoted-macro implementation behind the package-level lens[S](…) entry (spliced directly by PartiallyAppliedLens.apply) — instantiates the Hearth-backed derivation against the call-site Quotes.

Attributes

Source
LensMacro.scala