MultiFocusLaws

dev.constructive.eo.laws.MultiFocusLaws
trait MultiFocusLaws[S, A, F[_]]

Laws for MultiFocus[F][S, A]Optic[S, S, A, A, MultiFocus[F]] — at a concrete F[_].

  • MF1 modifyIdentity — mf.modify(identity)(s) == s.
  • MF2 composeModify — mf.modify(g) ∘ mf.modify(f) == mf.modify(f andThen g).
  • MF3 collectViaMap — mf.collectMap[A](agg)(s) == F.map(s)(_ => agg(s)) at the generic MultiFocus.apply[F, A] factory.
  • MF4 collectWithSubsumesCollectMap — mf.collectWith(fa => _ => agg(fa)) == mf.collectMap(agg).
  • MF5 collectWithSubsumesModify — mf.collectWith(_ => f) == mf.modify(f).

Attributes

See also

dev.constructive.eo.laws.discipline.MultiFocusTests.

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

Members list

Value members

Abstract methods

def multiFocus: Optic[S, S, A, A, MultiFocus[F]]

The optic under test.

The optic under test.

Attributes

Source
MultiFocusLaws.scala

Concrete methods

def collectViaMap(s: S, agg: F[A] => A)(using ev: S =:= F[A]): Boolean

MF3 — .collectMap coherence with Functor[F].map. At the generic factory (focus = s, rebuild = identity, S = F[A]), .collectMap[A](agg)(s) is definitionally F.map(focus)(_ => agg(focus)). The law works at S = F[A] by assumption; that's true for every shipped MultiFocus.apply[F, A] fixture.

MF3 — .collectMap coherence with Functor[F].map. At the generic factory (focus = s, rebuild = identity, S = F[A]), .collectMap[A](agg)(s) is definitionally F.map(focus)(_ => agg(focus)). The law works at S = F[A] by assumption; that's true for every shipped MultiFocus.apply[F, A] fixture.

Attributes

Source
MultiFocusLaws.scala
def collectWithSubsumesCollectMap(s: S, agg: F[A] => A): Boolean

MF4 — .collectWith subsumes .collectMap: a constant per-focus function recovers the broadcast exactly. Unlike MF3 this needs no S =:= F[A] evidence — both sides go through the optic, so the law holds at any MultiFocus[F] optic, composed ones included.

MF4 — .collectWith subsumes .collectMap: a constant per-focus function recovers the broadcast exactly. Unlike MF3 this needs no S =:= F[A] evidence — both sides go through the optic, so the law holds at any MultiFocus[F] optic, composed ones included.

Attributes

Source
MultiFocusLaws.scala
def collectWithSubsumesModify(s: S, f: A => A): Boolean

MF5 — .collectWith subsumes .modify: ignoring the aggregate recovers the pointwise map.

MF5 — .collectWith subsumes .modify: ignoring the aggregate recovers the pointwise map.

Attributes

Source
MultiFocusLaws.scala
def composeModify(s: S, f: A => A, g: A => A): Boolean

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

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

Attributes

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

MF1 — modify(identity) == identity.

MF1 — modify(identity) == identity.

Attributes

Source
MultiFocusLaws.scala

Givens

Givens

given functor: => Functor[F]

Functor evidence for the focus classifier F.

Functor evidence for the focus classifier F.

Attributes

Source
MultiFocusLaws.scala