or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

collection-extensions.mdcore-data-types.mdeffect-system.mdindex.mdraise-dsl.mdtuple-types.md
tile.json

tessl/maven-io-arrow-kt--arrow-core-iosarm64

Functional companion to Kotlin's Standard Library - Core module with iosArm64 target support

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/io.arrow-kt/arrow-core@2.1.x

To install, run

npx @tessl/cli install tessl/maven-io-arrow-kt--arrow-core-iosarm64@2.1.0

index.mddocs/

Arrow Core

Arrow Core is the foundational module of the Arrow Kotlin library that provides essential data types and functional programming abstractions for Kotlin Multiplatform development. It offers type-safe alternatives to null values, railway-oriented programming for error handling, non-empty collections, and a powerful Raise DSL for typed error management.

Package Information

  • Package Name: io.arrow-kt:arrow-core
  • Package Type: maven
  • Language: Kotlin
  • Platform: Kotlin Multiplatform (iosArm64, jvm, js, native targets)
  • Installation: implementation("io.arrow-kt:arrow-core:2.1.2")

Core Imports

import arrow.core.*
import arrow.core.raise.*

For specific imports:

import arrow.core.Either
import arrow.core.Option
import arrow.core.NonEmptyList
import arrow.core.raise.either
import arrow.core.raise.effect

Basic Usage

import arrow.core.*
import arrow.core.raise.either

// Working with Optional values
val maybeUser: Option<String> = Some("Alice")
val greeting = maybeUser.map { "Hello, $it!" }.getOrElse { "Hello, Guest!" }

// Error handling with Either
val result: Either<String, Int> = either {
    val input = "42"
    input.toIntOrNull() ?: raise("Invalid number")
}

// Non-empty collections
val numbers = nonEmptyListOf(1, 2, 3, 4, 5)
val doubled = numbers.map { it * 2 }

// Using the Raise DSL for error accumulation
val validation = either {
    val name = validateName("") // raises error if empty
    val age = validateAge(-1)   // raises error if negative
    User(name, age)
}

Architecture

Arrow Core is built around several key components:

  • Type-Safe Null Handling: Option<A> provides a safe alternative to nullable types
  • Railway-Oriented Programming: Either<A, B> enables clean error handling without exceptions
  • Error Accumulation: Ior<A, B> allows collecting multiple errors while preserving successful computations
  • Guaranteed Non-Empty Collections: NonEmptyList and NonEmptySet prevent empty collection errors at compile time
  • Raise DSL: A composable system for typed error handling with short-circuiting and accumulation
  • Effect System: Suspended computations with error handling capabilities
  • Functional Extensions: Rich collection operations following functional programming principles

Capabilities

Core Data Types

Essential functional data types providing type-safe alternatives to nullable values, error handling, and guaranteed non-empty collections.

sealed class Either<out A, out B>
sealed class Option<out A>
sealed class Ior<out A, out B>
interface NonEmptyCollection<out E>: Collection<E>
data class NonEmptyList<out A>: NonEmptyCollection<A>
data class NonEmptySet<out A>: NonEmptyCollection<A>

Core Data Types

Raise DSL

Composable typed error handling system with short-circuiting and error accumulation capabilities. Includes the Effect system for asynchronous computations and RaiseAccumulate for error collection. The foundation for all error handling in Arrow.

@RaiseDSL
interface Raise<in Error> {
    fun raise(error: Error): Nothing
    fun <A> Either<Error, A>.bind(): A
    fun <A> Option<A>.bind(): A
}

class SingletonRaise<in Error>: Raise<Error>
class IorRaise<Error>: Raise<Error>
class RaiseAccumulate<Error>: Raise<NonEmptyList<Error>>

// Effect System types
typealias Effect<Error, A> = suspend Raise<Error>.() -> A
typealias EagerEffect<Error, A> = Raise<Error>.() -> A

suspend fun <Error, A> effect(block: suspend Raise<Error>.() -> A): Either<Error, A>
fun <Error, A> eagerEffect(block: Raise<Error>.() -> A): Either<Error, A>

Raise DSL

Collection Extensions

Functional programming extensions for Kotlin collections including multi-parameter zip operations, alignment operations, error accumulation, and safety utilities.

fun <A, B, C, R> Iterable<A>.zip(other1: Iterable<B>, other2: Iterable<C>, transform: (A, B, C) -> R): List<R>
fun <Error, A, B> RaiseAccumulate<Error>.Iterable<A>.mapOrAccumulate(transform: Raise<Error>.(A) -> B): List<B>
fun <A, B> Iterable<A>.align(other: Iterable<B>): List<Ior<A, B>>
fun <A> Iterable<A>.firstOrNone(): Option<A>

Collection Extensions

Tuple Types

Immutable tuple data types for grouping 4-9 related values with type safety and destructuring support.

data class Tuple4<out A, out B, out C, out D>(val first: A, val second: B, val third: C, val fourth: D)
data class Tuple5<out A, out B, out C, out D, out E>(val first: A, val second: B, val third: C, val fourth: D, val fifth: E)
// ... through Tuple9
data class TupleN<out A>(val values: List<A>)

Tuple Types