简体   繁体   English

EitherT [Option,A,B] ===选项[A [B,B]]

[英]EitherT[Option, A, B] === Option[Either[A,B]]

If I understand correctly EitherT[Option,A,B ] should be identical to Option[Either[A,B]] , but the compiler doesn't agree. 如果我理解正确, EitherT[Option,A,B ]应该与Option[Either[A,B]] ,但编译器不同意。 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. EitherT[Option,A,B]包装Option[Either[A,B]]类型的值以提供不同的行为。 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]] 所以这里的EitherT包装了一个Option,而名为run的值是一个Option[Either[A,B]]类型的值Option[Either[A,B]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM