From af487e1001c83e32460f0ea659fa3034cd20fe77 Mon Sep 17 00:00:00 2001 From: Andy Scott Date: Wed, 10 Jan 2018 18:52:26 -0800 Subject: [PATCH] Add missing .unorderedTraverse syntax --- core/src/main/scala/cats/implicits.scala | 5 ++++- core/src/main/scala/cats/syntax/all.scala | 7 +++++++ core/src/main/scala/cats/syntax/package.scala | 3 ++- .../src/main/scala/cats/syntax/unorderedTraverse.scala | 4 ++++ testkit/src/main/scala/cats/tests/CatsSuite.scala | 4 ++-- .../test/scala/cats/tests/UnorderedTraverseSuite.scala | 10 ++++++++++ 6 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 core/src/main/scala/cats/syntax/unorderedTraverse.scala create mode 100644 tests/src/test/scala/cats/tests/UnorderedTraverseSuite.scala diff --git a/core/src/main/scala/cats/implicits.scala b/core/src/main/scala/cats/implicits.scala index fc5604da63e..892f7bda86b 100644 --- a/core/src/main/scala/cats/implicits.scala +++ b/core/src/main/scala/cats/implicits.scala @@ -1,3 +1,6 @@ package cats -object implicits extends syntax.AllSyntax with instances.AllInstances +object implicits + extends syntax.AllSyntax + with syntax.AllSyntaxBinCompat0 + with instances.AllInstances diff --git a/core/src/main/scala/cats/syntax/all.scala b/core/src/main/scala/cats/syntax/all.scala index 68fe3868fa7..926a0a7c473 100644 --- a/core/src/main/scala/cats/syntax/all.scala +++ b/core/src/main/scala/cats/syntax/all.scala @@ -1,6 +1,10 @@ package cats package syntax +abstract class AllSyntaxBinCompat + extends AllSyntax + with AllSyntaxBinCompat0 + trait AllSyntax extends AlternativeSyntax with ApplicativeSyntax @@ -48,3 +52,6 @@ trait AllSyntax with ValidatedSyntax with VectorSyntax with WriterSyntax + +trait AllSyntaxBinCompat0 + extends UnorderedTraverseSyntax diff --git a/core/src/main/scala/cats/syntax/package.scala b/core/src/main/scala/cats/syntax/package.scala index 6ce9e45ff98..b928818bc9c 100644 --- a/core/src/main/scala/cats/syntax/package.scala +++ b/core/src/main/scala/cats/syntax/package.scala @@ -1,7 +1,7 @@ package cats package object syntax { - object all extends AllSyntax + object all extends AllSyntaxBinCompat object alternative extends AlternativeSyntax object applicative extends ApplicativeSyntax object applicativeError extends ApplicativeErrorSyntax @@ -46,6 +46,7 @@ package object syntax { object strong extends StrongSyntax object traverse extends TraverseSyntax object nonEmptyTraverse extends NonEmptyTraverseSyntax + object unorderedTraverse extends UnorderedTraverseSyntax object validated extends ValidatedSyntax object vector extends VectorSyntax object writer extends WriterSyntax diff --git a/core/src/main/scala/cats/syntax/unorderedTraverse.scala b/core/src/main/scala/cats/syntax/unorderedTraverse.scala new file mode 100644 index 00000000000..5d9349b790c --- /dev/null +++ b/core/src/main/scala/cats/syntax/unorderedTraverse.scala @@ -0,0 +1,4 @@ +package cats +package syntax + +trait UnorderedTraverseSyntax extends UnorderedTraverse.ToUnorderedTraverseOps diff --git a/testkit/src/main/scala/cats/tests/CatsSuite.scala b/testkit/src/main/scala/cats/tests/CatsSuite.scala index eba024e1e8f..2caff3e3119 100644 --- a/testkit/src/main/scala/cats/tests/CatsSuite.scala +++ b/testkit/src/main/scala/cats/tests/CatsSuite.scala @@ -4,7 +4,7 @@ package tests import catalysts.Platform import cats.instances.AllInstances -import cats.syntax.{AllSyntax, EqOps} +import cats.syntax.{AllSyntax, AllSyntaxBinCompat0, EqOps} import org.scalactic.anyvals.{PosZDouble, PosInt, PosZInt} import org.scalatest.{FunSuite, FunSuiteLike, Matchers} @@ -36,7 +36,7 @@ trait CatsSuite extends FunSuite with Discipline with TestSettings with AllInstances - with AllSyntax + with AllSyntax with AllSyntaxBinCompat0 with StrictCatsEquality { self: FunSuiteLike => implicit override val generatorDrivenConfig: PropertyCheckConfiguration = diff --git a/tests/src/test/scala/cats/tests/UnorderedTraverseSuite.scala b/tests/src/test/scala/cats/tests/UnorderedTraverseSuite.scala new file mode 100644 index 00000000000..f4747f4a8da --- /dev/null +++ b/tests/src/test/scala/cats/tests/UnorderedTraverseSuite.scala @@ -0,0 +1,10 @@ +package cats +package tests + +class UnorderedTraverseSuite extends CatsSuite { + test("UnorderedTraverse[Set[Int]].unorderedTraverse via syntax") { + forAll { (ins: Set[Int]) => + ins.unorderedTraverse(in => in: Id[Int]).toList.sorted should === (ins.toList.sorted) + } + } +}