Cats 2.2.0
The most significant change in the 2.2.0 release is that all Cats type class instances for standard library types are now available in implicit scope, and no longer have to be imported. This has a number of benefits, including faster compile times and fewer things to think about. Please see this pull request, this blog post, the 2.2.0-M1 release notes, and the migration guide below for more detailed information about this change.
This release is verified to be backward binary compatible with all 2.1.x and 2.0.x releases (and with 1.x for the non-laws modules). It is also binary compatible with the last two 2.2.0 release candidates (RC3 and RC4), but has minor binary incompatibilities with the earlier release candidates.
While this release is not guaranteed to be 100% source-compatible with previous release series, most updates should not require changes. You may want to adjust your imports in order to use the new implicit scope type class instances, but this is only an optimization (it may improve your compile times). If you are using Scala Steward these adjustments will be made for you.
This is the first general-availability release that does not include cats-macros artifacts. This module has been empty since Cats 1.x, but if you explicitly depend on it for some reason, you'll have to remove it from your build.
This release is published for Scala 2.12 and 2.13 and for Scala.js 1.x. We dropped support for Scala.js 0.6 in 2.2.0-M3.
There have been 261 pull requests merged since the 2.1.0 release last December, and the list below only includes PRs that have been merged since the last release candidate.
3 API / feature enhancements
- #3566 Scalafix rule to remove instance imports when upgrading to 2.2.0 by @cb372
- #3579 Add
toValidated
to TrySyntax by @gagandeepkalra - #3576 Remove unused private method by @takayahilton
3 documentation improvements
- #3586 Fix typo in FoldableTests (constistency -> consistency) by @tmccarthy
- #3581 Add monix-bio to related projects by @Avasil
- #3580 Add Parallel typeclass diagram to docs. by @izeigerman
5 build improvements
- #3591 Update sbt-scalafix to 0.9.20 by @scala-steward
- #3589 Update discipline-munit to 0.2.4 by @scala-steward
- #3588 Update munit-scalacheck to 0.7.12 by @scala-steward
- #3585 Update sbt-dotty to 0.4.2 by @scala-steward
- #3578 Update discipline-scalatest to 2.0.1 by @scala-steward
For a complete record of changes since 2.1.0, please see the release notes for the pre-releases:
- https://github.com/typelevel/cats/releases/tag/v2.2.0-M1
- https://github.com/typelevel/cats/releases/tag/v2.2.0-M2
- https://github.com/typelevel/cats/releases/tag/v2.2.0-M3
- https://github.com/typelevel/cats/releases/tag/v2.2.0-RC1
- https://github.com/typelevel/cats/releases/tag/v2.2.0-RC2
- https://github.com/typelevel/cats/releases/tag/v2.2.0-RC3
- https://github.com/typelevel/cats/releases/tag/v2.2.0-RC4
Migration
In most cases all that's necessary to switch to using the new implicit scope instances is to replace cats.implicits._
imports with cats.syntax.all._
and delete any cats.instances
imports. You don't have to make this change to use Cats 2.2.x, though, since this release doesn't remove anything. Importing cats.implicits._
will do exactly the same thing on Cats 2.1.x and 2.2.x, since imported instances have higher priority than implicit scope. You just won't see improvements in compile times.
There is one exception to this rule. The cats.implicits
package provides implicit conversions from Cats's own Order
and PartialOrder
type classes to the standard library's Ordering
and PartialOrdering
. This conversion is not available in implicit scope, because it would be a bad idea for Cats to put instances of type classes it doesn't own into scope for types that it doesn't own (and also because it's not possible).
For example the following code compiles on all Cats versions:
import cats.instances.all._
Ordering[List[Int]]
The standard library doesn't provide an Ordering
for List[Int]
in implicit scope, but Cats provides both an Order[List[Int]]
and an implicit conversion from cats.Order
to scala.math.Ordering
, so this code compiles.
In this case you can't simply remove the import, though, since while the Order
instance will be available without it, the Ordering
conversion won't be:
scala> cats.Order[List[Int]]
res0: cats.kernel.Order[List[Int]] = cats.kernel.instances.ListOrder@91da5ff
scala> Ordering[List[Int]]
^
error: No implicit Ordering defined for List[Int].
Instead you can either leave the import as it is, or change it to the more minimal cats.instances.order._
.