Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing UnorderedTraverse syntax #2148

Merged
merged 1 commit into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/src/main/scala/cats/implicits.scala
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions core/src/main/scala/cats/syntax/all.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package cats
package syntax

abstract class AllSyntaxBinCompat
extends AllSyntax
with AllSyntaxBinCompat0

trait AllSyntax
extends AlternativeSyntax
with ApplicativeSyntax
Expand Down Expand Up @@ -48,3 +52,6 @@ trait AllSyntax
with ValidatedSyntax
with VectorSyntax
with WriterSyntax

trait AllSyntaxBinCompat0
Copy link
Contributor

@kailuowang kailuowang Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more small thing, if we make this one abstract class (and maybe even have it extends AllSyntax) we can add more traits to it going forward.

Copy link
Contributor Author

@andyscott andyscott Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about an abstract class AllSyntaxBinCompat extends AllSyntax with AllSyntaxBinCompat0?

Copy link
Contributor

@kailuowang kailuowang Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then what's the purpose of AllSyntaxBinCompat0? just as a versioning scheme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A downstream consumer can't mix in the abstract class but they could mix in AllSyntax and AllSyntaxBinCompat0 to get roughly the same effect. Without AllSyntaxBinCompat0, but then you'd have to remember that AllSyntax is missing UnorderedTraverse syntax. So it's versioning scheme to facilitate downstream use.

I'm not sure if it's worth it though. It's just an idea.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Makes sense to me

extends UnorderedTraverseSyntax
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/syntax/package.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/scala/cats/syntax/unorderedTraverse.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package cats
package syntax

trait UnorderedTraverseSyntax extends UnorderedTraverse.ToUnorderedTraverseOps
4 changes: 2 additions & 2 deletions testkit/src/main/scala/cats/tests/CatsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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 =
Expand Down
10 changes: 10 additions & 0 deletions tests/src/test/scala/cats/tests/UnorderedTraverseSuite.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}
}