Skip to content

Cats 2.2.0-M1

Pre-release
Pre-release
Compare
Choose a tag to compare
@travisbrown travisbrown released this
v2.2.0-M1
72637ce

Please note that this is a milestone release and should be considered experimental. It includes significant changes that may break source compatibility in some situations we haven't foreseen, and it's likely to be followed by subsequent milestone releases in the 2.2.x series that are not guaranteed to be binary-compatible with their milestone predecessors. We're excited about this release and want people to try it out, but please do so carefully (and let us know if you run into issues).

The biggest change in this release is that Cats's 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, or the migration guide below for more information about this change.

While this release is guaranteed by MiMa to be binary compatible with all 2.x releases (and with 1.x for most modules), and while we believe the implicit scope change should be fully source compatible, there are many other changes that may cause your code not to compile, or to behave differently. In particular Cats's BigDecimal arithmetic now works slightly differently on Scala 2.13 than it did in previous releases, the short-circuiting behavior of traverse and traverseFilter has been changed for some instances, and attemptNarrow will no longer compile if its type parameter isn't a subtype of Throwable. If you run into compilation errors or changes you don't understand, please let us know, either by asking a question in the Cats Gitter channel or opening an issue here.

We're also no longer publishing 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 0.6 and 1.x.

We don't currently have a definite timeline for Cats 2.2.0, but it's likely to be out by the end of April (2020).

3 source breaking changes

2 bug fixes

31 API/feature enhancements

11 documentation improvements

38 build improvements

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 are currently two exceptions to this rule. The first is that cats.implicits._ provides implicit conversions from its 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._.

The other instances that aren't included in implicit scope are the ones for the standard library Future. If you've been using on cats.implicits or cats.instances.all to bring these into scope, you'll still need at least cats.instances.future._ (as well as an implicit ExecutionContext). These instances may be included in implicit scope in future releases.