Review

dev.constructive.eo.optics.Review
See theReview companion object
final class Review[T, B](build: B => T) extends Optic[Unit, T, Unit, B, Direct], CanReverseGet[T, B]

Reverse-only counterpart to Getter — wraps reverseGet: A => S and is the exact mirror of Getter. Getter is Optic[S, Unit, A, Unit, Direct] (a real to reading S => A, vestigial from); Review is the dual Optic[Unit, S, Unit, A, Direct] — a vestigial to (reads Unit) and a real from that builds S from the focus A.

It therefore IS an Optic — with source Unit the to is exactly as vestigial as Getter's from, so "pure Review has no to" is no reason to sit outside the trait. A Review composes with another Review through the fused andThen just as Getters do, and slots into the Direct-carrier optic surface.

A final class storing reverseGet directly — NOT an abstract class with an abstract member — for the same composed-dispatch reason documented on Getter.

To get the build direction out of an Iso or Prism, wrap its reverse directly — Review(iso.reverseGet) / Review(prism.mend) — rather than via a bespoke factory: an Iso/Prism already is a build direction, so cross-optic from* constructors would be redundant (eo has no Prism.fromIso etc. for the same reason).

Review builds from ONE focus; its many-rung sibling is Unfold (assemble a T from an F-layer of parts), reachable by composition through the fused andThen(Unfold) below.

Attributes

Companion
object
Source
Review.scala
Graph
Supertypes
trait CanReverseGet[T, B]
trait Optic[Unit, T, Unit, B, Direct]
class Object
trait Matchable
class Any

Members list

Grouped members

Operations

inline def cross[C, D](o: Optic[T, Unit, C, D, Direct])(using Accessor[Direct], ReverseAccessor[Direct]): Optic[B, Unit, C, D, Direct]

Build-then-observe across the build-output ⇄ read-input seam, preserving structure, on a shared carrier F. Flip self (it must be reversible — Accessor[F] and ReverseAccessor[F], i.e. an Iso or Review over Direct) so it reads T from B, then andThen that under the same carrier. The result is the full Optic[B, A, C, D, F], not a collapsed getter: its read capability follows the carrier (.get for Direct), and self's read focus A survives as the composite's write-back focus.

Build-then-observe across the build-output ⇄ read-input seam, preserving structure, on a shared carrier F. Flip self (it must be reversible — Accessor[F] and ReverseAccessor[F], i.e. an Iso or Review over Direct) so it reads T from B, then andThen that under the same carrier. The result is the full Optic[B, A, C, D, F], not a collapsed getter: its read capability follows the carrier (.get for Direct), and self's read focus A survives as the composite's write-back focus.

This is exactly self.reverse.andThen(that). The motivating case is ana.cross(cata): a Review (the unfold) crossed with a getter on the built S (the fold) — a (materializing) hylomorphism whose .get reads the folded value. When that sits on a different carrier (a Prism, a Fold, …), the cross-carrier cross overload below is selected instead.

Seam: that's source is self's T and its back-type is self's S.

Attributes

Inherited from:
Optic
Source
Optic.scala

Type members

Types

type X = Nothing

Existential leftover carried alongside the focus — the type-level witness the carrier uses to rebuild T. Concrete at construction (Lens.apply sets X = S, Prism.apply sets X = S, …) and abstract when the optic is bound to Optic[…, F] without refinement.

Existential leftover carried alongside the focus — the type-level witness the carrier uses to rebuild T. Concrete at construction (Lens.apply sets X = S, Prism.apply sets X = S, …) and abstract when the optic is bound to Optic[…, F] without refinement.

Attributes

Source
Review.scala

Value members

Concrete methods

inline def andThen[D](inner: Review[B, D]): Review[T, D]

Fused Review.andThen(Review) — the build-direction mirror of Getter.andThen. this builds S from A, inner builds A from B, so the composite builds S from B (reverseGet ∘ inner.reverseGet). inline so each composition splices a distinct per-level lambda, sidestepping C2's recursive-inlining cap — the same reason Getter.andThen is inline.

Fused Review.andThen(Review) — the build-direction mirror of Getter.andThen. this builds S from A, inner builds A from B, so the composite builds S from B (reverseGet ∘ inner.reverseGet). inline so each composition splices a distinct per-level lambda, sidestepping C2's recursive-inlining cap — the same reason Getter.andThen is inline.

Attributes

Source
Review.scala
inline def andThen[G[_, _], D](inner: Optic[_, B, _, D, G])(using ReverseAccessor[G]): Review[T, D]

