GetterLaws

dev.constructive.eo.laws.GetterLaws
trait GetterLaws[S, A]

Law equations for a Getter[S, A]Optic[S, Unit, A, Unit, Direct].

A Getter is a read-only optic: both its leftover T and its back-focus B are Unit so no write path exists (and so Getters compose through the ordinary andThen). The only observable behaviour is get, which makes the meaningful law a constructor-correctness check: getter.get(s) must equal whatever reference function the caller claims the getter represents. This rules out plumbing mistakes like swapping _._1 / _._2 or accidentally threading the input through identity.

Compared to Monocle's GetterLaws, we omit the fold-consistency law (getter.fold.getAll(s).headOption == Some(getter.get(s))). The Composer[Direct, Forget[F]] bridge it needs exists (dev.constructive.eo.optics.Unfold made Forget[F]'s from a sound singleton-pick), so a Getter→Fold morph is available; the law is simply not yet restated here.

Attributes

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

Members list

Value members

Abstract methods

def getter: Optic[S, Unit, A, Unit, Direct]

The optic under test.

The optic under test.

Attributes

Source
GetterLaws.scala
def reference: S => A

The function this getter is declared to represent. Concrete subclass supplies this — typically the same S => A that was passed to Getter.apply.

The function this getter is declared to represent. Concrete subclass supplies this — typically the same S => A that was passed to Getter.apply.

Attributes

Source
GetterLaws.scala

Concrete methods

def getConsistent(s: S): Boolean

getter.get(s) equals the reference function applied at s.

getter.get(s) equals the reference function applied at s.

Attributes

Source
GetterLaws.scala