Skip to content

Releases: typelevel/cats-effect-direct

v1.0.0

14 Mar 15:54
941d32f

Choose a tag to compare

As the 1.0.0 moniker suggests, this is a pretty massive release. The whole thing has been rewritten from scratch to use dynamic CPS restructuring rather than static. What this means is that rather than relying on macros and syntactic transformations (a la for-comprehension compilation) to achieve direct-style syntax on top of effect types, we're now relying on mechanisms within the underlying runtime platform. On Scala Native, this means the LLVM equivalent of longjmp(). On the JVM, it means java.lang.Continuation, which is the mechanism which underlies virtual threads.

The upshot of this is that .await syntax now works in a large number of contexts in which it couldn't work before. An easy example of this is List#map, which previously had to be either special-cased (on Scala 3) or would result in a compilation error (on Scala 2). With the new implementation, this code works exactly as you would expect:

async[IO]:
  List(1, 2, 3).map(_ => IO(...).await)

Unfortunately, this comes at the cost of some compile-time safety, support for older versions of the JVM, and support for Scala.js. Let's take those one at a time.

A number of syntactically valid uses of the await function are not semantically valid, in that there is no possible way to make the syntax work in a sane way. With static transformation (as in the previous implementation), these sorts of uses would fail to compile, but unfortunately this checking is an overapproximation, preventing a number of semantically valid situations from being addressed. Dynamic transformation (in this release) allows all semantically valid transformations, but also allows compilation of many transformations which are invalid. A simple example:

async[IO]:
  val ioa = IO.println("boo")
  val t = new Thread(() => ioa.await)
  t.start()
  t.join()

The above code is simply invalid: there is no way to do anything sane when await is being called in a totally different thread context than the one in which it was defined. Unfortunately, we can't detect this at compile time anymore, meaning that this code will compile and fail at runtime with an IllegalStateException.

As for JVM versions, we now require Java 21 or higher when running on that platform. This is because java.lang.Continuation was introduced in that version, so the runtime functionality we need to make this work didn't exist previously. Additionally, when running on the JVM, you'll need to provide an extra flag to java when launching your application: --add-exports java.base/jdk.internal.vm=ALL-UNNAMED. This can be done easily in Sbt if using run / fork := true by simply tacking it onto javaOptions.

Finally, Scala.js out of the box has no support for this type of a transformation. Support is provided by WASM, and we intend to implement that functionality in an upcoming release, but vanilla ECMAScript runtimes have no support for this type of continuation mechanism.

Finally finally, we're officially renaming this project to cats-effect-direct (from the previous name, cats-effect-cps). While this is a CPS transformation library, we strongly suspect that anyone for whom the acronym "CPS" is meaningful is more or less self-selected to be uninterested in this type of functionality. When we first released this library, there was no standard term for this type of syntax, but this has changed in recent years, with "direct style" becoming the term of art.

What's Changed

  • Update cats-effect, cats-effect-std to 3.6.2 by @typelevel-steward[bot] in #267
  • Update cats-effect, cats-effect-std to 3.6.3 by @typelevel-steward[bot] in #268
  • Reimplemented everything using Continuation by @djspiewak in #284
  • Updated to Cats Effect 3.7, Scala Native 0.5, and dotty-cps-async 1.0… by @djspiewak in #270
  • Update sbt, scripted-plugin to 1.11.7 by @typelevel-steward[bot] in #276
  • Update scala3-library, ... to 3.3.7 by @typelevel-steward[bot] in #280
  • Update scala-library, scala-reflect to 2.13.18 by @typelevel-steward[bot] in #283
  • Update scala-library, scala-reflect to 2.12.21 by @typelevel-steward[bot] in #285
  • Update sbt-scalajs, scalajs-compiler, ... to 1.20.2 by @typelevel-steward[bot] in #287
  • Update nscplugin, sbt-scala-native to 0.5.10 by @typelevel-steward[bot] in #288
  • Update sbt-typelevel to 0.8.5 by @typelevel-steward[bot] in #289

Full Changelog: v0.5.0...v1.0.0

v0.5.0

07 Jul 19:34
ab47727

Choose a tag to compare

This is likely the last release compatible with Scala Native 0.4.x. Subsequent releases will be updated to SN 0.5.x, which also implies Cats Effect 3.7.x and dotty-cps-async 1.x.

What's Changed

  • explicit disabling of automatic coloring by @rssh in #99
  • Update cats-effect, cats-effect-std to 3.4.2 by @typelevel-steward in #101
  • Update nscplugin, sbt-scala-native, ... to 0.4.9 by @typelevel-steward in #100
  • Update cats-effect, cats-effect-std to 3.4.5 by @typelevel-steward in #110
  • Update cats-effect, cats-effect-std to 3.4.6 by @typelevel-steward in #116
  • Update cats-effect, cats-effect-std to 3.4.8 by @typelevel-steward in #120
  • Update scala3-library, ... to 3.2.2 by @typelevel-steward in #115
  • Update nscplugin, sbt-scala-native, ... to 0.4.10 by @typelevel-steward in #114
  • Update scalafmt-core to 3.7.1 by @typelevel-steward in #113
  • Update sbt to 1.8.2 by @typelevel-steward in #108
  • Update sbt-typelevel to 0.4.18 by @typelevel-steward in #109
  • Update sbt-scalajs, scalajs-compiler, ... to 1.13.0 by @typelevel-steward in #117
  • Update scalafmt-core to 3.7.2 by @typelevel-steward in #121
  • Update sbt-scala-native-crossproject to 1.3.1 by @typelevel-steward in #129
  • Update cats-effect, cats-effect-std to 3.4.9 by @typelevel-steward in #128
  • Update sbt-scalajs, scalajs-compiler, ... to 1.13.1 by @typelevel-steward in #127
  • Update scalafmt-core to 3.7.3 by @typelevel-steward in #125
  • Update nscplugin, sbt-scala-native, ... to 0.4.12 by @typelevel-steward in #124
  • Update sbt-typelevel to 0.4.19 by @typelevel-steward in #122
  • Update cats-effect, cats-effect-std to 3.4.10 by @typelevel-steward in #131
  • Update sbt-typelevel to 0.4.20 by @typelevel-steward in #130
  • Update cats-effect, cats-effect-std to 3.4.11 by @typelevel-steward in #132
  • Update nscplugin, sbt-scala-native, ... to 0.4.14 by @typelevel-steward in #140
  • Update sbt-typelevel to 0.4.22 by @typelevel-steward in #139
  • Update scalafmt-core to 3.7.4 by @typelevel-steward in #136
  • Update cats-effect, cats-effect-std to 3.5.0 by @typelevel-steward in #133
  • Update sbt to 1.8.3 by @typelevel-steward in #134
  • Update sbt to 1.9.0 by @typelevel-steward in #141
  • Update scala3-library, ... to 3.3.0 by @typelevel-steward in #137
  • Update dotty-cps-async to 0.9.16 by @typelevel-steward in #119
  • Update sbt-header to 5.10.0 by @typelevel-steward in #142
  • Update scala-library, scala-reflect to 2.12.18 by @typelevel-steward in #143
  • Update scala-library, scala-reflect to 2.13.11 by @typelevel-steward in #144
  • Update sbt-scalajs, scalajs-compiler, ... to 1.13.2 by @typelevel-steward in #147
  • Update sbt-scalajs, scalajs-compiler, ... to 1.15.0 by @typelevel-steward in #190
  • Update cats-effect, cats-effect-std to 3.5.3 by @typelevel-steward in #191
  • Update sbt to 1.9.8 by @typelevel-steward in #187
  • Update scala-library, scala-reflect to 2.13.12 by @typelevel-steward in #169
  • Update scalafmt-core to 3.7.17 by @typelevel-steward in #185
  • Update sbt-scala-native-crossproject to 1.3.2 by @typelevel-steward in #153
  • Update cats-effect, cats-effect-std to 3.5.4 by @typelevel-steward in #202
  • Update scala3-library, ... to 3.3.3 by @typelevel-steward in #201
  • Update sbt to 1.9.9 by @typelevel-steward in #197
  • Update scalafmt-core to 3.8.0 by @typelevel-steward in #196
  • Update nscplugin, sbt-scala-native, ... to 0.4.17 by @typelevel-steward in #193
  • dotty-cps-async 0.9.20 by @lhns in #203
  • Update scala-library, scala-reflect to 2.12.19 by @typelevel-steward in #199
  • bump sbt-typelevel to 0.7.4 by @samspills in #239
  • Update sbt to 1.10.6 by @typelevel-steward in #236
  • Update cats-effect, cats-effect-std to 3.5.7 by @typelevel-steward in #235
  • Update scalafmt-core to 3.8.3 by @typelevel-steward in #220
  • Update scala3-library, ... to 3.3.4 by @typelevel-steward in #227
  • Update sbt-typelevel to 0.7.7 by @typelevel-steward in #249
  • Update sbt, scripted-plugin to 1.10.11 by @typelevel-steward in #255
  • Update sbt, scripted-plugin to 1.11.1 by @typelevel-steward in #261
  • Update sbt-typelevel to 0.8.0 by @typelevel-steward in #260
  • Update sbt, scripted-plugin to 1.11.3 by @typelevel-steward in #264
  • Update scala3-library, ... to 3.3.6 by @typelevel-steward in #258
  • Update scalafmt-core to 3.8.6 by @typelevel-steward in #248
  • Updated everything stale in preparation for 0.5.0 by @djspiewak in #266

