Newer
Older
enum Either[+E, +A]:
case Left(value: E)
case Right(value: A)
def map[B](f: A => B): Either[E, B] = this match
case Left(e) => Left(e)
case Right(a) => Right(f(a))
def flatMap[EE >: E, B](f: A => Either[EE, B]): Either[EE, B] = this match
case Left(e) => Left(e)
case Right(a) => f(a)
def map2[EE >: E, B, C](other: Either[EE, B])(f: (A, B) => C): Either[EE, C] = ???