SameFocus

dev.constructive.eo.optics.Optic.SameFocus
trait SameFocus[C, D, F[_, _]]

Focus-stability witness carried by an optic whose focus types coincide (C =:= D).

It exists for kernels whose composite read cannot be inverted from the write bundle alone: the Function1-shaped one reads ONE position per index, so composing two tabulating optics (MultiFocus.tuple ∘ MultiFocus.tuple) leaves each inner structure's off-diagonal out of the composite's focus vector, and putting those values back needs a C => D — which exists exactly when C =:= D. Handing that fact to the kernel through the composition algebra would put one carrier's problem in every carrier's contract; it rides on the optic instead, like data.Function1BroadcastOptic (which says this optic writes one value per position) — this one says this optic's write types coincide with its read types.

Optic.andThen mixes it into every composite it builds, with whatever C =:= D evidence that call site has, and the monomorphic factories (MultiFocus.representable, MultiFocus.tuple, MultiFocus.apply) mix it in with Some(…) directly, so a kernel that is handed an inner optic can look the fact up on it.

None is a real answer, not a failure: a polymorphic optic (MultiFocus.pApply, a Lens whose S ≠ T) cannot put a read value back into a write bundle, and kernels keep their lossy default for it.

Attributes

Source
Optic.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def sameFocus: Option[C =:= D]

Some carries the evidence that this optic's read and write types coincide; None says they may not.

Some carries the evidence that this optic's read and write types coincide; None says they may not.

Attributes

Source
Optic.scala