def findMofu(id: Int): Future[CacheError | IOError | NotFound, Mofu] = ???
def createMofu(mofu: Mofu): Future[CacheError | IOError | DuplicateError, Mofu] = ???
val result = findMofu(5).recoverWith {
case NotFound =>
createMofu(Mofu(5)).recoverWith {
case DuplicateError => UnknownError
}
}
// findMofu の None が recoverWith され、createMofu の DuplicateError が UnknowError に変換されてるので↓のようになると推論される。
assert(result.isInstanceOf[Future[CacheError | IOError | UnknownError, Mofu])
Last active
June 9, 2016 16:15
-
-
Save okumin/494e068631a7d6295dfc to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment