Run this value as a Validated
against the function and convert it back to an XorT
.
Run this value as a Validated
against the function and convert it back to an XorT
.
The Applicative instance for XorT
"fails fast" - it is often useful to "momentarily" have
it accumulate errors instead, which is what the Validated
data type gives us.
Example:
val v1: Validated[NonEmptyList[Error], Int] = ... val v2: Validated[NonEmptyList[Error], Int] = ... val xort: XorT[Error, Int] = ... val result: XorT[NonEmptyList[Error], Int] = xort.withValidated { v3 => (v1 |@| v2 |@| v3.leftMap(NonEmptyList(_))) { case (i, j, k) => i + j + k } }
Transformer for
Xor
, allowing the effect of an arbitrary type constructorF
to be combined with the fail-fast effect ofXor
.XorT[F, A, B]
wraps a value of typeF[A Xor B]
. AnF[C]
can be lifted in toXorT[F, A, C]
viaXorT.right
, and lifted in to aXorT[F, C, B]
viaXorT.left
.