Concrete Optic subclass for a read-only getter — the one-way view of an S whose focus A can only be read. Both the leftover T and the back-focus B are Unit, making the read-only-ness honest in the type (there is no B to put back, so .modify / .replace never exist). Implements CanGet and CanFold directly, so a Getter can be passed wherever a consuming signature demands CanGet[S, A].
Implementation notes: a final class storing get directly — NOT an abstract class with an abstract get: the CI A/B showed composed-getter dispatch through the abstract-class form costs ~1.8x (eoGet_3 5.1ns final vs 11.5ns abstract) even with a fused andThen, while every fused path that stayed a concrete class (GetReplaceLens lens-reuse) was flat. The hot path skips the Accessor[Direct] dispatch the generic extension would perform — the same shape as BijectionIso / GetReplaceLens. Returned by Getter.apply so hand-written getters pick up the fused path automatically.
Attributes
- Companion
- object
- Source
- Getter.scala
- Graph
-
- Supertypes
Members list
Grouped members
Operations
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
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
- Getter.scala
Value members
Concrete methods
Fused Getter.andThen(Getter) — composes the read functions; the vestigial Unit write path needs no threading.
Fused Getter.andThen(Getter) — composes the read functions; the vestigial Unit write path needs no threading.
inline so each composition call site splices its own copy of the s => inner.get(get(s)) lambda, yielding a distinct synthetic method per level. A plain def compiles the lambda once (andThen$$anonfun$1), so a depth-N runtime chain reuses that one bytecode and C2 treats the .get cascade as recursion — capping inlining at MaxRecursiveInlineLevel and leaving the deep tail as virtual Function1.apply. Distinct per-level methods sidestep that cap with no JVM flag, the same way Monocle's per-compose anonymous classes do.
Attributes
- Source
- Getter.scala
Read-only outer ∘ ANY inner — a Getter only reads, so the inner's write side is irrelevant and the composite is the read-only join via compose.ReadCompose (Getter when the inner reads totally, PickFold when partially, ForgetFold when it has many foci). This member covers the writable inners (getter ∘ lens / prism / optional / traversal) that the trait's read-only-inner overload cannot reach; the fused andThen(Getter) / andThen(PickFold) members above stay as the more-specific fast paths.
Read-only outer ∘ ANY inner — a Getter only reads, so the inner's write side is irrelevant and the composite is the read-only join via compose.ReadCompose (Getter when the inner reads totally, PickFold when partially, ForgetFold when it has many foci). This member covers the writable inners (getter ∘ lens / prism / optional / traversal) that the trait's read-only-inner overload cannot reach; the fused andThen(Getter) / andThen(PickFold) members above stay as the more-specific fast paths.
Attributes
- Source
- Getter.scala
Override of the trait's read-only-inner overload, re-homed in this class so it shares an owner with andThenReadAny above — otherwise a read-only inner is ambiguous between the two (the trait one wins on signature specificity, the class one on owner derivation, and dotty calls the split a tie). Same ReadCompose route either way.
Override of the trait's read-only-inner overload, re-homed in this class so it shares an owner with andThenReadAny above — otherwise a read-only inner is ambiguous between the two (the trait one wins on signature specificity, the class one on owner derivation, and dotty calls the split a tie). Same ReadCompose route either way.
Attributes
- Definition Classes
- Source
- Getter.scala
Fused Getter.andThen(Direct-carried read-only citizen) — the C8 tie-breaker. The schemes' zoo citizens (cata/ana/hylo via ReadScheme/BuildScheme) are Optic[…, Unit, …, Unit, Direct] — simultaneously matching the any-carrier member, the re-homed read-only override, and the trait's same-carrier inline andThen; for that argument dotty called those three a draw (each wins on one of signature specificity / owner derivation / same-carrier matching; the fused andThen(Getter) does not apply — citizens are not statically Getter). This member's parameter type pins the full citizen shape (inner.T = Unit, inner.B = Unit, carrier Direct), making it strictly the most specific in the set, so it wins outright — and it returns the concrete Getter (what ReadCompose.totalTotal would produce) rather than a bare Optic, so ascribed compositions (val g: Getter[Doc, Int] = …) type-check. The DummyImplicit keeps its parameter-list shape comparable with the other overloads (all term + using), which is what lets the specificity comparison run at all.
Fused Getter.andThen(Direct-carried read-only citizen) — the C8 tie-breaker. The schemes' zoo citizens (cata/ana/hylo via ReadScheme/BuildScheme) are Optic[…, Unit, …, Unit, Direct] — simultaneously matching the any-carrier member, the re-homed read-only override, and the trait's same-carrier inline andThen; for that argument dotty called those three a draw (each wins on one of signature specificity / owner derivation / same-carrier matching; the fused andThen(Getter) does not apply — citizens are not statically Getter). This member's parameter type pins the full citizen shape (inner.T = Unit, inner.B = Unit, carrier Direct), making it strictly the most specific in the set, so it wins outright — and it returns the concrete Getter (what ReadCompose.totalTotal would produce) rather than a bare Optic, so ascribed compositions (val g: Getter[Doc, Int] = …) type-check. The DummyImplicit keeps its parameter-list shape comparable with the other overloads (all term + using), which is what lets the specificity comparison run at all.
Attributes
- Source
- Getter.scala
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
- Getter.scala
Attributes
- Source
- Getter.scala
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
- Getter.scala
Inherited methods
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
Attributes
- Inherited from:
- CanFold
- Source
- CanFold.scala
Attributes
- Inherited from:
- CanFold
- Source
- CanFold.scala
Attributes
- Inherited from:
- CanFold
- Source
- CanFold.scala
Attributes
- Inherited from:
- CanFold
- Source
- CanFold.scala