Skip to main content

Arrow 2.3.0

·

Arrow 2.3.0 is out! The main change of this release is the new Optics compiler plug-in, which greatly improves the experience of creating optics in Multiplatform projects and in the IDE. On top of that, this release brings compatibility with new (experimental) features from 2.4.0 and beyond.

Compiler plugin for optics. We have performed an AI-assisted migration of the Arrow Optics KSP plugin to the Kotlin compiler plugin API. This means that generation of optics happens directly during compilation, which allows us to remove the limitation of requiring a manually-written companion object — generating optics is now really simple.

@optics data class User(val id: UserId, val shownName: String)

To use the new compiler plugin-based implementation,

  • Remove any previous configuration of the Arrow Optics KSP plugin,
  • Add id("io.arrow-kt.optics") version "2.3.0.1" to your plugins block.

If you also want to see the generated optics in IntelliJ, go to Help > Edit custom properties, and add the following line and restart.

kotlin.k2.only.bundled.compiler.plugins.enabled=false.

If everything goes well, you'll see the result of the plugin right away in your editor.

Optics plug-in in IDE

Running plugins in the IDE

Note that adding the line above means that Arrow Optics and other compiler plugins are run during IDE operations. This may have an impact on the stability of the IDE experience. Of course, if you get problems by using Arrow Optics, feel free to open an issue.

Improvements to SuspendApp. This library has gotten a lot of love in this release, mostly as bugfixes for corner cases. In addition, you can now explicitly exit.

Non-empty collection literals. Kotlin 2.4.0 features collection literals. In this release we bring compatibility of NonEmptyList and NonEmptySet with it, that means you can now write,

val list: NonEmptyList<Int> = [1, 2, 3]

Given the way the compiler works, empty collection literals [] are correctly marked as an error if a non-empty one is required.

Missing contextual and ignorable functions. The whole Raise API is now exposed through context parameter versions. We have also annotated the API as ignorable when required; that means the unused return value checker has all the required information.