If I understand correctly EitherT[Option,A,B
] should be identical to Option[Either[A,B]]
, but the compiler doesn't agree. The following code fails to compile:
def f[A,B] = implicitly[EitherT[Option, A, B] === Option[Either[A,B]]]
What am I missing?
They are isomorphic, but not the same value. EitherT[Option,A,B]
wraps a value of type Option[Either[A,B]]
in order to provide different behavior. Let's look at the definition:
final case class EitherT[F[_], A, B](run: F[A \/ B])
So EitherT
here is wrapping an Option, and the value named run
is a value which is of type Option[Either[A,B]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.