Last active
March 10, 2017 06:36
-
-
Save yoshiyoshifujii/06341a920dd4a793f702cd7d50ac3b01 to your computer and use it in GitHub Desktop.
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
def swap[L, R](a: Option[Either[L, R]]): Either[L, Option[R]] = | |
(for { | |
b <- a | |
} yield for { | |
c <- b.right | |
} yield Option(c)).getOrElse(Right(None)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment