Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exercise 4.6 flatmap/orElse #588

Open
minnieshi opened this issue May 22, 2020 · 0 comments
Open

exercise 4.6 flatmap/orElse #588

minnieshi opened this issue May 22, 2020 · 0 comments

Comments

@minnieshi
Copy link

minnieshi commented May 22, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants