-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Port tests to Dotty #3552
Port tests to Dotty #3552
Conversation
@@ -10,3 +10,4 @@ docstrings = JavaDoc | |||
newlines.afterCurlyLambda = preserve | |||
docstrings.style = Asterisk | |||
docstrings.oneline = unfold | |||
project.excludeFilters = [ "core/src/main/scala-3.x" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scalafmt can't deal with dotty syntax yet.
|
||
import cats.{Monad, Alternative} | ||
|
||
final class MonadOps[F[_], A](private val fa: F[A]) extends AnyVal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to split this out due to scala/scala3#9480
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this flip the order of parameters though? That could be moderately source-incompatible. More importantly, it's inconsistent with the other syntax classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know how dotty compiles this down. Is explicitly
still a thing? Do you have a suggestion on how to fix this given the limitation above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would summon @smarter actually if I hit this. Probably worth looking at the bytecode quickly to see what the parameter order is. Can we simply put the using
block second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's source-compatible (to explicitly pass parameters to a using block, you have to write using
at use-site in front of the block too). I suggested putting the using block first because doing the implicit search requires instantiating type variables which in turns means that in increment.whileM_(inspect(i => i > 4)).run(3)
we can figure out that i
needs to be Int
, see scala/scala3#9480 (comment) for the full explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would increase the maintenance burden though. But if you did want to rewrite all the ops classes for dotty, then you might as well use extension syntax which would look more natural:
extension [F[_], A](fa: F[A])(using M: Monad[F]) {
def whileM_(p: F[Boolean]): F[Unit] = ???
def untilM(...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just concerned that we're going to end up hitting something like this again in the future, but once we release on Dotty, we can't futz with the binary compatibility any further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you can break BC every time we break BC which is every six weeks until 3.0 is out probably, but afterwards it gets tricky yeah :) (though I guess you can always play trick with something like a package-protected overload to preserve BC?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we promising binary compatibility for dotty artifacts? Should we? (We certainly don't test it yet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we're promising BC until Scala 3 goes final. Once it does though, we 100% should be promising it.
@@ -122,7 +122,6 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn | |||
implicit def catsFlatMapForSortedMap[K]: FlatMap[SortedMap[K, *]] = | |||
cats.instances.sortedMap.catsStdInstancesForSortedMap[K] | |||
implicit def catsBimonadForFunction0: Bimonad[Function0] = cats.instances.function.catsStdBimonadForFunction0 | |||
implicit def catsMonadForFunction1[I]: Monad[I => *] = cats.instances.function.catsStdMonadForFunction1[I] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this down because dotty thinks Monad[List]
and Monad[Function1[Int, *]]
are ambiguous
implicit def catsCommutativeFlatMapForTuple2[X](implicit X: CommutativeSemigroup[X]): CommutativeFlatMap[(X, *)] = | ||
cats.instances.tuple.catsStdCommutativeFlatMapForTuple2[X] | ||
|
||
implicit def catsApplicativeForArrow[F[_, _], A](implicit F: Arrow[F]): Applicative[F[A, *]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with this one
@@ -10,6 +10,7 @@ import cats.syntax.parallel._ | |||
import cats.syntax.traverse._ | |||
import cats.syntax.eq._ | |||
import org.scalacheck.Prop._ | |||
import cats.catsInstancesForId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id instances are no longer automatically in scope in dotty.
@@ -506,7 +509,7 @@ class IndexedStateTSuite extends CatsSuite { | |||
Alternative[IndexedStateT[ListWrapper, Int, Int, *]] | |||
Applicative[IndexedStateT[ListWrapper, Int, Int, *]] | |||
Apply[IndexedStateT[ListWrapper, Int, Int, *]] | |||
Functor[IndexedStateT[ListWrapper, Int, Int, *]] | |||
//Functor[IndexedStateT[ListWrapper, Int, Int, *]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ambiguous here because both G
and F
are Functor
s
@@ -536,7 +536,7 @@ class OptionTSuite extends CatsSuite { | |||
Traverse[OptionT[List, *]] | |||
|
|||
implicit val T: Traverse[ListWrapper] = ListWrapper.traverse | |||
implicit val M: Monad[ListWrapper] = ListWrapper.monad | |||
//implicit val M: Monad[ListWrapper] = ListWrapper.monad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
@@ -88,34 +83,37 @@ class ParallelSuite extends CatsSuite with ApplicativeErrorForEitherTest with Sc | |||
} | |||
} | |||
|
|||
type ListTuple2[A, B] = List[(A, B)] | |||
case class ListTuple2[A, B](value: List[(A, B)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to turn this into a case class for it to work
@@ -131,14 +131,14 @@ class ReducibleSuiteAdditional extends CatsSuite { | |||
val n = 100000 | |||
val xs = NES(0, Stream.from(1)) | |||
|
|||
assert(xs.reduceMapM(i => if (i < n) Right(i) else Left(i)) === Left(n)) | |||
assert(xs.reduceMapM(i => if (i < n) i.asRight[Int] else i.asLeft[Int]) === Left(n)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -61,7 +61,7 @@ class ApplicativeErrorSuite extends CatsSuite { | |||
assert(compileErrors("e2.attemptNarrow[Num]").nonEmpty) | |||
|
|||
val e3: Either[List[T[String]], Unit] = List(Str).asLeft[Unit] | |||
assert(compileErrors("e3.attemptNarrow[List[Str.type]]").nonEmpty) | |||
//assertEquals(compileErrors("e3.attemptNarrow[List[Str.type]]"), "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an odd one, because when I try it in the console it gives me an error but munit returns an empty string here
/** | ||
* Placed here to work around scala/bug#6260 on scala 2.10 | ||
*/ | ||
test("#1802 duplicated method name") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted this for now, since it was giving me an error and seems like this is pretty old
@@ -103,7 +103,7 @@ class RegressionSuite extends CatsSuite with ScalaVersionSpecificRegressionSuite | |||
|
|||
test("#500: foldMap - traverse consistency") { | |||
assert( | |||
List(1, 2, 3).traverse(i => Const.of[List[Int]](List(i))).getConst == List(1, 2, 3).foldMap(List(_)) | |||
List(1, 2, 3).traverse(i => Const[List[Int], List[Int]](List(i))).getConst == List(1, 2, 3).foldMap(List(_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dotty was inferring Int => Int
, I'll try to reach out to the dotty team on how to get this working
Codecov Report
@@ Coverage Diff @@
## master #3552 +/- ##
==========================================
- Coverage 91.33% 91.27% -0.06%
==========================================
Files 386 386
Lines 8628 8611 -17
Branches 260 269 +9
==========================================
- Hits 7880 7860 -20
- Misses 748 751 +3 |
|
||
import cats.{Monad, Alternative} | ||
|
||
final class MonadOps[F[_], A](private val fa: F[A]) extends AnyVal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this flip the order of parameters though? That could be moderately source-incompatible. More importantly, it's inconsistent with the other syntax classes.
onFlatMapped: ((S[X], X => Free[S, A]) forSome { type X }) => B | ||
onFlatMapped: ((S[Any], Any => Free[S, A])) => B |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't foldStep
public? This would be a rather drastic change if so. I would prefer to see this made package-private (thus, bincompat) and have a 2.0-specific enrichment which uses forSome
in this skolem rank, while a 3.0-specific enrichment uses a higher-rank universal to achieve the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bincompat due to type erasure, but I believe having separate sources here is probably a good idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely bincompat, I was mostly just concerned about the loss of type safety in a public-facing API.
Seeing a new failure now, opened a bug report at scala/scala3#9793 |
This appears to be fixed in scala/scala3#9937, which is scheduled for 3.0.0-M1, so I guess we'll have to wait for that. |
I just realized that the milestone date is end of year 😬 Maybe let's try this instead: 300a9cd |
Codecov Report
@@ Coverage Diff @@
## master #3552 +/- ##
==========================================
- Coverage 91.33% 91.29% -0.05%
==========================================
Files 386 386
Lines 8628 8611 -17
Branches 260 257 -3
==========================================
- Hits 7880 7861 -19
- Misses 748 750 +2 |
M1 should be out next week, the milestone date hasn't been updated |
I made a new PR that is up-to-date: #3636. Obviously we can continue the discussion there. |
No description provided.