Project

dev.constructive.eo.optics.Project
trait Project[F[_], S]

The user-supplied bridge between a recursive type S and one layer of its pattern functor F[_] — the correspondence the typed recursion schemes (cata / ana / hylo, in the schemes module) and the Plated.fromBasis derivation are built on.

A pattern functor replaces S's recursive positions with a type parameter:

 enum Bin:        case Leaf(n: Int);  case Branch(l: Bin, r: Bin)
 enum BinF[A]:    case LeafF(n: Int); case BranchF(l: A,  r: A)   // recursion → A

Project peels one layer off (S => F[S]), Embed glues one layer back on (F[S] => S). A driver then walks F with the user's Traverse[F], so algebras pattern-match F's named constructors (case BranchF(l, r) => l + r) instead of indexing an erased vector.

Unlike the F type itself (which the user must write — Scala-3 macros emit terms, not type definitions), Project/Embed are ordinary instances, expected hand-written (droste's model).

'''Coherence laws''' (the S↔F correspondence is hand-maintained and NOT compiler-checked — a swapped or non-exhaustive mapping is a silent bug, so these are exercised by the typed-scheme law suite):

 embed(project(s)) == s          // round-trip through one layer of S
 project(embed(fs)) == fs        // round-trip through one layer of F

Attributes

Source
Basis.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Basis[F, S]

Members list

Value members

Abstract methods

def project(s: S): F[S]

Peel one layer: expose S's immediate children as F's recursive slots.

Peel one layer: expose S's immediate children as F's recursive slots.

Attributes

Source
Basis.scala