Build-only outer ∘ ANY reversible inner — only the inner's build half is used (reverseGet, available when G admits a ReverseAccessor: Direct for Iso, Either for Prism), so the composite stays a build-only Review. The single-focus mirror of Unfold's andThenBuildAny.

Build-only outer ∘ ANY reversible inner — only the inner's build half is used (reverseGet, available when G admits a ReverseAccessor: Direct for Iso, Either for Prism), so the composite stays a build-only Review. The single-focus mirror of Unfold's andThenBuildAny.

Attributes

Source
Review.scala
inline def andThen[F[_], D](inner: Unfold[B, D, F]): Unfold[T, D, F]

Fused Review.andThen(Unfold) — post-process the assembled whole. inner assembles B from a layer F[D]; this builds T from that B, so the composite is an Unfold assembling T from F[D] (reverseGet ∘ inner.embed). No constraint on F — the seam threads a single B, never an F-layer, so pattern-functor algebras compose freely. A member (not an extension) so it out-prioritises the Morph-summoning generic andThen, which would route the same call through Composer[Direct, Forget[F]]'s singleton-pick.

Fused Review.andThen(Unfold) — post-process the assembled whole. inner assembles B from a layer F[D]; this builds T from that B, so the composite is an Unfold assembling T from F[D] (reverseGet ∘ inner.embed). No constraint on F — the seam threads a single B, never an F-layer, so pattern-functor algebras compose freely. A member (not an extension) so it out-prioritises the Morph-summoning generic andThen, which would route the same call through Composer[Direct, Forget[F]]'s singleton-pick.

Attributes

Source
Review.scala
def from(d: Direct[X, B]): T

Close the carrier: given a modified focus B (and the leftover X already inside the F), reassemble the result T.

Close the carrier: given a modified focus B (and the leftover X already inside the F), reassemble the result T.

Attributes

Source
Review.scala
def reverseGet(b: B): T

Attributes

Source
Review.scala
def to(u: Unit): Direct[X, Unit]

Push the source S into the carrier, extracting the focus A and packing the leftover X. Paired with from to reconstruct T.

Push the source S into the carrier, extracting the focus A and packing the leftover X. Paired with from to reconstruct T.

Attributes

Source
Review.scala

Inherited methods

def andThen[C, IB, G[_, _]](inner: Optic[Unit, Unit, C, IB, G])(using rc: ReadCompose[Direct, G]): rc.Out[Unit, C]

ANY outer ∘ read-only inner — the inner is honestly one-way (T = Unit: a Getter, AffineFold, or Fold), so only the two READ sides matter and the composite collapses to the read-only join of their strengths via compose.ReadCompose (Getter / PickFold / ForgetFold).

ANY outer ∘ read-only inner — the inner is honestly one-way (T = Unit: a Getter, AffineFold, or Fold), so only the two READ sides matter and the composite collapses to the read-only join of their strengths via compose.ReadCompose (Getter / PickFold / ForgetFold).

A trait member (not an extension in the companion) deliberately: once a receiver is statically one of the fused concrete classes, its andThen member overloads enter resolution and Scala 3 never falls back to extension methods when they all fail — the collapse must be in the member overload set to be reachable without an expected-type ascription.

Only the inner's T is pinned to Unit; its B stays free (IB) even though read-only inners always have B = Unit. That keeps this overload strictly LESS specific than the same-carrier andThen above (which accepts every argument this one does whenever B = Unit at the receiver), so a same-carrier read-only ∘ read-only call resolves unambiguously to the AssociativeFunctor path and this one fires exactly on the cross-seam cells the generic member cannot type.

Attributes

Inherited from:
Optic
Source
Optic.scala
inline def andThen[C, D](o: Optic[Unit, B, C, D, Direct]): Optic[Unit, T, C, D, Direct]

Compose with another optic under the shared carrier F. Requires AssociativeFunctor[F]. Cross-carrier composition (Lens → Optional, Lens → Traversal, …) goes through the Morph-summoning overload of this same method.

Compose with another optic under the shared carrier F. Requires AssociativeFunctor[F]. Cross-carrier composition (Lens → Optional, Lens → Traversal, …) goes through the Morph-summoning overload of this same method.

Attributes

Example
case class Address(street: String)
case class Person(address: Address)
val streetLens = lens[Person](_.address).andThen(lens[Address](_.street))
Inherited from:
Optic
Source
Optic.scala