Arrow 1.1.0 is now available

Arrow 1.1.0 is now available

We are happy to announce Arrow 1.1.0, with fixed Maven artifacts, new Effect runtime, resource DSL, optics KSP plugin, and several community contributions.

Thanks for all the feedback and contributions!

Table of Contents

The Effect Runtime

The 1.1.0 release includes the Continuation proposal from Simon Vergauwen with better ergonomics and runtime, which allow users to write idiomatic type-safe polymorphic programs in Kotlin.

Effect<R, A> models suspend () -> R | A and is able to fold into Either, Validated, Option, or your own custom types.

More technical details can be found here.

To migrate to this new runtime, simply refactor your existing code from either, option, or other high-level operators in Arrow 1.0.X, by replacing arrow.core.computations.either to arrow.core.continuations.either, similar for other operators.

This needs to be manually refactored due to several bugs in the ReplaceWith functionality of the Kotlin IDEA plugin.

We suggest using IDEA’s Replace in Files functionality with the above replacement, and Replace All for the whole project. Since the APIs are compatible, this will not result in any breakage of the project.

Effect Migration

More references to try the new high-level operators to write polymorphic programs can be found here:

Resource

One powerful addition to the Resource API is the builder DSL. See an example of Hikari and Exposed below.

fun hikari(config: HikariConfig): Resource<DataSource> =
  Resource.fromCloseable { HikariDataSource(config) }

fun database(ds: DataSource): Resource<Database> =
  Resource(
    acquire = { Database.connect(ds) },
    release = { db, _: ExitCase -> closeAndUnregister(db) }
  )

class DependencyGraph(val database: Database)

fun dependencies(config: HikariConfig): Resource<DependencyGraph> =
  resource {
    val ds = hikari(config).bind()
    val db = database(ds).bind()
    DependencyGraph(db)
  }

The resource DSL allows us to bind on Resource directly, giving us the ability to easily compose external resources in the context of another Resource. Resource guarantees the release of bound resources in success, failure, or cancellation scenarios.

More information on Resource is available here.

New Flow operators in Arrow Fx coroutines

The already available operators on Flow received great responses from the community, and we’ve added a few more in this release.

Resource#asFlow

This new operator is meant to easily consume a Resource in a streaming program using KotlinX Flow. For example, to write a Flow<ByteArrow> to a File:

suspend fun Flow<ByteArray>.writeAll(path: Path): Unit =
  Resource.fromCloseable { path.toFile().outputStream() }
    .asFlow()
    .flatMapConcat { outputStream ->
      this@writeAll.map { outputStream.write(it) }
    }.flowOn(Dispatchers.IO)
    .collect()

Schedule#repeatAsFlow

repeat returns the final output of when the Schedule finished, whereas the new repeatAsFlow emits all intermediate outputs along the way. For this particular example, schedule.repeat{ i++ } == schedule.repeatAsFlow { ii++ }.toList().last().

This is useful when you want to run a Schedule and introspect all intermediate outputs while the Schedule is running.

import io.kotest.matchers.shouldBe

val n = 10
val schedule: Schedule<Int, List<Int>> =
  Schedule.recurs<Int>(n) zipRight Schedule.collect()

var i = 0
schedule.repeat { i++ } shouldBe (0..n).toList()

var ii = 0
schedule.repeatAsFlow { ii++ }.toList() shouldBe (0..n).map { (0..it).toList() }

More information on Schedule is available here.

Maven artifact fix

Maven users were only able to consume Arrow 1.0.1 with a -jvm postfix. This has been fixed in all arrow-libraries. A template for Maven projects can be found here.

Arrow KSP optics plugin

If you’re new to KSP, it provides a simplified compiler plugin API for code generation, which, compared to kapt, natively supports Kotlin declarations and understands the Kotlin AST and Kotlin multi-platform module layouts.

This iteration utilizes the KSP API for the optics plugin. Check out the quickstart or head over to this branch of the Arrow Jvm template for a complete set up.

The minimum setup in build.gradle.kts:

plugins {
  id("com.google.devtools.ksp") version "1.6.20-1.0.4"
}

dependencies {
  ksp("io.arrow-kt:arrow-optics-ksp-plugin:1.1.0")
}

Deprecations

  • arrow.core.computations package as well as the arrow.continuations module are being deprecated and will be removed in the next major release in favor of Effect and EagerEffect in arrow.core.continuations
  • Deprecate some constructors in Resource in favor of the new resource DSL
  • Misleading operators for kotlin.Sequence have been deprecated https://github.com/arrow-kt/arrow/pull/2686
  • Iterable.combineAll in favor of Iterable.fold https://github.com/arrow-kt/arrow/pull/2687
  • Resource.tap removed the type parameter B. This is binary compatible, but breaks the Kotlin API - here opt to remove the Type parameter in a code base
  • arrow.core.computations.eval is being deprecated. Use Eval.value() instead of bind(). This will be turned into an ERROR in the next minor version.
  • arrow.core.computations.ResultEffect was introducing dangerous behavior and is being deprecated and will be turned into an ERROR in the next minor version. Use arrow.core.continuations.result instead.

