For example, remoteLogin(String user, String password) may return either a network error (Left) or a response (Right). But if there is a response, the login may still be invalid. So I want to biFlatMap the Either. In biFlatMap, if there is a network error, I want to normalize it. If there is a response, I want it to become a Left if the login is invalid, otherwise keep it a Right.
Proposed function signature:
Example use case:
For example,
remoteLogin(String user, String password)
may return either a network error (Left
) or a response (Right
). But if there is a response, the login may still be invalid. So I want tobiFlatMap
theEither
. InbiFlatMap
, if there is a network error, I want to normalize it. If there is a response, I want it to become aLeft
if the login is invalid, otherwise keep it aRight
.