PlateMacro
Compile-time derivation of a dev.constructive.eo.optics.Plated for a recursive ADT S.
The derived plate focuses the immediate same-typed children of every case: each field whose declared type is exactly S (the "exact self-type" rule — List[S], Option[S], tuples of S, etc. are not descended in this version; their elements are leftover skeleton). For
enum Expr:
case Var(name: String) // 0 children
case App(f: Expr, x: Expr) // 2 children
case Lam(bind: String, body: Expr) // 1 child (bind:String is skeleton)
plate[Expr] gathers App's f/x and Lam's body, leaving Var.name / Lam.bind untouched. Works on Scala 3 enums, sealed hierarchies (via Hearth's Enum.parse), and plain recursive case classes (via CaseClass.parse). Reconstruction routes through CaseClass.construct[Id] (new V(...), never .copy), so enum cases reassemble fine.
children reads the self-typed fields in declaration order; rebuild swaps them back by the same declaration-order index, so the two agree without relying on construct's call order.
Attributes
- Source
- PlateMacro.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
PlateMacro.type