More community contributions

  • define Dsl as public - #2706 by Imran Malic Settuba
  • Update all dependencies - #2705 by renovate-bot
  • Update link to Arrow Analysis documentation - #2701 by Francisco Diaz
  • Update all dependencies - #2703 by renovate-bot
  • Update plugin dokka to v1.6.20 - #2702 by renovate-bot
  • Update stefanzweifel/git-auto-commit-action action to v4.14.1 - #2700 by renovate-bot
  • Update all dependencies - #2699 by renovate-bot
  • Update all dependencies - #2696 by renovate-bot
  • update - #2698 by Imran Malic Settuba
  • Update libs.versions.toml - #2697 by Imran Malic Settuba
  • Fix Either#isNotEmpty()’s KDoc sample - #2694 by Imran Malic Settuba
  • Update gradle/gradle-build-action action to v2.1.5 - #2695 by renovate-bot
  • Update all dependencies - #2665 by renovate-bot
  • rename traverseX and sequenceX for Iterable - #2692 by Imran Malic Settuba
  • rename Sequence sequenceX, traverseX and deprecate Sequence.some - #2686 by Imran Malic Settuba
  • deprecate combineAll in favour of fold - #2687 by Imran Malic Settuba
  • rm snapshot and update Kotlin label - #2690 by Imran Malic Settuba
  • resource tap deprecation - #2684 by Imran Malic Settuba
  • Update Set up Documentation - #2685 by Imran Malic Settuba
  • fix TOC - #2688 by Imran Malic Settuba
  • generate optics based on targets or all - #2683 by Imran Malic Settuba
  • Schedule.repeatAsFlow - #2676 by Imran Malic Settuba
  • File name generation fix - #2681 by Imran Malic Settuba
  • Update all dependencies (major) - #2673 by renovate-bot
  • fix imports for ksp plugin - #2678 by Imran Malic Settuba
  • add Nullable proposal - #2675 by Imran Malic Settuba
  • Resource.asFlow - #2677 by Imran Malic Settuba
  • remove design doc of Effect - #2674 by Imran Malic Settuba
  • Fix typos reorg resource computation block - #2671 by Imran Malic Settuba
  • deprecate signatures in computations and add Result for continuations - #2669 by Imran Malic Settuba
  • Fix bug in the transaction example - #2667 by SaberCon
  • deprecate arrow.continuation - #2672 by Imran Malic Settuba
  • fix sitemap titles - #2670 by Imran Malic Settuba
  • Transfer Cont from @nomisrev to arrow - #2661 by Imran Malic Settuba
  • Non throwing Retrofit Either adapter - #2621 by Lukasz Kalnik
  • Retrofit adapter: allow null response body for methods returning Unit - #2625 by Lukasz Kalnik
  • Fix broken build main Optics Reflect - #2666 by Simon Vergauwen
  • Update documentation links in README - #2664 by Dmitry Sitnikov
  • Optics based on kotlin.reflect - #2612 by Alejandro Serrano
  • [Optics] Optional getter - #2611 by Alejandro Serrano
  • Update all dependencies - #2663 by renovate-bot
  • Fix link to /patterns/error_handling/ - #2627 by Ilya Pomaskin
  • Update all dependencies - #2659 by renovate-bot
  • Update gradle/gradle-build-action action to v2.1.1 - #2653 by renovate-bot
  • [Optics KSP] Update docs to talk about IDEs - #2655 by Alejandro Serrano
  • Use first, .. instead of a,.. - #2654 by Simon Vergauwen
  • Update README.md - #2631 by Imran Malic Settuba
  • CU-23dm3ye support maven publication - #2652 by Imran Malic Settuba
  • Update arrow gradle version - #2651 by Imran Malic Settuba
  • Move Arrow Optics KSP to main/test hierarchy - #2649 by Alejandro Serrano
  • Update libs.versions.toml - #2648 by Imran Malic Settuba
  • Link Analysis from home page - #2595 by Alejandro Serrano
  • Clean up README after gradle upgrade - #2642 by Felix Divo
  • Update plugin kotest-multiplatform to v5.1.0 - #2645 by renovate-bot
  • Update libs.versions.toml - #2644 by Imran Malic Settuba
  • Update all dependencies to v5.1.0 - #2643 by renovate-bot
  • revert ksp plugin to jvm only - #2640 by Imran Malic Settuba
  • update arrow gradle - #2639 by Imran Malic Settuba
  • Update all dependencies - #2638 by renovate-bot
  • fix typo comment of circuitbreaker - #2637 by Larry Jung
  • Fixes a few typos on the Fx docs - #2620by Julien Terrier
  • Update contributing guide with Knit - #2634 by Lukasz Kalnik
  • [Optics] Show error for generic classes in KSP plug-in - #2636 by Alejandro Serrano
  • Pass Arrow version to publish_doc job - #2633 by Francisco Diaz
  • Fix 404 error in the Core library documentation - #2633 by Mark Karamyar
  • Fix Retrofit adapter test configuration - #2624 by Lukasz Kalnik
  • Update all dependencies - #2628 by renovate-bot
  • run on windows only windows test - #2630 by Imran Malic Settuba
  • Update CONTRIBUTING.md with the new build guide - #2600 by Lukasz Kalnik
  • Bump Arrow Gradle Config to 0.6.1-rc.4 - by Simon Vergauwen
  • [Github Action] Run build on all platforms - #2626 by Simon Vergauwen
  • Disable Gradle scan, and Gradle daemon - by Simon Vergauwen
  • Update all dependencies - #2617 by renovate-bot
  • Disable ksp, and ksp test in Arrow Optics - by Simon Vergauwen
  • Use gradle action everywhere, revery permSize, and add –full-stacktrace everywhere - by Simon Vergauwen
  • Make KSP plugin a JVM module - by Simon Vergauwen
  • Use gradle action, and add –full-stacktrace - by Simon Vergauwen
  • Bump to arrow gradle config rc3 - by Simon Vergauwen
  • Revert back to ./gradlew - by Simon Vergauwen
  • Fix publish file - by Simon Vergauwen
  • Use gradle action for publish, and increase timeout time - by Simon Vergauwen
  • Setup Java publish.yml - by Simon Vergauwen
  • Update publish workflow - by Simon Vergauwen
  • Run ./gradlew before get-arrow-version - by Simon Vergauwen
  • Update publish.yml - by Simon Vergauwen
  • Add lib_version - #2616 by Simon Vergauwen
  • Bump Gradle Config to 0.6.1-RC.1 - #2615 by Simon Vergauwen
  • Update all dependencies - #2566 by renovate-bot
  • Disable parallel gradle - #2614by Simon Vergauwen
  • Fix Gradle an existing connection was forcibly closed by the remote host - #2610 by Simon Vergauwen
  • Update publish gradle opts, and remove gradle cache from tag workflows - by Simon Vergauwen
  • Remove gradle cache from publish workflow - by Simon Vergauwen
  • Fix Windows env settings in publish workflow - #2609 by Raul Raja
  • Fix publish and pull_request workflows (#2608) - #2608 by Javier Segovia Cordoba
  • Change Java memory settings - by Javier Segovia Cordoba
  • Add Java and Gradle settings for both generate tag workflows - by Javier Segovia Cordoba
  • Add generate-alpha-tag - by Javier Segovia Cordoba
  • Change tags regex - by Javier Segovia Cordoba
  • Merge remote-tracking branch ‘origin/main’ into rr-js-add-versioning-plugin - by Javier Segovia Cordoba
  • Re-organize Optics docs - #2583 by Alejandro Serrano
  • Fixing documentation workflow - #2594 by Francisco Diaz
  • Upgrade to kotlinx-coroutines 1.6.0 - #2606 by Alejandro Serrano
  • Job to update the API files - #2605 by Alejandro Serrano
  • Rename arrow-optics-ksp to arrow-optics-ksp-plugin - #2604 by Alejandro Serrano
  • Remove legacy Meta, bring Optics KSP - #2599 by Simon Vergauwen
  • docs(Either): describe the all method - #2551 by Cody Mikol
  • Make sure listHead set works properly - #2589 by Thanh Le
  • Code block style (#2596) by Israel Perez
  • Add JAVA_OPTS and GRADLE_OPTS to publish and pull_request - by Javier Segovia Cordoba
  • Refactor publish and pull-request workflows - by Javier Segovia Cordoba
  • Fix tag regex in publish workflow - by Javier Segovia Cordoba
  • Refactor publish.yml workflow and add generate-tag workflow - by Javier Segovia Cordoba
  • Refactor publish.yml workflow - by Javier Segovia Cordoba
  • Add vcs.xml - by Javier Segovia Cordoba
  • versioning plugin - by Raul Raja
  • Remove base directory for gradle.properties file - #2585 by Francisco Diaz
  • Simplify Gradle layout, + KNIT, - ANK and fix site code fences - #2584 by Raul Raja
  • Fix bug cancellation parMap - #2579 by Simon Vergauwen
  • Resource computation block - #2571 by Simon Vergauwen
  • make Semigroup a fun interface - #2569 by Jan Brezina
  • Update all dependencies (major) - #2567 by renovate-bot
  • Configure Renovate - #2533 by renovate-bot

1.1.x versions

If you look at Maven Central, you’ll see that, alongside version 1.1.0, version 1.1.2 is also available.

Use of the Arrow Optics KSP plugin is the difference between these versions. When working with Kotlin 1.6.21, you should be using Arrow 1.1.2, and when you’re working with Kotlin 1.6.20, then you should be using Arrow 1.1.0.

In the future, you can expect many more minor releases, since we can keep up with the Kotlin and KSP releases.

If you run into issues, check the KotlinLang #arrow channel.

Ensure the success of your project

47 Degrees can work with you to help manage the risks of technology evolution, develop a team of top-tier engaged developers, improve productivity, lower maintenance cost, increase hardware utilization, and improve product quality; all while using the best technologies.