Maven Central Build Status Kotlin version badge License

Λrrow is a library for Typed Functional Programming in Kotlin.

Arrow aims to provide a lingua franca of interfaces and abstractions across Kotlin libraries. For this, it includes the most popular data types, type classes and abstractions such as Option, Try, Either, IO, Functor, Applicative, Monad to empower users to write pure FP apps and libraries built atop higher order abstractions.

Use the list below to learn more about Λrrow’s main features.

  • Patterns: tutorials and approaches to day-to-day challenges using FP
  • Libraries: all the libraries provided by Λrrow
  • Type classes: defining behaviors for data
  • Data types: common abstractions
  • Effects: interfacing with external systems
  • Optics: inspecting and modifying data structures

Gradle

Basic Setup

Make sure to have the latest version of JDK 1.8 installed.

In your project’s root build.gradle append the jcenter repository to your list of repositories.

allprojects {
    repositories {
        mavenCentral()
        jcenter()
        maven { url "https://dl.bintray.com/arrow-kt/arrow-kt/" }
        maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' }
    }
}

Dependency breakdown starting in Arrow 0.9.0

Starting in 0.9.0, Arrow follows the following convention for artifact publication.

The arrow modules are Core, Effects, Optics, Recursion, etc.

An Arrow module is composed of data types and type classes. Arrow modules are exported and published with the following semantics.

If we take for example arrow-core.

Arrow core contains the basic arrow type classes and data types and it’s composed of 3 main artifacts that may be used a la carte:

Recomended for most use cases:

  • arrow-core (Depends on data and extensions modules and exports both)

Trimmed down versions:

  • arrow-core-data (Only data types)
  • arrow-core-extensions (Only type class extensions)

Current stable version 0.8.2

You can find the dependencies necessary in the Basic Setup of the README at the 0.8.2 tag clicking here.

Next development version 0.9.0

Add the dependencies into the project’s build.gradle

apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
def arrow_version = "0.9.0-SNAPSHOT"
dependencies {
    compile "io.arrow-kt:arrow-core-data:$arrow_version"
    compile "io.arrow-kt:arrow-syntax:$arrow_version"
    compile "io.arrow-kt:arrow-typeclasses:$arrow_version"
    compile "io.arrow-kt:arrow-extras:$arrow_version"
    compile "io.arrow-kt:arrow-core-extensions:$arrow_version"
    compile "io.arrow-kt:arrow-extras-extensions:$arrow_version"
    kapt    "io.arrow-kt:arrow-meta:$arrow_version"

    compile "io.arrow-kt:arrow-free:$arrow_version" //optional
    compile "io.arrow-kt:arrow-free-extensions:$arrow_version" //optional
    compile "io.arrow-kt:arrow-mtl:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-extensions:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-io-extensions:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-rx2:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-rx2-extensions:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-reactor:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-reactor-extensions:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-kotlinx-coroutines:$arrow_version" //optional
    compile "io.arrow-kt:arrow-effects-kotlinx-coroutines-extensions:$arrow_version" //optional
    compile "io.arrow-kt:arrow-optics:$arrow_version" //optional
    compile "io.arrow-kt:arrow-generic:$arrow_version" //optional
    compile "io.arrow-kt:arrow-recursion:$arrow_version" //optional
    compile "io.arrow-kt:arrow-extensions-recursion:$arrow_version" //optional
    compile "io.arrow-kt:arrow-integration-retrofit-adapter:$arrow_version" //optional
}

Additional Setup

For projects that wish to use their own @higherkind, @optics and other meta programming facilities provided by Λrrow the setup below is also required:

Add the dependencies into the project’s build.gradle

apply plugin: 'kotlin-kapt' //optional
apply from: rootProject.file('gradle/generated-kotlin-sources.gradle') //only for Android projects

def arrow_version = "0.8.2"
dependencies {
    ...
    kapt    'io.arrow-kt:arrow-meta:$arrow_version' //optional
    ...
}

gradle/generated-kotlin-sources.gradle

apply plugin: 'idea'

idea {
    module {
        sourceDirs += files(
                'build/generated/source/kapt/main',
                'build/generated/source/kapt/debug',
                'build/generated/source/kapt/release',
                'build/generated/source/kaptKotlin/main',
                'build/generated/source/kaptKotlin/debug',
                'build/generated/source/kaptKotlin/release',
                'build/tmp/kapt/main/kotlinGenerated')
        generatedSourceDirs += files(
                'build/generated/source/kapt/main',
                'build/generated/source/kapt/debug',
                'build/generated/source/kapt/release',
                'build/generated/source/kaptKotlin/main',
                'build/generated/source/kaptKotlin/debug',
                'build/generated/source/kaptKotlin/release',
                'build/tmp/kapt/main/kotlinGenerated')
    }
}

Maven

Basic Setup

Make sure to have the at least the latest version of JDK 1.8 installed. Add to your pom.xml file the following properties:

<properties>
    <kotlin.version>1.3.0</kotlin.version>
    <arrow.version>0.8.2</arrow.version>
</properties>

Add the dependencies that you want to use

<dependency>
    <groupId>io.arrow-kt</groupId>
    <artifactId>arrow-core</artifactId>
    <version>${arrow.version}</version>
</dependency>
<dependency>
    <groupId>io.arrow-kt</groupId>
    <artifactId>arrow-syntax</artifactId>
    <version>${arrow.version}</version>
</dependency>
<dependency>
    <groupId>io.arrow-kt</groupId>
    <artifactId>arrow-typeclasses</artifactId>
    <version>${arrow.version}</version>
</dependency>
<dependency>
    <groupId>io.arrow-kt</groupId>
    <artifactId>arrow-data</artifactId>
    <version>${arrow.version}</version>
</dependency>
<dependency>
    <groupId>io.arrow-kt</groupId>
    <artifactId>arrow-extensions-core</artifactId>
    <version>${arrow.version}</version>
</dependency>
<dependency>
    <groupId>io.arrow-kt</groupId>
    <artifactId>arrow-extensions-data</artifactId>
    <version>${arrow.version}</version>
</dependency>

Enabling kapt

Enable annotaton processing using kotlin plugin

<plugin>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-maven-plugin</artifactId>
    <version>${kotlin.version}</version>
    <executions>
        <execution>
            <id>kapt</id>
            <goals>
                <goal>kapt</goal>
            </goals>
            <configuration>
                <sourceDirs>
                    <sourceDir>src/main/kotlin</sourceDir>
                </sourceDirs>
                <annotationProcessorPaths>
                    <annotationProcessorPath>
                        <groupId>io.arrow-kt</groupId>
                        <artifactId>arrow-annotations-processor</artifactId>
                        <version>${arrow.version}</version>
                    </annotationProcessorPath>
                </annotationProcessorPaths>
            </configuration>
        </execution>
        <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals>
                <goal>compile</goal>
            </goals>
            <configuration>
                <sourceDirs>
                    <sourceDir>src/main/kotlin</sourceDir>
                </sourceDirs>
            </configuration>
        </execution>
        <execution>
            <id>test-compile</id>
            <phase>test-compile</phase>
            <goals>
                <goal>test-compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>