BifoldableTests

cats.laws.discipline.BifoldableTests
See theBifoldableTests companion object
trait BifoldableTests[F[_, _]] extends Laws

Attributes

Companion
object
Source
BifoldableTests.scala
Graph
Supertypes
trait Laws
class Object
trait Matchable
class Any
Known subtypes
trait BitraverseTests[F]

Members list

Type members

Inherited classlikes

Convenience class for rule sets which may have a parent, but no bases.

Convenience class for rule sets which may have a parent, but no bases.

Attributes

Inherited from:
Laws
Source
Laws.scala
Supertypes
trait HasOneParent
trait RuleSet
class Object
trait Matchable
class Any
Known subtypes
trait HasOneParent

Convenience trait to mix into subclasses of RuleSet for rule sets which only have one parent.

Convenience trait to mix into subclasses of RuleSet for rule sets which only have one parent.

Attributes

Inherited from:
Laws
Source
Laws.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait RuleSet

This trait abstracts over the various ways how the laws of a type class can depend on the laws of other type classes.

This trait abstracts over the various ways how the laws of a type class can depend on the laws of other type classes. An instance of this trait is called a rule set.

For that matter, we divide type classes into kinds, where the classes of one kind share the number of operations and meaning. For example, Semigroup, Monoid and Group all belong to the same kind. On the other hand, their additive variants also belong to a common kind, but to a different one.

Users of this trait should extend the outer trait Laws and create specialized subtypes for each kind of type class. (See DefaultRuleSet for an example.)

Consider this example hierarchy:

 Semigroup
| \ Monoid AdditiveSemigroup
| \ | Group AdditiveMonoid \ | AdditiveGroup 
They all define their own laws, as well as a couple of parent classes. If we want to check the laws of AdditiveGroup, we want to avoid checking properties twice, i.e. do not want to check Monoid laws via Group and also via AdditiveMonoid.

To address this problem, we define the parent in the same kind as parent, and other parents as bases. In this example, the parent of AdditiveGroup is AdditiveMonoid, and its only basis is Group. On the other hand, the parent of Group is Monoid, and it does not have any bases.

The set of all properties of a certain class is now defined as union of these sets:

  • the properties of the class itself

  • recursively, the properties of all its parents (ignoring their bases)

  • recursively, the set of all properties of its bases

Looking at our example, that means that AdditiveGroup includes the Monoid law only once, because it is the parent of its basis. The same laws are ignored by its parent AdditiveMonoid, hence no redundant checks occur.

Of course, classes can have multiple parents and multiple (named) bases. The only requirement here is that inside one kind, the identifier of a property is unique, since duplicates are eliminated. To avoid name clashes between different kinds, the names of properties pulled in via a basis are prefixed with the name of the basis.

For better type-safety, parents are only allowed to come from the same outer instance of Laws, whereas bases are allowed to come from anywhere.

Attributes

Inherited from:
Laws
Source
Laws.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Convenience class for rule sets without parents and bases.

Convenience class for rule sets without parents and bases.

Attributes

Inherited from:
Laws
Source
Laws.scala
Supertypes
trait HasOneParent
trait RuleSet
class Object
trait Matchable
class Any
Show all

Value members

Abstract methods

Attributes

Source
BifoldableTests.scala

Concrete methods

def [Prop](forAll[F[A,B],Function1[A,C],Function1[B,C],IsEq[C]]({ val$1$:BifoldableLaws[F]=BifoldableTests.this.laws ((fab:F[A,B],f:Function1[A,C],g:Function1[B,C])=>$1$.bifoldLeftConsistentWithBifoldMap[A,B,C](fab,f,g)(evidence$4)) })(((isEq:IsEq[C])=>catsLawsIsEqToProp[C](isEq)(evidence$5,((t:C)=>prettyAny(t)))),ArbFAB,shrinkAny[F[A,B]],((`t₂`:F[A,B])=>prettyAny(`t₂`)),arbFunction1[A,C](evidence$3,CogenA),shrinkAny[Function1[A,C]],((`t₃`:Function1[A,C])=>prettyAny(`t₃`)),arbFunction1[B,C](evidence$3,CogenB),shrinkAny[Function1[B,C]],((`t₄`:Function1[B,C])=>prettyAny(`t₄`)))),ArrowAssoc[String]("bifoldRightconsistentwithbifoldMap").->[Prop](forAll[F[A,B],Function1[A,C],Function1[B,C],IsEq[C]]({ val$2$:BifoldableLaws[F]=BifoldableTests.this.laws ((`fab₂`:F[A,B],`f₂`:Function1[A,C],`g₂`:Function1[B,C])=>$2$.bifoldRightConsistentWithBifoldMap[A,B,C](`fab₂`,`f₂`,`g₂`)(evidence$4)) })(((`isEq₂`:IsEq[C])=>catsLawsIsEqToProp[C](`isEq₂`)(evidence$5,((`t₅`:C)=>prettyAny(`t₅`)))),ArbFAB,shrinkAny[F[A,B]],((`t₆`:F[A,B])=>prettyAny(`t₆`)),arbFunction1[A,C](evidence$3,CogenA),shrinkAny[Function1[A,C]],((`t₇`:Function1[A,C])=>prettyAny(`t₇`)),arbFunction1[B,C](evidence$3,CogenB),shrinkAny[Function1[B,C]],((`t₈`:Function1[B,C])=>prettyAny(`t₈`)))))" t="n"class="documentableName ">bifoldable[A : Arbitrary, B : Arbitrary, C : Eq](implicit evidence$1: Arbitrary[A], evidence$2: Arbitrary[B], evidence$3: Arbitrary[C], evidence$4: Monoid[C], evidence$5: Eq[C], ArbFAB: Arbitrary[F[A, B]], CogenA: Cogen[A], CogenB: Cogen[B]): RuleSet

Attributes

Source
BifoldableTests.scala

Inherited methods

Empty rule set.

Empty rule set.

Attributes

Inherited from:
")">Laws
Source
Laws.scala