diff --git a/laws/src/main/scala/cats/laws/DistributiveLaws.scala b/laws/src/main/scala/cats/laws/DistributiveLaws.scala index db45442101..1df311b445 100644 --- a/laws/src/main/scala/cats/laws/DistributiveLaws.scala +++ b/laws/src/main/scala/cats/laws/DistributiveLaws.scala @@ -8,6 +8,10 @@ import cats.syntax.distributive._ trait DistributiveLaws[F[_]] extends FunctorLaws[F] { implicit override def F: Distributive[F] + def distributeIdentity[A, B](fa: F[A], f: A => B): IsEq[F[B]] = { + fa.distribute[Id, B](f) <-> F.map(fa)(f) + } + def cosequenceIdentity[A](fa: F[A]): IsEq[F[A]] = { F.cosequence[Id, A](fa) <-> fa } diff --git a/laws/src/main/scala/cats/laws/discipline/DistributiveTests.scala b/laws/src/main/scala/cats/laws/discipline/DistributiveTests.scala index 7d25a5b5a7..c4a54479d8 100644 --- a/laws/src/main/scala/cats/laws/discipline/DistributiveTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/DistributiveTests.scala @@ -18,6 +18,7 @@ trait DistributiveTests[F[_]] extends FunctorTests[F] { CogenB: Cogen[B], CogenC: Cogen[C], EqFA: Eq[F[A]], + EqFB: Eq[F[B]], EqFC: Eq[F[C]], EqA: Eq[A], EqFYXC: Eq[F[Y[X[C]]]], @@ -29,6 +30,7 @@ trait DistributiveTests[F[_]] extends FunctorTests[F] { def bases: Seq[(String, RuleSet)] = Nil def parents: Seq[RuleSet] = Seq(functor[A, B, C]) def props: Seq[(String, Prop)] = Seq( + "distributive distribute identity" -> forAll(laws.distributeIdentity[A, B] _), "distributive identity" -> forAll(laws.cosequenceIdentity[A] _), "distributive composition" -> forAll(laws.composition[A, B, C, X, Y] _), "distributive double cosequence identity" -> forAll(laws.cosequenceTwiceIsId[A, Y] _)