Assume we have EitherT[F, String, A]
.
The withFilter
function of Scalaz uses the zero of String
's Monoid in order to fill in Left
if the filter fails.
Therefore, there is no meaningful error message.
How could I implement something of the form where Left would be "Not positive".
val a: Either[Future, String, Int] = -1.point[EitherT[Future, String, ?]]
val foo = for {
aa <- a
if aa >= 0
} yield aa
Are the filter
and withFilter
methods on EitherT
just hacks to fulfill the for-comprehension demands?
You can use
EitherT#ensure
: