Additional Features

Short syntax for await

It can be helpful when the monad or environment does not support automatic coloring or direct context, but the default await syntax is too heavy. In this case, we define the unary_! operator to use instead of await.

Example:

import cps.syntax.`unary_!`

val x = username + !fetchToken(data)

Inside the async block this will be a synonym for

val x = username + await(fetchToken(data))

SIP-22 compatible interface

This feature provides a compatibility layer for Scala 2 SIP-22 async (implemented in scala-async). When migrating your program from legacy SIP-22 to Scala 3, you can change the imports from

import scala.async.Async.{async, await}

to

import cps.compat.sip22.{async, await}

and use Future-based async/await.

All test cases from the original scala-async distribution are passed with a change of imports only, and included in our regression suite.

It is also possible to compile SIP-22 async code without changing the source code with shim--scala-async--dotty-cps-async’s help.

libraryDependencies += "com.github.rssh" %% "shim-scala-async-dotty-cps-async" % "0.9.7",

Note that compatibility was not a primary goal during the development of dotty-cps-async. The generated code is quite different, so if you need a bug-to-bug compatible version of Scala 2 scala-async, you should use the port of the original -XAsync compiler plugin.