Skip to main content

Setup

The setup for using Arrow in your project doesn't differ much from any other Kotlin library, although some special steps are required for Android and Optics. Check the library reference for the whole list of libraries under the Arrow umbrella.

Enable the Maven Central repository​

Arrow is published in Maven Central, so you need to enable it as a source of dependencies in your build.

repositories {
mavenCentral()
}

Include the dependencies​

You're now ready to include Arrow in your project. You have three possibilities that correspond to three different ways of handling versioning in your build.

All Arrow libraries are Multiplatform-ready, so you can use them in all of your KMP projects. Be aware that some instructions here may need to be slightly changed in that situation.

One by one​

Simply include the desired library in your dependencies block or as a <dependency> if you're using Maven.

dependencies {
implementation("io.arrow-kt:arrow-core:2.3.0")
implementation("io.arrow-kt:arrow-fx-coroutines:2.3.0")
}

Using version catalogs​

Version catalogs provide centralized management of versions. This is especially helpful when your Gradle build has several subprojects.

[versions]
arrow = "2.3.0"
# other versions

[libraries]
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
arrow-fx-coroutines = { module = "io.arrow-kt:arrow-fx-coroutines", version.ref = "arrow" }
# other dependencies

Using a Bill-of-Materials (BOM)​

Another way to keep a single version for all Arrow dependencies in your build is to include arrow-stack, which declares versions for the rest of the components.

dependencies {
implementation(platform("io.arrow-kt:arrow-stack:2.3.0"))
// no versions on libraries
implementation("io.arrow-kt:arrow-core")
implementation("io.arrow-kt:arrow-fx-coroutines")
}
Eager dependency update policy

The Arrow team follows an eager dependency update policy. That means that Arrow libraries always depend on the most up-to-date version of the dependencies at the moment of release. In most cases, it is fine to use older versions of the dependencies; but in rare cases, the conflict leads to NoClassDefFoundErrors. If that happens, please try to update your dependencies to a more recent version, or open an issue.

Additional setup for Android​

If you are using Arrow in Android, you should enable library desugaring in your final application. This is especially important if you use arrow-collectors, since that library uses APIs available only from Java 11 on.

Additional setup for Optics​

If you're using the Optics component of Arrow, we provide a Kotlin compiler plug-in that can derive most of the boilerplate required to use it.

There are two possibilities to configure this plug-in. Since version 2.3.0, we recommend using the compiler plug-in.

plugins {
id("io.arrow-kt.optics") version "2.3.0"
}

If you cannot use the compiler plug-in for any reason (unsupported build tool, unsupported Kotlin version), you should use the KSP implementation instead. If you are using it in a Multiplatform project or plan to, we recommend checking the official guide in Kotlin docs and the related documentation in Koin for guidance.

plugins {
id("com.google.devtools.ksp") version "2.3.12"
}

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

Plug-in for IntelliJ-based IDEs​

If you are using an IntelliJ IDEA or any other IDE from JetBrains, we strongly recommend installing the Arrow plug-in. The plug-in helps fix common problems, especially in the realm of typed errors and suggests more idiomatic alternatives when available.

Alphas (development builds)​

For those wanting to live on the edge, we provide alphas of our development branch. Those are tagged with the upcoming version, followed by -alpha. and the sequence number of the compilation. Check Maven Central for the most recent list of available versions.