LensLaws

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

Law equations for a Lens[S, A]Optic[S, S, A, A, Tuple2].

Ported from Monocle's monocle.law.LensLaws. Six equations total: the three classical get/replace round-trips plus modify identity, modify composition, and the consistency bridge between replace and modify.

Attributes

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

Members list

Value members

Abstract methods

def lens: Optic[S, S, A, A, Tuple2]

The optic under test.

The optic under test.

Attributes

Source
LensLaws.scala

Concrete methods

def composeModify(s: S, f: A => A, g: A => A): Boolean

modify(g) ∘ modify(f) == modify(f andThen g).

modify(g) ∘ modify(f) == modify(f andThen g).

Attributes

Source
LensLaws.scala
def consistentReplaceModify(s: S, a: A): Boolean

replace(a) == modify(_ => a).

replace(a) == modify(_ => a).

Attributes

Source
LensLaws.scala
def getReplace(s: S): Boolean

get-put: replace(get(s))(s) == s — writing back what was read is a no-op.

get-put: replace(get(s))(s) == s — writing back what was read is a no-op.

Attributes

Source
LensLaws.scala
def modifyIdentity(s: S): Boolean

modify(identity) == identity.

modify(identity) == identity.

Attributes

Source
LensLaws.scala
def replaceGet(s: S, a: A): Boolean

put-get: get(replace(a)(s)) == a — a read observes the last write.

put-get: get(replace(a)(s)) == a — a read observes the last write.

Attributes

Source
LensLaws.scala
def replaceIdempotent(s: S, a: A): Boolean

put-put: replace(a) ∘ replace(a) == replace(a) — replacing twice equals replacing once.

put-put: replace(a) ∘ replace(a) == replace(a) — replacing twice equals replacing once.

Attributes

Source
LensLaws.scala