ForgetFold
Concrete Optic subclass for Fold, storing the source projection to and the underlying Foldable[F] directly. This lets the terminal foldMap fold the focus eagerly through the captured Foldable[F], skipping both the per-call ForgetfulFold[Forget[F]] summon and the intermediate S => M closure the generic Optic.foldMap extension builds — the same specialisation GetReplaceLens / Modify / MultiFocusSingleton apply to their hot paths.
Returned by every Fold.* constructor so hand-written folds pick up the fast path automatically. A composed Fold (the result of .andThen) surfaces as the erased Optic[…, Forget[F]] and keeps the generic extension — the same trade-off GetReplaceLens accepts.
Attributes
- Source
- Fold.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
- Fold.scala
Value members
Concrete methods
Fused Fold.andThen(Fold) — same-carrier flatMap (read(s).flatMap(inner.read)); the read-only-triple join cell for the many rung. Being the most specific overload, it resolves the otherwise-ambiguous fold ∘ fold (a read-only outer where the structure-preserving and read-collapse trait members both match a read-only inner). Requires FlatMap[F], exactly as the generic assocForgetMonad path did.
Fused Fold.andThen(Fold) — same-carrier flatMap (read(s).flatMap(inner.read)); the read-only-triple join cell for the many rung. Being the most specific overload, it resolves the otherwise-ambiguous fold ∘ fold (a read-only outer where the structure-preserving and read-collapse trait members both match a read-only inner). Requires FlatMap[F], exactly as the generic assocForgetMonad path did.
Attributes
- Source
- Fold.scala
Read-only outer ∘ ANY inner — a Fold only reads (many), so the inner's write side is irrelevant and the composite is always a ForgetFold (many ∘ anything = many) via compose.ReadCompose. Covers the writable inners (fold ∘ lens / prism / optional / traversal); the fused same-F andThen above stays as the more-specific fast path.
Read-only outer ∘ ANY inner — a Fold only reads (many), so the inner's write side is irrelevant and the composite is always a ForgetFold (many ∘ anything = many) via compose.ReadCompose. Covers the writable inners (fold ∘ lens / prism / optional / traversal); the fused same-F andThen above stays as the more-specific fast path.
Attributes
- Source
- Fold.scala
Override of the trait's read-only-inner overload, re-homed here so it shares an owner with andThenReadAny above — see Getter's twin override for the ambiguity rationale.
Override of the trait's read-only-inner overload, re-homed here so it shares an owner with andThenReadAny above — see Getter's twin override for the ambiguity rationale.
Attributes
- Definition Classes
- Source
- Fold.scala
Eager foldMap — folds s straight through the captured Foldable[F], returning M with no intermediate S => M closure and no ForgetfulFold summon. Wins over the Optic.foldMap extension by member precedence whenever the receiver is statically a ForgetFold; the call shape (fold.foldMap(f)(s)) is identical, so this is a transparent drop-in.
Eager foldMap — folds s straight through the captured Foldable[F], returning M with no intermediate S => M closure and no ForgetfulFold summon. Wins over the Optic.foldMap extension by member precedence whenever the receiver is statically a ForgetFold; the call shape (fold.foldMap(f)(s)) is identical, so this is a transparent drop-in.
Attributes
- Source
- Fold.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
- Fold.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
- Fold.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
Concrete fields
Attributes
- Source
- Fold.scala