Skip to the content.

KIO Actions Status Release

A simple, lightweight IO monad implementation for Kotlin inspired to the effect-rotation based ZIO library for Scala.

Blog posts:

Introducing KIO: https://www.msec.it/blog/introducing-kio/

Comprehension-like syntax: https://www.msec.it/blog/comprehension-like-syntax-in-kotlin/

Introduction

Many functional programming languages (like Clojure and F#), even if they could (more or less) support the Haskell typeclasses-like FP approach, doesn’t rely on it in order to provide a functional programming environment. Instead, they just rely on the most important pillars of functional programming that are referential transparency and immutability, usually complemented with the use of algebraic data types (ADTs).

Kotlin already provides many tools that can help the developers to stick with these principles, like data classes, sealed classes and immutable variables (val). The two most notable missing pieces are a way to easily handle referential transparency when side effects are involved and an error handling alternative to exceptions. KIO is a lightweight IO implementation that tries to fill this gap without aspiring to provide all the classic Haskell/Scala typeclass categories. If you are looking for this type of library, take a look at Arrow instead.

Features

KIO provides a IO monad-like implementation specific for Kotlin with the following features:

Also some utility methods are available for lists and null-handling.

Maven configuration

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>it.msec.KIO</groupId>
    <artifactId>kio</artifactId>
    <version>0.7</version>
  </dependency>
</dependencies>

Getting started

You can find some documentation in order to start with KIO here.