Cats 2.2.0-M1
Pre-releasePlease 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
- #3043 Move standard library type class instances into implicit scope by @travisbrown
- #3241 Reimplemented MonadError[FreeT[...]] to be correct by @djspiewak
- #3361 Restrict attemptNarrow to subtypes of Throwable by @travisbrown
2 bug fixes
- #3306 Make cats.syntax.flatMap include untilDefinedM by @travisbrown
- #3305 Add cats.syntax.hash by @travisbrown
31 API/feature enhancements
- #3321 Reinstate @johnynek's intercalate optimization from #3279 by @travisbrown
- #3374 Add EitherT.liftAttemptK by @kubukoz
- #3168 Use
getOrElse
inNonEmptyList#last
by @PeterPerhac - #2689 Add
orElseRaise
syntax forApplicativeError
by @kubukoz - #3372 Add zipAll to Align typeclass by @dantb
- #3328 Fix short circuiting behaviour in
traverse
andtraverseFilter
by @gagandeepkalra - #3362 Prepend a Vector to a NonEmptyVector by @ssanj
- #3361 Restrict attemptNarrow to subtypes of Throwable by @travisbrown
- #3346 Add Either.unit, use in Applicative[Either[A, ?]] by @rossabaker
- #3323 Re-encode relationships to avoid implicit conversion functions by @travisbrown
- #3316 Add semiflatTap and leftSemiflatTap functions to EitherT by @matwojcik
- #3324 Use ArraySeq.untagged instead of ClassTag[Nothing] by @travisbrown
- #3235 Added flatMapK to FreeT by @djspiewak
- #3279 Add Semigroup and Monoid combinators reverse and intercalate by @johnynek
- #3303 Use unlimited MathContext for BigDecimal arithmetic by @travisbrown
- #3307 Clean up some NonEmpty stuff by @travisbrown
- #3283 Optimize traverse by @travisbrown
- #3294 Add traverseEither by @LukaJCB
- #3302 ArraySeq instance follow-up by @travisbrown
- #3278 Issue 2304: Missing functions for RWST by @barambani
- #3273 Adding instances for ArraySeq by @BalmungSan
- #3274 Add ContT.liftF and ContT.liftK by @lavrov
- #3263 Avoid syntax methods in implementations in cats-core by @travisbrown
- #3261 Fix compiler warnings in tests by @travisbrown
- #3255 More Dotty compat stuff in tests by @travisbrown
- #3254 Use dotty-friendly kind-projector placeholder by @travisbrown
- #3253 Some Dotty compat for tests by @travisbrown
- #3239 add List#scanLeftNel and List#scanRightNel by @enzief
- #3237 Follow up to #3233 by @strong-zero
- #3233 Add when and unless to OptionT by @strong-zero
- #3230 Add two casts to satisfy Dotty by @travisbrown
- #3225 Publicize Free#foldStep by @djspiewak
11 documentation improvements
- #3301 Cats package: add comprehensive scaladoc. by @diesalbla
- #3364 Fix typo by @MaT1g3R
- #3314 Fix doc examples for Ior.map by @ybasket
- #3290 Update readme with latest cats-core version by @leusgalvan
- #3285 Remove machinist from colophon microsite page by @markusa380
- #3272 Fix typo on Chain docs by @LLCampos
- #3265 Copyright and license by @travisbrown
- #3229 fixes #3206 remove references to waffle.io by @ssikdar1
- #3226 Update kind-projector and simulacrum url by @xuwei-k
- #3224 Add a Developer-Comment regarding an unused parameter. by @diesalbla
- #3221 Fix typos by @bwignall
38 build improvements
- #3193 Expand kind-projector's syntax for polymorphic function values by @travisbrown
- #3365 Update sbt-microsites to 1.1.5 by @scala-steward
- #3371 Update sbt-sonatype to 3.9.2 by @scala-steward
- #3325 Specific commutativity and associativity tests for BigDecimal by @travisbrown
- #3342 Fix
Foldable
doctest to useseparateFoldable
instead ofseparate
by @gagandeepkalra - #3352 Update sbt-microsites to 1.1.3 by @scala-steward
- #3354 Change review policy for PRs that don't target master by @travisbrown
- #3319 Update changelog by @travisbrown
- #3337 Update Scalafmt to 2.4.2 by @travisbrown
- #3331 Update sbt-mima-plugin to 0.7.0 by @scala-steward
- #3326 Update snakeyaml to 1.26 by @scala-steward
- #3344 Update sbt-scalafmt to 2.3.2 by @scala-steward
- #3350 Add Align lawful tests for Option instance by @gagandeepkalra
- #3304 Replace instance trait inheritance with imports in tests by @travisbrown
- #3322 Add parentheses for Dotty by @travisbrown
- #3311 Update sbt-microsites to 1.1.2 by @scala-steward
- #3310 Update discipline-scalatest by @travisbrown
- #3308 Update scalacheck-1-14 to 3.1.1.0 by @scala-steward
- #3291 Update sbt-scalajs-crossproject to 1.0.0 by @scala-steward
- #3284 Update sbt to 1.3.8 by @scala-steward
- #3288 Update sbt-mima-plugin to 0.6.4 by @scala-steward
- #3282 Update sbt-mima-plugin to 0.6.3 by @scala-steward
- #3276 Update sbt-unidoc to 0.4.3 by @scala-steward
- #3267 Update sbt-scalajs to 0.6.32 by @scala-steward
- #3268 Update sbt-doctest with ScalaTest 3.1.0 and Dotty fixes by @travisbrown
- #3266 Update discipline-scalatest to 1.0.0 by @scala-steward
- #3277 Update sbt-scalafmt to 2.3.1 by @scala-steward
- #3246 Minor changes for Scala.js 1.0 compatibility by @travisbrown
- #3259 Update discipline-scalatest by @travisbrown
- #3258 Update sbt-release to 1.0.13 by @scala-steward
- #3257 Update sbt to 1.3.7 by @scala-steward
- #3251 Update sbt-microsites to 1.1.0 by @scala-steward
- #3250 Avoid ScalaTest 3.1.0 deprecations by @travisbrown
- #3244 Update discipline-scalatest and scalatestplus dependency by @travisbrown
- #3243 Remove unused Scala Native sbt plugin by @travisbrown
- #3232 Update Scalafmt to 2.3.2 by @travisbrown
- #3231 Drop cats-macros project by @travisbrown
- #3227 Update sbt to 1.3.6 by @scala-steward
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.