Created
April 7, 2016 00:06
-
-
Save malcolmgreaves/d06a7e01202a5792c7c9031b643ffd70 to your computer and use it in GitHub Desktop.
Easily convert a Try[T] into a scalaz.\/[Throwable, T]
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
implicit class TryToDisjunction[T](private val x: Try[T]) extends AnyVal { | |
@inline def toOr: \/[Throwable, T] = | |
x match { | |
case Success(value) => \/-(value) | |
case Failure(e) => -\/(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! Suggest wrapping the Failure catch clause with NonFatal