HamKrest

A Result type for Kotlin

License

License

GroupId

GroupId

com.natpryce
ArtifactId

ArtifactId

result4k
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

HamKrest
A Result type for Kotlin
Project URL

Project URL

https://github.com/npryce/result4k
Source Code Management

Source Code Management

https://github.com/npryce/result4k

Download result4k

How to add to project

<!-- https://jarcasting.com/artifacts/com.natpryce/result4k/ -->
<dependency>
    <groupId>com.natpryce</groupId>
    <artifactId>result4k</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.natpryce/result4k/
implementation 'com.natpryce:result4k:2.0.0'
// https://jarcasting.com/artifacts/com.natpryce/result4k/
implementation ("com.natpryce:result4k:2.0.0")
'com.natpryce:result4k:jar:2.0.0'
<dependency org="com.natpryce" name="result4k" rev="2.0.0">
  <artifact name="result4k" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.natpryce', module='result4k', version='2.0.0')
)
libraryDependencies += "com.natpryce" % "result4k" % "2.0.0"
[com.natpryce/result4k "2.0.0"]

Dependencies

test (3)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.1.51
org.jetbrains.kotlin : kotlin-test jar 1.1.51
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Result4K

NB Result4K is moving - please migrate to https://github.com/fork-handles/forkhandles/tree/trunk/result4k

Kotlin Build Status Maven Central

Type safe error handling in Kotlin.

Motivation

Kotlin does not type-check exceptions. Result4k lets you type-check code that reports and recovers from errors.

A Result<T,E> represents the result of a calculation of a T value that might fail with an error of type E.

You can use a when expression to determine if a Result represents a success or a failure, but most of the time you don't need to. Result4k type provides many useful operations for handling success or failure without explicit conditionals.

Result4k works with the grain of the Kotlin language. Kotlin does not have language support for monads (known as "do notation" or "for comprehensions" in other languages). A pure monadic approach becomes verbose and awkward. Therefore, Result4k lets you use early returns to avoid deep nesting when propagating errors.

Versions

Version
2.0.0
1.4.1
1.4.0
1.3.0
1.2.0
1.1.0
1.0.0