February 2018
Intermediate to advanced
350 pages
7h 35m
English
Either<L, R> is a representation of one of two possible values L or R, but not both at the same time. Either is a sealed class (similar to Option) with two subtypes Left<L> and Right<R>. Usually Either is used to represent results that can fail, using the left side to represent the error and the right side to represent a successful result. Because representing operations that can fail is a common scenario, Arrow's Either is right biased, in other words, unless it is documented otherwise all operations run on the right side.
Let's translate our division example from Option to Either:
import arrow.core.Eitherimport arrow.core.Either.Rightimport arrow.core.Either.Leftfun eitherDivide(num: Int, den: Int): Either<String, Int> { val option ...
Read now
Unlock full access