Package-level declarations

Types

Link copied to clipboard
@Serializable(with = EitherSerializer::class)
sealed class Either<out L, out R>

Base implementation. Can either be Left or Right.

Link copied to clipboard
class EitherSerializer<L, R>(leftDelegate: KSerializer<L>, rightDelegate: KSerializer<R>) : KSerializer<Either<L, R>>

Serializer for both Left and Right implementation of the Either class.

Link copied to clipboard
@Serializable(with = LeftSerializer::class)
data class Left<out L>(val left: L) : Either<L, Nothing>

Left implementation of Either

Link copied to clipboard
class LeftSerializer<L>(delegate: KSerializer<L>) : KSerializer<Left<L>>

Serializer for the Left implementation of the Either class.

Link copied to clipboard
data object None : Option<Nothing>

Implementation of none Option

Link copied to clipboard
@Serializable(with = OptionSerializer::class)
sealed class Option<out T>

Base implementation. Can either be Some or None

Link copied to clipboard
class OptionSerializer<T>(delegate: KSerializer<T>) : KSerializer<Option<T>>

This serializer is used to encode/decode options with field presence inside JSON.

Link copied to clipboard
@Serializable(with = RightSerializer::class)
data class Right<out R>(val right: R) : Either<Nothing, R>

Right implementation of Either

Link copied to clipboard
class RightSerializer<R>(delegate: KSerializer<R>) : KSerializer<Right<R>>

Serializer for the Right implementation of the Either class.

Link copied to clipboard
@Serializable(with = SomeSerializer::class)
data class Some<out T>(val value: T) : Option<T>

Implementation of value Option

Link copied to clipboard
class SomeSerializer<T>(delegate: KSerializer<T>) : KSerializer<Some<T>>

Default serializer for SomeSerializer. This serializer does not encapsulate the value into an object with value inside.

Functions

Link copied to clipboard
inline fun <L, R> Either<L, R>.alsoBoth(onLeft: (L) -> Unit, onRight: (R) -> Unit): Either<L, R>
inline fun <T> Option<T>.alsoBoth(onNone: () -> Unit, onSome: (T) -> Unit): Option<T>

Depending on this kind:

Link copied to clipboard
inline fun <L, R> Either<L, R>.alsoLeft(block: (L) -> Unit): Either<L, R>

On a Left Either, calls the specified function block with Either.left

Link copied to clipboard
inline fun <T> Option<T>.alsoNone(block: () -> Unit): Option<T>

On a None Option, calls the specified function block

Link copied to clipboard
inline fun <L, R> Either<L, R>.alsoRight(block: (R) -> Unit): Either<L, R>

On a Right Either, calls the specified function block with Either.right.

Link copied to clipboard
inline fun <T> Option<T>.alsoSome(block: (T) -> Unit): Option<T>

On a Some Option, calls the specified function block with Some.value

Link copied to clipboard
inline fun <L, R, NewType> Either<L, R>.foldBoth(onLeft: (L) -> NewType, onRight: (R) -> NewType): NewType

Depending on this Kind:

inline fun <T, O> Option<T>.foldBoth(onSome: (T) -> O, onNone: () -> O): O

Depending on this kind:

Link copied to clipboard
inline fun <L, R> Either<L, R>.foldLeft(block: (L) -> R): R

On a Left Either, calls the specified function block to transform Either.left into Either.right type.

Link copied to clipboard
inline fun <T> Option<T>.foldNone(block: () -> T): T

Depending on this kind:

Link copied to clipboard
inline fun <L, R> Either<L, R>.foldRight(block: (R) -> L): L

On a Right Either, calls the specified function block to transform Either.right into Either.left type.

Link copied to clipboard
inline fun <T, L, R> Option<T>.letAsLeft(onSome: (T) -> L, onNone: () -> R): Either<L, R>

Depending on this Kind:

Link copied to clipboard
inline fun <T, L, R> Option<T>.letAsRight(onNone: () -> L, onSome: (T) -> R): Either<L, R>

Depending on this Kind:

Link copied to clipboard
inline fun <OldL, OldR, NewL, NewR> Either<OldL, OldR>.letBoth(onLeft: (OldL) -> NewL, onRight: (OldR) -> NewR): Either<NewL, NewR>

Depending on this kind:

Link copied to clipboard
inline fun <OldL, NewL, R> Either<OldL, R>.letLeft(block: (OldL) -> NewL): Either<NewL, R>

On a Left Either, calls the specified function block to transform Either.left.

Link copied to clipboard
inline fun <R, L> Option<R>.letNoneAsLeft(block: () -> L): Either<L, R>

Depending on this kind:

Link copied to clipboard
inline fun <L, R> Option<L>.letNoneAsRight(block: () -> R): Either<L, R>

Depending on this kind:

Link copied to clipboard
inline fun <L, OldR, NewR> Either<L, OldR>.letRight(block: (OldR) -> NewR): Either<L, NewR>

On a Right Either, calls the specified function block to transform Either.right.

Link copied to clipboard
inline fun <T, R> Option<T>.letSome(block: (T) -> R): Option<R>

On a Some Option, calls the specified function block to transform Some.value.

Link copied to clipboard
inline fun <L, R> Either<L, R>.requireLeft(block: (Right<R>) -> Nothing): L

Try to get Either.left or calls block to return or stops the current execution block.

Link copied to clipboard
inline fun <T> Option<T>.requireNone(block: (Some<T>) -> Nothing)

If this is Some, calls block with this to return or stops the current execution block.

Link copied to clipboard
inline fun <L, R> Either<L, R>.requireRight(block: (Left<L>) -> Nothing): R

Try to get Either.right or calls block to return or stops the current execution block.

Link copied to clipboard
inline fun <T> Option<T>.requireSome(block: () -> Nothing): T

Try to get Some.value or calls block to return or stops the current execution block.

Link copied to clipboard
infix inline fun <OldL, NewL, R> Either<OldL, R>.tryLeft(block: (OldL) -> Either<NewL, R>): Either<NewL, R>

Depending on this Kind:

Link copied to clipboard
infix inline fun <L, OldR, NewR> Either<L, OldR>.tryRight(block: (OldR) -> Either<L, NewR>): Either<L, NewR>

Depending on this Kind:

Link copied to clipboard
inline fun <Old, New> Option<Old>.trySome(block: (Old) -> Option<New>): Option<New>