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.

Attributes

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

Members list

Value members

Concrete methods

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 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