diff --git a/core/src/main/scala/cats/FunctorEmpty.scala b/core/src/main/scala/cats/FunctorFilter.scala similarity index 76% rename from core/src/main/scala/cats/FunctorEmpty.scala rename to core/src/main/scala/cats/FunctorFilter.scala index 21c75a119e0..90a43c0e640 100644 --- a/core/src/main/scala/cats/FunctorEmpty.scala +++ b/core/src/main/scala/cats/FunctorFilter.scala @@ -3,10 +3,10 @@ package cats import simulacrum.typeclass /** - * `FunctorEmpty[F]` allows you to `map` and filter out elements simultaneously. + * `FunctorFilter[F]` allows you to `map` and filter out elements simultaneously. */ @typeclass -trait FunctorEmpty[F[_]] extends Serializable { +trait FunctorFilter[F[_]] extends Serializable { def functor: Functor[F] def mapFilter[A, B](fa: F[A])(f: A => Option[B]): F[B] diff --git a/core/src/main/scala/cats/TraverseEmpty.scala b/core/src/main/scala/cats/TraverseFilter.scala similarity index 84% rename from core/src/main/scala/cats/TraverseEmpty.scala rename to core/src/main/scala/cats/TraverseFilter.scala index 5dc3bd631fa..ad15ee7311d 100644 --- a/core/src/main/scala/cats/TraverseEmpty.scala +++ b/core/src/main/scala/cats/TraverseFilter.scala @@ -3,7 +3,7 @@ package cats import simulacrum.typeclass /** - * `TraverseEmpty`, also known as `Witherable`, represents list-like structures + * `TraverseFilter`, also known as `Witherable`, represents list-like structures * that can essentially have a `traverse` and a `filter` applied as a single * combined operation (`traverseFilter`). * @@ -11,7 +11,7 @@ import simulacrum.typeclass */ @typeclass -trait TraverseEmpty[F[_]] extends FunctorEmpty[F] { +trait TraverseFilter[F[_]] extends FunctorFilter[F] { def traverse: Traverse[F] final override def functor: Functor[F] = traverse diff --git a/core/src/main/scala/cats/data/Chain.scala b/core/src/main/scala/cats/data/Chain.scala index 96575bcf8a7..e577de3e53c 100644 --- a/core/src/main/scala/cats/data/Chain.scala +++ b/core/src/main/scala/cats/data/Chain.scala @@ -617,7 +617,7 @@ private[data] sealed abstract class ChainInstances extends ChainInstances1 { } } - implicit val catsDataTraverseEmptyForChain: TraverseEmpty[Chain] = new TraverseEmpty[Chain] { + implicit val catsDataTraverseFilterForChain: TraverseFilter[Chain] = new TraverseFilter[Chain] { def traverse: Traverse[Chain] = Chain.catsDataInstancesForChain override def filter[A](fa: Chain[A])(f: A => Boolean): Chain[A] = fa.filter(f) diff --git a/core/src/main/scala/cats/data/Const.scala b/core/src/main/scala/cats/data/Const.scala index e8beb676d8b..9532cc74406 100644 --- a/core/src/main/scala/cats/data/Const.scala +++ b/core/src/main/scala/cats/data/Const.scala @@ -87,7 +87,7 @@ private[data] sealed abstract class ConstInstances extends ConstInstances0 { fa.traverse(f) } - implicit def catsDataTraverseEmptyForConst[C]: TraverseEmpty[Const[C, ?]] = new TraverseEmpty[Const[C, ?]] { + implicit def catsDataTraverseFilterForConst[C]: TraverseFilter[Const[C, ?]] = new TraverseFilter[Const[C, ?]] { override def mapFilter[A, B](fa: Const[C, A])(f: (A) => Option[B]): Const[C, B] = fa.retag diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index a35201c2b65..583ad070890 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -507,9 +507,9 @@ private[data] abstract class EitherTInstances extends EitherTInstances1 { EitherT(F.defer(fa.value)) } - implicit def catsDataTraverseEmptyForEitherT[F[_], L](implicit F0: TraverseEmpty[F]): TraverseEmpty[EitherT[F, L, ?]] = - new EitherTFunctorEmpty[F, L] with TraverseEmpty[EitherT[F, L, ?]] { - implicit def F: FunctorEmpty[F] = F0 + implicit def catsDataTraverseFilterForEitherT[F[_], L](implicit F0: TraverseFilter[F]): TraverseFilter[EitherT[F, L, ?]] = + new EitherTFunctorFilter[F, L] with TraverseFilter[EitherT[F, L, ?]] { + implicit def F: FunctorFilter[F] = F0 def traverse: Traverse[EitherT[F, L, ?]] = catsDataTraverseForEitherT[F, L](F0.traverse) def traverseFilter[G[_], A, B] @@ -560,8 +560,8 @@ private[data] abstract class EitherTInstances1 extends EitherTInstances2 { fa.ensureOr(error)(predicate)(F) } - implicit def catsDataFunctorEmptyForEitherT[F[_], L](implicit F0: FunctorEmpty[F]): FunctorEmpty[EitherT[F, L, ?]] = - new EitherTFunctorEmpty[F, L] { implicit def F = F0 } + implicit def catsDataFunctorFilterForEitherT[F[_], L](implicit F0: FunctorFilter[F]): FunctorFilter[EitherT[F, L, ?]] = + new EitherTFunctorFilter[F, L] { implicit def F = F0 } } private[data] abstract class EitherTInstances2 extends EitherTInstances3 { @@ -722,8 +722,8 @@ private[data] sealed trait EitherTOrder[F[_], L, A] extends Order[EitherT[F, L, override def compare(x: EitherT[F, L, A], y: EitherT[F, L, A]): Int = x compare y } -private[data] sealed trait EitherTFunctorEmpty[F[_], E] extends FunctorEmpty[EitherT[F, E, ?]] { - implicit def F: FunctorEmpty[F] +private[data] sealed trait EitherTFunctorFilter[F[_], E] extends FunctorFilter[EitherT[F, E, ?]] { + implicit def F: FunctorFilter[F] override def functor: Functor[EitherT[F, E, ?]] = EitherT.catsDataFunctorForEitherT[F, E](F.functor) diff --git a/core/src/main/scala/cats/data/Nested.scala b/core/src/main/scala/cats/data/Nested.scala index efc8f520eca..871c7e90fd0 100644 --- a/core/src/main/scala/cats/data/Nested.scala +++ b/core/src/main/scala/cats/data/Nested.scala @@ -54,10 +54,10 @@ private[data] sealed abstract class NestedInstances extends NestedInstances0 { Nested(F.defer(fa.value)) } - implicit def catsDataTraverseEmptyForNested[F[_], G[_]](implicit F0: Traverse[F], G0: TraverseEmpty[G]): TraverseEmpty[Nested[F, G, ?]] = - new NestedTraverseEmpty[F, G] { + implicit def catsDataTraverseFilterForNested[F[_], G[_]](implicit F0: Traverse[F], G0: TraverseFilter[G]): TraverseFilter[Nested[F, G, ?]] = + new NestedTraverseFilter[F, G] { implicit val F: Traverse[F] = F0 - implicit val G: TraverseEmpty[G] = G0 + implicit val G: TraverseFilter[G] = G0 } @@ -323,10 +323,10 @@ private[data] trait NestedInvariantSemigroupalApply[F[_], G[_]] extends Invarian Nested(FG.product(fa.value, fb.value)) } -private[data] abstract class NestedTraverseEmpty[F[_], G[_]] extends TraverseEmpty[Nested[F, G, ?]] { +private[data] abstract class NestedTraverseFilter[F[_], G[_]] extends TraverseFilter[Nested[F, G, ?]] { implicit val F: Traverse[F] - implicit val G: TraverseEmpty[G] + implicit val G: TraverseFilter[G] def traverse: Traverse[Nested[F, G, ?]] = Nested.catsDataTraverseForNested(F, G.traverse) diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 9552ee855d2..9e057eec660 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -235,8 +235,8 @@ private[data] sealed abstract class OptionTInstances extends OptionTInstances0 { OptionT(F.defer(fa.value)) } - implicit def optionTFunctorEmpty[F[_]: Functor]: FunctorEmpty[OptionT[F, ?]] = { - new FunctorEmpty[OptionT[F, ?]] { + implicit def optionTFunctorFilter[F[_]: Functor]: FunctorFilter[OptionT[F, ?]] = { + new FunctorFilter[OptionT[F, ?]] { override val functor: Functor[OptionT[F, ?]] = OptionT.catsDataFunctorForOptionT[F] override def mapFilter[A, B](fa: OptionT[F, A])(f: (A) => Option[B]): OptionT[F, B] = fa.subflatMap(f) diff --git a/core/src/main/scala/cats/instances/list.scala b/core/src/main/scala/cats/instances/list.scala index 90761bfa274..7ef2972a0b7 100644 --- a/core/src/main/scala/cats/instances/list.scala +++ b/core/src/main/scala/cats/instances/list.scala @@ -145,7 +145,7 @@ trait ListInstances extends cats.kernel.instances.ListInstances { } trait ListInstancesBinCompat0 { - implicit val catsStdTraverseEmptyForList: TraverseEmpty[List] = new TraverseEmpty[List] { + implicit val catsStdTraverseFilterForList: TraverseFilter[List] = new TraverseFilter[List] { val traverse: Traverse[List] = cats.instances.list.catsStdInstancesForList override def mapFilter[A, B](fa: List[A])(f: (A) => Option[B]): List[B] = fa.collect(Function.unlift(f)) diff --git a/core/src/main/scala/cats/instances/map.scala b/core/src/main/scala/cats/instances/map.scala index 745caa60e43..fda0d300523 100644 --- a/core/src/main/scala/cats/instances/map.scala +++ b/core/src/main/scala/cats/instances/map.scala @@ -109,8 +109,8 @@ trait MapInstancesBinCompat0 { } } - implicit def catsStdFunctorEmptyForMap[K]: FunctorEmpty[Map[K, ?]] = { - new FunctorEmpty[Map[K, ?]] { + implicit def catsStdFunctorFilterForMap[K]: FunctorFilter[Map[K, ?]] = { + new FunctorFilter[Map[K, ?]] { val functor: Functor[Map[K, ?]] = cats.instances.map.catsStdInstancesForMap[K] diff --git a/core/src/main/scala/cats/instances/option.scala b/core/src/main/scala/cats/instances/option.scala index a03e004b643..16d72006b0a 100644 --- a/core/src/main/scala/cats/instances/option.scala +++ b/core/src/main/scala/cats/instances/option.scala @@ -123,7 +123,7 @@ trait OptionInstances extends cats.kernel.instances.OptionInstances { } trait OptionInstancesBinCompat0 { - implicit val catsStdTraverseEmptyForOption: TraverseEmpty[Option] = new TraverseEmpty[Option] { + implicit val catsStdTraverseFilterForOption: TraverseFilter[Option] = new TraverseFilter[Option] { val traverse: Traverse[Option] = cats.instances.option.catsStdInstancesForOption override def mapFilter[A, B](fa: Option[A])(f: (A) => Option[B]): Option[B] = fa.flatMap(f) diff --git a/core/src/main/scala/cats/instances/sortedMap.scala b/core/src/main/scala/cats/instances/sortedMap.scala index 708841d1491..a23a18f1502 100644 --- a/core/src/main/scala/cats/instances/sortedMap.scala +++ b/core/src/main/scala/cats/instances/sortedMap.scala @@ -1,6 +1,6 @@ package cats.instances -import cats.{Always, Applicative, Eval, FlatMap, Foldable, Monoid, Order, Show, Traverse, TraverseEmpty} +import cats.{Always, Applicative, Eval, FlatMap, Foldable, Monoid, Order, Show, Traverse, TraverseFilter} import cats.kernel._ import cats.kernel.instances.StaticMethods @@ -168,8 +168,8 @@ class SortedMapMonoid[K, V](implicit V: Semigroup[V], O: Order[K]) extends Monoi } trait SortedMapInstancesBinCompat0 { - implicit def catsStdTraverseEmptyForSortedMap[K: Order]: TraverseEmpty[SortedMap[K, ?]] = - new TraverseEmpty[SortedMap[K, ?]] { + implicit def catsStdTraverseFilterForSortedMap[K: Order]: TraverseFilter[SortedMap[K, ?]] = + new TraverseFilter[SortedMap[K, ?]] { implicit val ordering: Ordering[K] = Order[K].toOrdering diff --git a/core/src/main/scala/cats/instances/stream.scala b/core/src/main/scala/cats/instances/stream.scala index c33730c315e..1d97c90fb03 100644 --- a/core/src/main/scala/cats/instances/stream.scala +++ b/core/src/main/scala/cats/instances/stream.scala @@ -155,7 +155,7 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances { } trait StreamInstancesBinCompat0 { - implicit val catsStdTraverseEmptyForStream: TraverseEmpty[Stream] = new TraverseEmpty[Stream] { + implicit val catsStdTraverseFilterForStream: TraverseFilter[Stream] = new TraverseFilter[Stream] { val traverse: Traverse[Stream] = cats.instances.stream.catsStdInstancesForStream override def mapFilter[A, B](fa: Stream[A])(f: (A) => Option[B]): Stream[B] = { diff --git a/core/src/main/scala/cats/instances/vector.scala b/core/src/main/scala/cats/instances/vector.scala index e2bafc1237a..1b1ddec7409 100644 --- a/core/src/main/scala/cats/instances/vector.scala +++ b/core/src/main/scala/cats/instances/vector.scala @@ -116,7 +116,7 @@ trait VectorInstances extends cats.kernel.instances.VectorInstances { } trait VectorInstancesBinCompat0 { - implicit val catsStdTraverseEmptyForVector: TraverseEmpty[Vector] = new TraverseEmpty[Vector] { + implicit val catsStdTraverseFilterForVector: TraverseFilter[Vector] = new TraverseFilter[Vector] { val traverse: Traverse[Vector] = cats.instances.vector.catsStdInstancesForVector override def mapFilter[A, B](fa: Vector[A])(f: (A) => Option[B]): Vector[B] = diff --git a/core/src/main/scala/cats/syntax/all.scala b/core/src/main/scala/cats/syntax/all.scala index 92d7f2b59d8..d131c8bd259 100644 --- a/core/src/main/scala/cats/syntax/all.scala +++ b/core/src/main/scala/cats/syntax/all.scala @@ -72,5 +72,5 @@ trait AllSyntaxBinCompat1 trait AllSyntaxBinCompat2 extends ParallelTraverseSyntax - with TraverseEmptySyntax - with FunctorEmptySyntax + with TraverseFilterSyntax + with FunctorFilterSyntax diff --git a/core/src/main/scala/cats/syntax/functorEmpty.scala b/core/src/main/scala/cats/syntax/functorEmpty.scala deleted file mode 100644 index ee687de18ff..00000000000 --- a/core/src/main/scala/cats/syntax/functorEmpty.scala +++ /dev/null @@ -1,4 +0,0 @@ -package cats -package syntax - -trait FunctorEmptySyntax extends FunctorEmpty.ToFunctorEmptyOps diff --git a/core/src/main/scala/cats/syntax/functorFilter.scala b/core/src/main/scala/cats/syntax/functorFilter.scala new file mode 100644 index 00000000000..a80b6c2618e --- /dev/null +++ b/core/src/main/scala/cats/syntax/functorFilter.scala @@ -0,0 +1,4 @@ +package cats +package syntax + +trait FunctorFilterSyntax extends FunctorFilter.ToFunctorFilterOps diff --git a/core/src/main/scala/cats/syntax/package.scala b/core/src/main/scala/cats/syntax/package.scala index dd6a5fbf562..c336eecd139 100644 --- a/core/src/main/scala/cats/syntax/package.scala +++ b/core/src/main/scala/cats/syntax/package.scala @@ -28,7 +28,7 @@ package object syntax { object flatMap extends FlatMapSyntax object foldable extends FoldableSyntax object functor extends FunctorSyntax - object functorEmpty extends FunctorEmptySyntax + object functorFilter extends FunctorFilterSyntax object group extends GroupSyntax object invariant extends InvariantSyntax object ior extends IorSyntax @@ -50,7 +50,7 @@ package object syntax { object show extends ShowSyntax object strong extends StrongSyntax object traverse extends TraverseSyntax - object traverseEmpty extends TraverseEmptySyntax + object traverseFilter extends TraverseFilterSyntax object nonEmptyTraverse extends NonEmptyTraverseSyntax object unorderedTraverse extends UnorderedTraverseSyntax object validated extends ValidatedSyntax with ValidatedExtensionSyntax diff --git a/core/src/main/scala/cats/syntax/traverseEmpty.scala b/core/src/main/scala/cats/syntax/traverseEmpty.scala deleted file mode 100644 index bfe49e712f2..00000000000 --- a/core/src/main/scala/cats/syntax/traverseEmpty.scala +++ /dev/null @@ -1,4 +0,0 @@ -package cats -package syntax - -trait TraverseEmptySyntax extends TraverseEmpty.ToTraverseEmptyOps diff --git a/core/src/main/scala/cats/syntax/traverseFilter.scala b/core/src/main/scala/cats/syntax/traverseFilter.scala new file mode 100644 index 00000000000..794caeddee1 --- /dev/null +++ b/core/src/main/scala/cats/syntax/traverseFilter.scala @@ -0,0 +1,4 @@ +package cats +package syntax + +trait TraverseFilterSyntax extends TraverseFilter.ToTraverseFilterOps diff --git a/laws/src/main/scala/cats/laws/FunctorEmptyLaws.scala b/laws/src/main/scala/cats/laws/FunctorFilterLaws.scala similarity index 80% rename from laws/src/main/scala/cats/laws/FunctorEmptyLaws.scala rename to laws/src/main/scala/cats/laws/FunctorFilterLaws.scala index 814580896c5..32af361b1d7 100644 --- a/laws/src/main/scala/cats/laws/FunctorEmptyLaws.scala +++ b/laws/src/main/scala/cats/laws/FunctorFilterLaws.scala @@ -2,8 +2,8 @@ package cats package laws -trait FunctorEmptyLaws[F[_]] { - implicit def F: FunctorEmpty[F] +trait FunctorFilterLaws[F[_]] { + implicit def F: FunctorFilter[F] implicit def functor: Functor[F] = F.functor @@ -32,7 +32,7 @@ trait FunctorEmptyLaws[F[_]] { } } -object FunctorEmptyLaws { - def apply[F[_]](implicit ev: FunctorEmpty[F]): FunctorEmptyLaws[F] = - new FunctorEmptyLaws[F] { def F: FunctorEmpty[F] = ev } +object FunctorFilterLaws { + def apply[F[_]](implicit ev: FunctorFilter[F]): FunctorFilterLaws[F] = + new FunctorFilterLaws[F] { def F: FunctorFilter[F] = ev } } diff --git a/laws/src/main/scala/cats/laws/TraverseEmptyLaws.scala b/laws/src/main/scala/cats/laws/TraverseFilterLaws.scala similarity index 83% rename from laws/src/main/scala/cats/laws/TraverseEmptyLaws.scala rename to laws/src/main/scala/cats/laws/TraverseFilterLaws.scala index 5c98a459cbb..bd799fa8f67 100644 --- a/laws/src/main/scala/cats/laws/TraverseEmptyLaws.scala +++ b/laws/src/main/scala/cats/laws/TraverseFilterLaws.scala @@ -5,8 +5,8 @@ import cats.data.Nested import cats.syntax.all._ import cats.instances.option._ -trait TraverseEmptyLaws[F[_]] extends FunctorEmptyLaws[F] { - implicit override def F: TraverseEmpty[F] +trait TraverseFilterLaws[F[_]] extends FunctorFilterLaws[F] { + implicit override def F: TraverseFilter[F] def traverseFilterIdentity[G[_]: Applicative, A](fa: F[A]): IsEq[G[F[A]]] = { fa.traverseFilter(_.some.pure[G]) <-> fa.pure[G] @@ -35,7 +35,7 @@ trait TraverseEmptyLaws[F[_]] extends FunctorEmptyLaws[F] { } } -object TraverseEmptyLaws { - def apply[F[_]](implicit ev: TraverseEmpty[F]): TraverseEmptyLaws[F] = - new TraverseEmptyLaws[F] { def F: TraverseEmpty[F] = ev } +object TraverseFilterLaws { + def apply[F[_]](implicit ev: TraverseFilter[F]): TraverseFilterLaws[F] = + new TraverseFilterLaws[F] { def F: TraverseFilter[F] = ev } } diff --git a/laws/src/main/scala/cats/laws/discipline/FunctorEmptyTests.scala b/laws/src/main/scala/cats/laws/discipline/FunctorFilterTests.scala similarity index 79% rename from laws/src/main/scala/cats/laws/discipline/FunctorEmptyTests.scala rename to laws/src/main/scala/cats/laws/discipline/FunctorFilterTests.scala index 38fe5e7a670..01fead48a2d 100644 --- a/laws/src/main/scala/cats/laws/discipline/FunctorEmptyTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/FunctorFilterTests.scala @@ -6,10 +6,10 @@ import org.scalacheck.Prop.forAll import org.scalacheck.Arbitrary import org.typelevel.discipline.Laws -trait FunctorEmptyTests[F[_]] extends Laws { - def laws: FunctorEmptyLaws[F] +trait FunctorFilterTests[F[_]] extends Laws { + def laws: FunctorFilterLaws[F] - def functorEmpty[A, B, C](implicit + def functorFilter[A, B, C](implicit ArbFA: Arbitrary[F[A]], ArbFABoo: Arbitrary[PartialFunction[A, B]], ArbFOA: Arbitrary[F[Option[A]]], @@ -22,7 +22,7 @@ trait FunctorEmptyTests[F[_]] extends Laws { EqFC: Eq[F[C]] ): RuleSet = { new DefaultRuleSet( - name = "functorEmpty", + name = "functorFilter", parent = None, "mapFilter composition" -> forAll(laws.mapFilterComposition[A, B, C] _), "mapFilter map consistency" -> forAll(laws.mapFilterMapConsistency[A, B] _), @@ -33,7 +33,7 @@ trait FunctorEmptyTests[F[_]] extends Laws { } } -object FunctorEmptyTests { - def apply[F[_]: FunctorEmpty]: FunctorEmptyTests[F] = - new FunctorEmptyTests[F] { def laws: FunctorEmptyLaws[F] = FunctorEmptyLaws[F] } +object FunctorFilterTests { + def apply[F[_]: FunctorFilter]: FunctorFilterTests[F] = + new FunctorFilterTests[F] { def laws: FunctorFilterLaws[F] = FunctorFilterLaws[F] } } diff --git a/laws/src/main/scala/cats/laws/discipline/TraverseEmptyTests.scala b/laws/src/main/scala/cats/laws/discipline/TraverseFilterTests.scala similarity index 80% rename from laws/src/main/scala/cats/laws/discipline/TraverseEmptyTests.scala rename to laws/src/main/scala/cats/laws/discipline/TraverseFilterTests.scala index d163b444edb..77dc281eec3 100644 --- a/laws/src/main/scala/cats/laws/discipline/TraverseEmptyTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/TraverseFilterTests.scala @@ -7,10 +7,10 @@ import org.scalacheck.Prop.forAll import org.scalacheck.Arbitrary import cats.instances.option._ -trait TraverseEmptyTests[F[_]] extends FunctorEmptyTests[F] { - def laws: TraverseEmptyLaws[F] +trait TraverseFilterTests[F[_]] extends FunctorFilterTests[F] { + def laws: TraverseFilterLaws[F] - def traverseEmpty[A, B, C](implicit + def traverseFilter[A, B, C](implicit ArbFA: Arbitrary[F[A]], ArbFOA: Arbitrary[F[Option[A]]], ArbFABoo: Arbitrary[PartialFunction[A, B]], @@ -29,8 +29,8 @@ trait TraverseEmptyTests[F[_]] extends FunctorEmptyTests[F] { EqMNFC: Eq[Nested[Option, Option, F[C]]] ): RuleSet = { new DefaultRuleSet( - name = "traverseEmpty", - parent = Some(functorEmpty[A, B, C]), + name = "traverseFilter", + parent = Some(functorFilter[A, B, C]), "traverseFilter identity" -> forAll(laws.traverseFilterIdentity[Option, A] _), "traverseFilter nested composition" -> forAll(laws.traverseFilterComposition[A, B, C, Option, Option] _), "traverseFilter consistent with traverse" -> forAll(laws.traverseFilterConsistentWithTraverse[Option, A] _), @@ -39,7 +39,7 @@ trait TraverseEmptyTests[F[_]] extends FunctorEmptyTests[F] { } } -object TraverseEmptyTests { - def apply[F[_]: TraverseEmpty]: TraverseEmptyTests[F] = - new TraverseEmptyTests[F] { def laws: TraverseEmptyLaws[F] = TraverseEmptyLaws[F] } +object TraverseFilterTests { + def apply[F[_]: TraverseFilter]: TraverseFilterTests[F] = + new TraverseFilterTests[F] { def laws: TraverseFilterLaws[F] = TraverseFilterLaws[F] } } diff --git a/tests/src/test/scala/cats/tests/ChainSuite.scala b/tests/src/test/scala/cats/tests/ChainSuite.scala index 65608886d03..54fed688738 100644 --- a/tests/src/test/scala/cats/tests/ChainSuite.scala +++ b/tests/src/test/scala/cats/tests/ChainSuite.scala @@ -2,7 +2,7 @@ package cats package tests import cats.data.Chain -import cats.laws.discipline.{AlternativeTests, CoflatMapTests, MonadTests, SerializableTests, TraverseEmptyTests, TraverseTests} +import cats.laws.discipline.{AlternativeTests, CoflatMapTests, MonadTests, SerializableTests, TraverseFilterTests, TraverseTests} import cats.kernel.laws.discipline.{EqTests, MonoidTests, OrderTests, PartialOrderTests} import cats.laws.discipline.arbitrary._ @@ -26,8 +26,8 @@ class ChainSuite extends CatsSuite { checkAll("Order[Chain]", SerializableTests.serializable(Order[Chain[Int]])) - checkAll("Chain[Int]", TraverseEmptyTests[Chain].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[Chain]", SerializableTests.serializable(TraverseEmpty[Chain])) + checkAll("Chain[Int]", TraverseFilterTests[Chain].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[Chain]", SerializableTests.serializable(TraverseFilter[Chain])) { implicit val partialOrder = ListWrapper.partialOrder[Int] diff --git a/tests/src/test/scala/cats/tests/ConstSuite.scala b/tests/src/test/scala/cats/tests/ConstSuite.scala index e1f7756da75..d233f91ac50 100644 --- a/tests/src/test/scala/cats/tests/ConstSuite.scala +++ b/tests/src/test/scala/cats/tests/ConstSuite.scala @@ -21,8 +21,8 @@ class ConstSuite extends CatsSuite { checkAll("Const[String, Int] with Option", TraverseTests[Const[String, ?]].traverse[Int, Int, Int, Int, Option, Option]) checkAll("Traverse[Const[String, ?]]", SerializableTests.serializable(Traverse[Const[String, ?]])) - checkAll("Const[String, Int]", TraverseEmptyTests[Const[String, ?]].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[Const[String, ?]]", SerializableTests.serializable(TraverseEmpty[Const[String, ?]])) + checkAll("Const[String, Int]", TraverseFilterTests[Const[String, ?]].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[Const[String, ?]]", SerializableTests.serializable(TraverseFilter[Const[String, ?]])) // Get Apply[Const[C : Semigroup, ?]], not Applicative[Const[C : Monoid, ?]] { diff --git a/tests/src/test/scala/cats/tests/EitherTSuite.scala b/tests/src/test/scala/cats/tests/EitherTSuite.scala index 296453228cd..7f32f456663 100644 --- a/tests/src/test/scala/cats/tests/EitherTSuite.scala +++ b/tests/src/test/scala/cats/tests/EitherTSuite.scala @@ -48,24 +48,24 @@ class EitherTSuite extends CatsSuite { } { - //If a TraverseEmpty for F is defined - implicit val F = ListWrapper.traverseEmpty + //If a TraverseFilter for F is defined + implicit val F = ListWrapper.traverseFilter checkAll("EitherT[ListWrapper, Int, ?]", - TraverseEmptyTests[EitherT[ListWrapper, Int, ?]].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[EitherT[ListWrapper, Int, ?]]", - SerializableTests.serializable(TraverseEmpty[EitherT[ListWrapper, Int, ?]])) + TraverseFilterTests[EitherT[ListWrapper, Int, ?]].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[EitherT[ListWrapper, Int, ?]]", + SerializableTests.serializable(TraverseFilter[EitherT[ListWrapper, Int, ?]])) } { - //If a FunctorEmpty for F is defined - implicit val F = ListWrapper.functorEmpty + //If a functorFilter for F is defined + implicit val F = ListWrapper.functorFilter checkAll("EitherT[ListWrapper, Int, ?]", - FunctorEmptyTests[EitherT[ListWrapper, Int, ?]].functorEmpty[Int, Int, Int]) - checkAll("FunctorEmpty[EitherT[ListWrapper, Int, ?]]", - SerializableTests.serializable(FunctorEmpty[EitherT[ListWrapper, Int, ?]])) + FunctorFilterTests[EitherT[ListWrapper, Int, ?]].functorFilter[Int, Int, Int]) + checkAll("FunctorFilter[EitherT[ListWrapper, Int, ?]]", + SerializableTests.serializable(FunctorFilter[EitherT[ListWrapper, Int, ?]])) } diff --git a/tests/src/test/scala/cats/tests/ListSuite.scala b/tests/src/test/scala/cats/tests/ListSuite.scala index a74cbcc77a9..1e8ed70e04e 100644 --- a/tests/src/test/scala/cats/tests/ListSuite.scala +++ b/tests/src/test/scala/cats/tests/ListSuite.scala @@ -2,7 +2,7 @@ package cats package tests import cats.data.{NonEmptyList, ZipList} -import cats.laws.discipline.{AlternativeTests, CoflatMapTests, CommutativeApplyTests, MonadTests, SemigroupalTests, SerializableTests, TraverseEmptyTests, TraverseTests} +import cats.laws.discipline.{AlternativeTests, CoflatMapTests, CommutativeApplyTests, MonadTests, SemigroupalTests, SerializableTests, TraverseFilterTests, TraverseTests} import cats.laws.discipline.arbitrary._ class ListSuite extends CatsSuite { @@ -22,8 +22,8 @@ class ListSuite extends CatsSuite { checkAll("List[Int]", MonadTests[List].monad[Int, Int, Int]) checkAll("Monad[List]", SerializableTests.serializable(Monad[List])) - checkAll("List[Int]", TraverseEmptyTests[List].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[List]", SerializableTests.serializable(TraverseEmpty[List])) + checkAll("List[Int]", TraverseFilterTests[List].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[List]", SerializableTests.serializable(TraverseFilter[List])) checkAll("ZipList[Int]", CommutativeApplyTests[ZipList].commutativeApply[Int, Int, Int]) diff --git a/tests/src/test/scala/cats/tests/ListWrapper.scala b/tests/src/test/scala/cats/tests/ListWrapper.scala index 2384c64d52a..2f081d77358 100644 --- a/tests/src/test/scala/cats/tests/ListWrapper.scala +++ b/tests/src/test/scala/cats/tests/ListWrapper.scala @@ -56,20 +56,20 @@ object ListWrapper { } } - val traverseEmpty: TraverseEmpty[ListWrapper] = { - val F = TraverseEmpty[List] + val traverseFilter: TraverseFilter[ListWrapper] = { + val F = TraverseFilter[List] - new TraverseEmpty[ListWrapper] { + new TraverseFilter[ListWrapper] { def traverse = ListWrapper.traverse def traverseFilter[G[_], A, B](fa: ListWrapper[A])(f: A => G[Option[B]])(implicit G: Applicative[G]): G[ListWrapper[B]] = G.map(F.traverseFilter(fa.list)(f))(ListWrapper.apply) } } - val functorEmpty: FunctorEmpty[ListWrapper] = { - val F = FunctorEmpty[List] + val functorFilter: FunctorFilter[ListWrapper] = { + val F = FunctorFilter[List] - new FunctorEmpty[ListWrapper] { + new FunctorFilter[ListWrapper] { def functor = ListWrapper.functor def mapFilter[A, B](fa: ListWrapper[A])(f: A => Option[B]): ListWrapper[B] = ListWrapper(F.mapFilter(fa.list)(f)) diff --git a/tests/src/test/scala/cats/tests/MapSuite.scala b/tests/src/test/scala/cats/tests/MapSuite.scala index 591c7942a22..e05d19e5fac 100644 --- a/tests/src/test/scala/cats/tests/MapSuite.scala +++ b/tests/src/test/scala/cats/tests/MapSuite.scala @@ -2,7 +2,7 @@ package cats package tests -import cats.laws.discipline.{FlatMapTests, FunctorEmptyTests, SemigroupalTests, SerializableTests, UnorderedTraverseTests, ComposeTests} +import cats.laws.discipline.{FlatMapTests, FunctorFilterTests, SemigroupalTests, SerializableTests, UnorderedTraverseTests, ComposeTests} import cats.laws.discipline.arbitrary._ import cats.arrow.Compose @@ -18,8 +18,8 @@ class MapSuite extends CatsSuite { checkAll("Map[Int, Int] with Option", UnorderedTraverseTests[Map[Int, ?]].unorderedTraverse[Int, Int, Int, Option, Option]) checkAll("UnorderedTraverse[Map[Int, ?]]", SerializableTests.serializable(UnorderedTraverse[Map[Int, ?]])) - checkAll("Map[Int, Int]", FunctorEmptyTests[Map[Int, ?]].functorEmpty[Int, Int, Int]) - checkAll("FunctorEmpty[Map[Int, ?]]", SerializableTests.serializable(FunctorEmpty[Map[Int, ?]])) + checkAll("Map[Int, Int]", FunctorFilterTests[Map[Int, ?]].FunctorFilter[Int, Int, Int]) + checkAll("FunctorFilter[Map[Int, ?]]", SerializableTests.serializable(FunctorFilter[Map[Int, ?]])) checkAll("Map[Int, Long]", ComposeTests[Map].compose[Int, Long, String, Double]) checkAll("Compose[Map]", SerializableTests.serializable(Compose[Map])) diff --git a/tests/src/test/scala/cats/tests/NestedSuite.scala b/tests/src/test/scala/cats/tests/NestedSuite.scala index f5bd48f17eb..9b1802a9322 100644 --- a/tests/src/test/scala/cats/tests/NestedSuite.scala +++ b/tests/src/test/scala/cats/tests/NestedSuite.scala @@ -26,13 +26,13 @@ class NestedSuite extends CatsSuite { } { - // TraverseEmpty composition - implicit val instance = ListWrapper.traverseEmpty + // TraverseFilter composition + implicit val instance = ListWrapper.traverseFilter implicit val traverseInstance = ListWrapper.traverse checkAll("Nested[ListWrapper, ListWrapper]", - TraverseEmptyTests[Nested[ListWrapper, ListWrapper, ?]].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[Nested[ListWrapper, ListWrapper, ?]]", - SerializableTests.serializable(TraverseEmpty[Nested[ListWrapper, ListWrapper, ?]])) + TraverseFilterTests[Nested[ListWrapper, ListWrapper, ?]].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[Nested[ListWrapper, ListWrapper, ?]]", + SerializableTests.serializable(TraverseFilter[Nested[ListWrapper, ListWrapper, ?]])) } { diff --git a/tests/src/test/scala/cats/tests/OptionSuite.scala b/tests/src/test/scala/cats/tests/OptionSuite.scala index 8604b3b7d92..ae36f201298 100644 --- a/tests/src/test/scala/cats/tests/OptionSuite.scala +++ b/tests/src/test/scala/cats/tests/OptionSuite.scala @@ -21,8 +21,8 @@ class OptionSuite extends CatsSuite { checkAll("Option[Int] with Option", TraverseTests[Option].traverse[Int, Int, Int, Int, Option, Option]) checkAll("Traverse[Option]", SerializableTests.serializable(Traverse[Option])) - checkAll("Option[Int] with Option", TraverseEmptyTests[Option].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[Option]", SerializableTests.serializable(TraverseEmpty[Option])) + checkAll("Option[Int] with Option", TraverseFilterTests[Option].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[Option]", SerializableTests.serializable(TraverseFilter[Option])) checkAll("Option with Unit", MonadErrorTests[Option, Unit].monadError[Int, Int, Int]) checkAll("MonadError[Option, Unit]", SerializableTests.serializable(MonadError[Option, Unit])) diff --git a/tests/src/test/scala/cats/tests/OptionTSuite.scala b/tests/src/test/scala/cats/tests/OptionTSuite.scala index d1223280be5..bf34daa456f 100644 --- a/tests/src/test/scala/cats/tests/OptionTSuite.scala +++ b/tests/src/test/scala/cats/tests/OptionTSuite.scala @@ -10,7 +10,7 @@ class OptionTSuite extends CatsSuite { implicit val iso = SemigroupalTests.Isomorphisms.invariant[OptionT[ListWrapper, ?]](OptionT.catsDataFunctorForOptionT(ListWrapper.functor)) checkAll("OptionT[Eval, ?]", DeferTests[OptionT[Eval, ?]].defer[Int]) - checkAll("OptionT[Eval, ?]", FunctorEmptyTests[OptionT[Eval, ?]].functorEmpty[Int, Int, Int]) + checkAll("OptionT[Eval, ?]", FunctorFilterTests[OptionT[Eval, ?]].functorFilter[Int, Int, Int]) { diff --git a/tests/src/test/scala/cats/tests/SortedMapSuite.scala b/tests/src/test/scala/cats/tests/SortedMapSuite.scala index 13283fe6623..5c4af5c6fd1 100644 --- a/tests/src/test/scala/cats/tests/SortedMapSuite.scala +++ b/tests/src/test/scala/cats/tests/SortedMapSuite.scala @@ -3,7 +3,7 @@ package tests import cats.kernel.CommutativeMonoid import cats.kernel.laws.discipline.{CommutativeMonoidTests, HashTests, MonoidTests} -import cats.laws.discipline.{FlatMapTests, SemigroupalTests, SerializableTests, TraverseEmptyTests, TraverseTests} +import cats.laws.discipline.{FlatMapTests, SemigroupalTests, SerializableTests, TraverseFilterTests, TraverseTests} import cats.laws.discipline.arbitrary._ import scala.collection.immutable.SortedMap @@ -20,8 +20,8 @@ class SortedMapSuite extends CatsSuite { checkAll("SortedMap[Int, Int] with Option", TraverseTests[SortedMap[Int, ?]].traverse[Int, Int, Int, Int, Option, Option]) checkAll("Traverse[SortedMap[Int, ?]]", SerializableTests.serializable(Traverse[SortedMap[Int, ?]])) - checkAll("SortedMap[Int, Int]", TraverseEmptyTests[SortedMap[Int, ?]].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[SortedMap[Int, ?]]", SerializableTests.serializable(TraverseEmpty[SortedMap[Int, ?]])) + checkAll("SortedMap[Int, Int]", TraverseFilterTests[SortedMap[Int, ?]].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[SortedMap[Int, ?]]", SerializableTests.serializable(TraverseFilter[SortedMap[Int, ?]])) test("show isn't empty and is formatted as expected") { forAll { (map: SortedMap[Int, String]) => diff --git a/tests/src/test/scala/cats/tests/StreamSuite.scala b/tests/src/test/scala/cats/tests/StreamSuite.scala index 75a7a5d1beb..25f7c1bb4df 100644 --- a/tests/src/test/scala/cats/tests/StreamSuite.scala +++ b/tests/src/test/scala/cats/tests/StreamSuite.scala @@ -1,7 +1,7 @@ package cats package tests -import cats.laws.discipline.{AlternativeTests, CoflatMapTests, CommutativeApplyTests, MonadTests, SemigroupalTests, SerializableTests, TraverseEmptyTests, TraverseTests} +import cats.laws.discipline.{AlternativeTests, CoflatMapTests, CommutativeApplyTests, MonadTests, SemigroupalTests, SerializableTests, TraverseFilterTests, TraverseTests} import cats.data.ZipStream import cats.laws.discipline.arbitrary._ @@ -21,8 +21,8 @@ class StreamSuite extends CatsSuite { checkAll("Stream[Int] with Option", TraverseTests[Stream].traverse[Int, Int, Int, Set[Int], Option, Option]) checkAll("Traverse[Stream]", SerializableTests.serializable(Traverse[Stream])) - checkAll("Stream[Int]", TraverseEmptyTests[Stream].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[Stream]", SerializableTests.serializable(TraverseEmpty[Stream])) + checkAll("Stream[Int]", TraverseFilterTests[Stream].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[Stream]", SerializableTests.serializable(TraverseFilter[Stream])) // Can't test applicative laws as they don't terminate checkAll("ZipStream[Int]", CommutativeApplyTests[ZipStream].apply[Int, Int, Int]) diff --git a/tests/src/test/scala/cats/tests/VectorSuite.scala b/tests/src/test/scala/cats/tests/VectorSuite.scala index aff1464dddd..1d9562f8fa7 100644 --- a/tests/src/test/scala/cats/tests/VectorSuite.scala +++ b/tests/src/test/scala/cats/tests/VectorSuite.scala @@ -2,7 +2,7 @@ package cats package tests import cats.data.{NonEmptyVector, ZipVector} -import cats.laws.discipline.{AlternativeTests, CoflatMapTests, CommutativeApplyTests, MonadTests, SemigroupalTests, SerializableTests, TraverseEmptyTests, TraverseTests} +import cats.laws.discipline.{AlternativeTests, CoflatMapTests, CommutativeApplyTests, MonadTests, SemigroupalTests, SerializableTests, TraverseFilterTests, TraverseTests} import cats.laws.discipline.arbitrary._ class VectorSuite extends CatsSuite { @@ -21,8 +21,8 @@ class VectorSuite extends CatsSuite { checkAll("Vector[Int]", MonadTests[Vector].monad[Int, Int, Int]) checkAll("Monad[Vector]", SerializableTests.serializable(Monad[Vector])) - checkAll("Vector[Int]", TraverseEmptyTests[Vector].traverseEmpty[Int, Int, Int]) - checkAll("TraverseEmpty[Vector]", SerializableTests.serializable(TraverseEmpty[Vector])) + checkAll("Vector[Int]", TraverseFilterTests[Vector].traverseFilter[Int, Int, Int]) + checkAll("TraverseFilter[Vector]", SerializableTests.serializable(TraverseFilter[Vector])) checkAll("ZipVector[Int]", CommutativeApplyTests[ZipVector].commutativeApply[Int, Int, Int])