I’m glad to announce the first public release of dotty-cps-async. This release depends on the published version of the compiler and can-be downloaded from maven central.
Full implementation of async/await: all language constructions are supported.
Produce optimized code: the number of monad brackets is equal to the number of async operations, sequential parts run without additional overhead.
Pluggable interface for continuation monads.
Limited support for high-order functions:
urls.map( httpClient.fetch(_) ).map(await(_))can be an idiomatic way to fetch all URLs from the list in parallel.
Miscellaneous additional futures, such as automatic coloring, custom value discard, and sip22 compatibility layer.
- Documentation: https://rssh.github.io/dotty-cps-async/
- Project on Github: https://github.com/rssh/dotty-cps-async
- SIP-22 compatible shim: https://github.com/rssh/shim--scala-async--dotty-cps-async
Some extra words about compatibility with scala2:
import cps.compact.sip22 provides a SIP22-like interface. All test cases from the original Scala-Async distribution successfully passed with a change of imports only and included in the regression suite.
It is also possible to compile sip22 async code without changing the source code with shim’s help: add to the dependencies’ shim-scala-async-dotty-cps-async’ to scala3 dependencies instead scala-async for scala2.
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 scala2 async, you should wait for the port of the original XAsync compiler plugin.