ModifyFLaws

dev.constructive.eo.laws.data.ModifyFLaws
trait ModifyFLaws[X, A]

Carrier-level laws for ModifyF[X, A].

ModifyF[X, A] wraps a pair (Fst[X], Snd[X] => A) — the first component carries "outer state", the second a builder closure that eventually produces the focused A. Its ForgetfulFunctor instance post-composes the builder with the function argument.

Because ModifyF holds a function, structural == cannot witness equality. The laws below therefore assert extensional equality: after applying a law-relevant transformation, the first component and the builder's output on a test input must match the expected values.

The ForgetfulTraverse[ModifyF, Distributive] instance is intentionally not exercised here — writing a standalone law for the distributive-traverse path requires picking a concrete distributive functor (Id is distributive, so the identity law collapses to a tautology). The traverse identity is already exercised through the ModifyLaws discipline suite that consumes this carrier.

Attributes

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

Members list

Value members

Concrete methods

def functorComposition(fst: Fst[X], fn: Snd[X] => A, f: A => A, g: A => A, x: Snd[X])(using FF: ForgetfulFunctor[ModifyF]): Boolean

map(map(fa, f), g) is extensionally equal to map(fa, f andThen g) — sampled at one Snd[X].

map(map(fa, f), g) is extensionally equal to map(fa, f andThen g) — sampled at one Snd[X].

Attributes

Source
ModifyFLaws.scala
def functorIdentity(fst: Fst[X], fn: Snd[X] => A, x: Snd[X])(using FF: ForgetfulFunctor[ModifyF]): Boolean

map(fa, identity) produces a ModifyF whose builder behaves identically to the input on every Snd[X] sample.

map(fa, identity) produces a ModifyF whose builder behaves identically to the input on every Snd[X] sample.

Attributes

Source
ModifyFLaws.scala