A multiplatform Result monad for modelling success or failure operations.
Go to file
Michael Bull eb326ecebb Remove erroneous list entry in README 2017-10-21 19:46:44 +01:00
gradle/wrapper Update gradle wrapper 2017-10-21 04:31:24 +01:00
src Pass error/value to UnwrapException message 2017-10-21 19:17:01 +01:00
.editorconfig Initial commit 2017-10-21 03:51:30 +01:00
.gitignore Initial commit 2017-10-21 03:51:30 +01:00
LICENSE Initial commit 2017-10-21 03:51:30 +01:00
README.md Remove erroneous list entry in README 2017-10-21 19:46:44 +01:00
build.gradle Initial commit 2017-10-21 03:51:30 +01:00
gradle.properties Add README 2017-10-21 17:44:55 +01:00
gradlew Initial commit 2017-10-21 03:51:30 +01:00
gradlew.bat Initial commit 2017-10-21 03:51:30 +01:00
settings.gradle Initial commit 2017-10-21 03:51:30 +01:00

README.md

kotlin-result

Result<V, E> is a monad for modelling success (Ok) or failure (Error) operations.

Inspiration

Inspiration for this library has been drawn from other languages in which the Result monad is present, including:

It also iterates on other Result libraries written in Kotlin, namely:

Improvements on the existing solutions include:

  • Complete feature parity with Result types from other languages including Elm, Haskell, & Rust
  • Lax constraints on value/error nullability
  • Lax constraints on the error type's inheritance (does not inherit from Exception)
  • Top level Ok and Error classes avoids qualifying usages with Result.Ok/Result.Error respectively
  • Higher-order functions marked with the inline keyword for reduced runtime overhead
  • Extension functions on Iterable & List for folding, combining, partitioning
  • Consistent naming with existing Result libraries from other languages (e.g. map, mapError, mapBoth, mapEither, and, andThen, or, orElse, unwrap)
  • Extensive test suite with over 50 unit tests and every library method covered

Installation

This project is available in the Maven Central Repository repository. The artifacts are signed with my personal GPG key.

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.mikebull94.kotlin-result:kotlin-result:1.0.0'
}

Getting Started

The unit tests are a good source of examples for using the library as they cover every avaiable method.

Mappings from common Result libraries are available on the wiki: