A multiplatform Result monad for modelling success or failure operations.
Go to file
2018-01-10 13:27:02 +00:00
gradle/wrapper Update Gradle to 4.4 2017-12-16 19:23:33 +00:00
js Add multi-platform support 2017-12-16 19:30:54 +00:00
jvm Downgrade dokka 2017-12-16 19:50:00 +00:00
src Add lazy variants for {and,or,getOr,getErrorOr} 2018-01-10 13:27:02 +00:00
.editorconfig Initial commit 2017-10-21 03:51:30 +01:00
.gitignore Add Travis CI configuration file 2017-10-22 01:06:11 +01:00
.travis.yml Add Travis CI configuration file 2017-10-22 01:06:11 +01:00
build.gradle Downgrade dokka 2017-12-16 19:50:00 +00:00
gradle.properties [Gradle Release Plugin] - new version commit: '1.0.6-SNAPSHOT'. 2017-12-17 00:17:10 +00:00
gradlew Update Gradle to v4.3.1 2017-11-28 18:40:25 +00:00
gradlew.bat Initial commit 2017-10-21 03:51:30 +01:00
LICENSE Initial commit 2017-10-21 03:51:30 +01:00
README.md Update README 2017-12-17 00:16:48 +00:00
settings.gradle Add multi-platform support 2017-12-16 19:30:54 +00:00

kotlin-result

Release Build Status License

Result<V, E> is a monad for modelling success (Ok) or failure (Err) 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:

  • Feature parity with Result types from other languages including Elm, Haskell, & Rust
  • Multiplatform project support
  • Lax constraints on value/error nullability
  • Lax constraints on the error type's inheritance (does not inherit from Exception)
  • Top level Ok and Err classes avoids qualifying usages with Result.Ok/Result.Err 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 covering every library method

Installation

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.michaelbull:kotlin-result:1.0.5'
}

Getting Started

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

Mappings from common Result libraries are available on the wiki:

Contributing

Bug reports and pull requests are welcome on GitHub.

License

This project is available under the terms of the ISC license. See the LICENSE file for the copyright information and licensing terms.