ForgetfulTraverseLaws

dev.constructive.eo.laws.typeclass.ForgetfulTraverseLaws
trait ForgetfulTraverseLaws[F[_, _], X, A]

Law equations for any ForgetfulTraverse[F, Applicative] — cats' Traverse laws restated for the two-parameter carrier, at fixed effects:

  • identity: traverse[Id](fa)(a => a) == fa;
  • sequential composition: traversing under Nested[List, Option] equals traversing under List, then each branch under Option;
  • parallel composition: traversing under Tuple2K[List, Vector] equals the pair of the two separate traversals;
  • multi-shot agreement: traversing under List gives cats' cartesian product Traverse[List].traverse(foci)(f) over the carrier's foci (read off ForgetfulFold), each choice written back into fa.

The effects are deliberately MULTI-SHOT (List, Vector resume every continuation once per branch; Tuple2K once per component): a traverse that threads one mutable result through map2 passes every single-shot law (Id, Option, Const) yet hands all branches the same result. The last law is the one that pins a branch to its values; the composition laws compare the carrier only with itself.

The [_ <: Distributive] flavour (ModifyF) is not covered: it collapses to a tautology at Id.

Attributes

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

Members list

Value members

Concrete methods

def traverseIdentity(fa: F[X, A])(using FT: ForgetfulTraverse[F, Applicative]): Boolean

traverse[Id](fa)(a => a) == fa.

traverse[Id](fa)(a => a) == fa.

Attributes

Source
ForgetfulTraverseLaws.scala
def traverseMultiShotAgreesWithFoci(fa: F[X, A], f: A => List[A])(using FT: ForgetfulTraverse[F, Applicative], FF: ForgetfulFold[F]): Boolean

traverse[List](fa)(f) == Traverse[List].traverse(foci(fa))(f).map(refill(fa, _)), with foci the carrier's foldMap(List(_)) and refill writing a list of foci back in order (a single-shot State traverse).

traverse[List](fa)(f) == Traverse[List].traverse(foci(fa))(f).map(refill(fa, _)), with foci the carrier's foldMap(List(_)) and refill writing a list of foci back in order (a single-shot State traverse).

Attributes

Source
ForgetfulTraverseLaws.scala
def traverseParallelComposition(fa: F[X, A], f: A => List[A], g: A => Vector[A])(using FT: ForgetfulTraverse[F, Applicative]): Boolean

traverse[Tuple2K[List, Vector]](fa)(a => Tuple2K(f(a), g(a))) == Tuple2K(traverse[List](fa)(f), traverse[Vector](fa)(g)).

traverse[Tuple2K[List, Vector]](fa)(a => Tuple2K(f(a), g(a))) == Tuple2K(traverse[List](fa)(f), traverse[Vector](fa)(g)).

Attributes

Source
ForgetfulTraverseLaws.scala
def traverseSequentialComposition(fa: F[X, A], f: A => List[A], g: A => Option[A])(using FT: ForgetfulTraverse[F, Applicative]): Boolean

traverse[Nested[List, Option]](fa)(a => Nested(f(a).map(g))) == Nested(traverse[List](fa)(f).map(traverse[Option](_)(g))).

traverse[Nested[List, Option]](fa)(a => Nested(f(a).map(g))) == Nested(traverse[List](fa)(f).map(traverse[Option](_)(g))).

Attributes

Source
ForgetfulTraverseLaws.scala