Add two subclasses of Either, representing Error and Value:
sealed class Either<out L, out R> { data class Left<out L>(val left: L) : Either<L, Nothing>() data class Right<out R>(val right: R) : Either<Nothing, R>() }
Add factory functions for the convenient instantiating of Either:
sealed class Either<out L, out R> { data class Left<out L>(val left: L) : Either<L, Nothing>() data class Right<out R>(val right: R) : Either<Nothing, R>()