New Contributors

Full Changelog: v0.3.1...v0.5.0

v0.4.0: Scala-native support, CE 3.4.0 bump

17 Nov 17:43
5a4250b

Choose a tag to compare

Noteworthy changes

  • Introduction of Scala-native support, see #88
  • Amends the Scala 2 macro code to avoid expanding into a now deprecated method. See #94

What's Changed

New Contributors

Full Changelog: v0.3.0...v0.3.1

v0.3.0

16 Jul 16:16
v0.3.0
c2dee16

Choose a tag to compare

v0.3.0 Pre-release
Pre-release
  • Updated to dotty-cps-async 0.9.0. This was a breaking change to the internal APIs and binary interface but shouldn't have any source-breaking impacts on downstream users.

v0.2.0

28 Jun 16:35
v0.2.0
19528af

Choose a tag to compare

v0.2.0 Pre-release
Pre-release

This release adds support for Scala 3! It is now possible to use cats-effect-cps in all environments and dependency contexts in which it is possible to use Cats Effect itself. Note that the Scala 3 support brings in an upstream dependency, but the tradeoff here is that it also supports a considerably larger subset of the Scala language (within an async block) than does the Scala 2 support. In other words, it should always be possible to take sources which compile on Scala 2 using this library and cross-build them on Scala 3, but it may not always be possible to go in the other direction.

  • Added support for Scala 3 (adds a dependency on rssh/dotty-cps-async when using Scala 3.0.0 or higher)
  • Fixed ScalaJS dependencies

v0.1.0

15 Jun 18:28
v0.1.0

Choose a tag to compare

v0.1.0 Pre-release
Pre-release

This is the first release of Cats Effect CPS! As a reminder, this is an incubator library and we will expect things to continue to change and evolve as we move towards full stability. Once this functionality is stable and considered acceptable by the community, it will be folded into Cats Effect itself and this library will be deprecated.

Support is offered for Scala 2.13 and 2.12, including ScalaJS 1.6.0. Scala 3 is not (at present!) supported; PRs welcome! This library requires Cats Effect 3.