Last active
April 21, 2017 09:29
-
-
Save jbgi/56079514dde4869f9403b9069aa53365 to your computer and use it in GitHub Desktop.
Minimal Either sum type in Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Either[A, B] | |
final case class Left[A, B](a: A) extends Either[A, B] | |
final case class Right[A, B](b: B) extends Either[A, B] | |
object Either { | |
def left[A, B](a: A): Either[A, B] = Left(a) | |
def right[A, B](b: B): Either[A, B] = Right(b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment