You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the book says for flatmap (def flatMap[EE >: E, B](f: A => Either[EE, B]): Either[EE, B] = ???), it needs to promote left type to super type EE.
//when mapping over the right side, we must promote the left type parameter to some supertype, to satisfy the +E variance annotation. Similarly for 'orElse'
My question is : why do not we have to say B >: A, we do not need to satisfy +A ???... interestingly, the orElse signature has promoted the right type parameter to some supertype B (def orElse[EE >: E, B >: A](b: => Either[EE, B]): Either[EE, B] = ???).
I've tried to read covariance, subtyping, but still could not understand.
The text was updated successfully, but these errors were encountered:
the book says for flatmap (def flatMap[EE >: E, B](f: A => Either[EE, B]): Either[EE, B] = ???), it needs to promote left type to super type EE.
//when mapping over the right side, we must promote the left type parameter to some supertype, to satisfy the +E variance annotation. Similarly for 'orElse'
My question is : why do not we have to say B >: A, we do not need to satisfy +A ???... interestingly, the orElse signature has promoted the right type parameter to some supertype B (def orElse[EE >: E, B >: A](b: => Either[EE, B]): Either[EE, B] = ???).
I've tried to read covariance, subtyping, but still could not understand.
The text was updated successfully, but these errors were encountered: