AffineLaws

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

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

Affine is the carrier behind Optional: a sum of a "no write path" case (Fst[X]) and a tuple-like "got the focus" case ((Snd[X], A)). The laws pin down its two main type-class instances:

  • ForgetfulFunctor[Affine] — identity and composition.
  • ForgetfulTraverse[Affine, Applicative] at Id — identity.

The AssociativeFunctor[Affine, X, Y] instance is already exercised by Optional ∘ Optional at the optic level (see dev.constructive.eo.laws.eo.OptionalComposeLaws); re-stating its associativity equations as a standalone law class would duplicate that coverage without adding signal.

On the BUILD seam (see Affine.graft), the two arms are the decoration vocabulary — Miss = the slot is finished (an apo graft, a futu unroll), Hit = keep going. The build-channel laws pin the finished arm as final: invisible to the focus (getOption empty, foldMap empty) and inert under map — the carrier-shaped halves of "done is final"; the per-value graft(done(t)) == t equation is stated against concrete decoration citizens (which pin Fst[X]), not here.

Attributes

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

Members list

Value members

Concrete methods

def doneFoldEmpty(fst: Fst[X])(using G: Graft[Affine], FD: ForgetfulFold[Affine]): Boolean

The finished arm contributes nothing to a fold.

The finished arm contributes nothing to a fold.

Attributes

Source
AffineLaws.scala
def doneHasNoFocus(fst: Fst[X])(using G: Graft[Affine], P: PartialAccessor[Affine]): Boolean

The finished arm carries no focus.

The finished arm carries no focus.

Attributes

Source
AffineLaws.scala
def doneMapInert(fst: Fst[X], f: A => A)(using G: Graft[Affine], FF: ForgetfulFunctor[Affine]): Boolean

The finished arm is inert under map — finished means finished.

The finished arm is inert under map — finished means finished.

Attributes

Source
AffineLaws.scala
def functorComposition(fa: Affine[X, A], f: A => A, g: A => A)(using FF: ForgetfulFunctor[Affine]): Boolean

map(map(fa, f), g) == map(fa, f andThen g).

map(map(fa, f), g) == map(fa, f andThen g).

Attributes

Source
AffineLaws.scala
def functorIdentity(fa: Affine[X, A])(using FF: ForgetfulFunctor[Affine]): Boolean

map(fa, identity) == fa. Sample Affine values are scalacheck-generated through the forAll calls in dev.constructive.eo.laws.data.discipline.AffineTests.

map(fa, identity) == fa. Sample Affine values are scalacheck-generated through the forAll calls in dev.constructive.eo.laws.data.discipline.AffineTests.

Attributes

Source
AffineLaws.scala
def stepHasFocus(snd: Snd[X], a: A)(using G: Graft[Affine], P: PartialAccessor[Affine]): Boolean

The keep-going arm carries exactly its focus.

The keep-going arm carries exactly its focus.

Attributes

Source
AffineLaws.scala
def traverseIdentity(fa: Affine[X, A])(using FT: ForgetfulTraverse[Affine, Applicative]): Boolean

traverse[Id] is map — the degenerate case of the traverse identity law.

traverse[Id] is map — the degenerate case of the traverse identity law.

Attributes

Source
AffineLaws.scala