@@ -11,14 +11,14 @@ import scala.annotation.tailrec
11
11
* - `[[Ior.Right Right ]][B]`
12
12
* - `[[Ior.Both Both ]][A, B]`
13
13
*
14
- * `A [[Ior ]] B` is similar to `Either [A, B]`, except that it can represent the simultaneous presence of
14
+ * `A [[Ior ]] B` is similar to `Xor [A, B]`, except that it can represent the simultaneous presence of
15
15
* an `A` and a `B`. It is right-biased so methods such as `map` and `flatMap` operate on the
16
16
* `B` value. Some methods, like `flatMap`, handle the presence of two [[Ior.Both Both ]] values using a
17
- * `[[Semigroup ]][A]`, while other methods, like [[toEither ]], ignore the `A` value in a [[Ior.Both Both ]].
17
+ * `[[Semigroup ]][A]`, while other methods, like [[toXor ]], ignore the `A` value in a [[Ior.Both Both ]].
18
18
*
19
- * `A [[Ior ]] B` is isomorphic to `Either[Either [A, B], (A, B)]`, but provides methods biased toward `B`
19
+ * `A [[Ior ]] B` is isomorphic to `Xor[Xor [A, B], (A, B)]`, but provides methods biased toward `B`
20
20
* values, regardless of whether the `B` values appear in a [[Ior.Right Right ]] or a [[Ior.Both Both ]].
21
- * The isomorphic [[scala.util.Either ]] form can be accessed via the [[unwrap ]] method.
21
+ * The isomorphic [[cats.data.Xor ]] form can be accessed via the [[unwrap ]] method.
22
22
*/
23
23
sealed abstract class Ior [+ A , + B ] extends Product with Serializable {
24
24
@@ -36,10 +36,10 @@ sealed abstract class Ior[+A, +B] extends Product with Serializable {
36
36
final def right : Option [B ] = fold(_ => None , b => Some (b), (_, b) => Some (b))
37
37
final def onlyLeft : Option [A ] = fold(a => Some (a), _ => None , (_, _) => None )
38
38
final def onlyRight : Option [B ] = fold(_ => None , b => Some (b), (_, _) => None )
39
- final def onlyLeftOrRight : Option [Either [A , B ]] = fold(a => Some (Left (a)), b => Some (Right (b)), (_, _) => None )
39
+ final def onlyLeftOrRight : Option [Xor [A , B ]] = fold(a => Some (Xor . Left (a)), b => Some (Xor . Right (b)), (_, _) => None )
40
40
final def onlyBoth : Option [(A , B )] = fold(_ => None , _ => None , (a, b) => Some ((a, b)))
41
41
final def pad : (Option [A ], Option [B ]) = fold(a => (Some (a), None ), b => (None , Some (b)), (a, b) => (Some (a), Some (b)))
42
- final def unwrap : Either [ Either [A , B ], (A , B )] = fold(a => Left (Left (a)), b => Left (Right (b)), (a, b) => Right ((a, b)))
42
+ final def unwrap : Xor [ Xor [A , B ], (A , B )] = fold(a => Xor . Left (Xor . Left (a)), b => Xor . Left (Xor . Right (b)), (a, b) => Xor . Right ((a, b)))
43
43
44
44
final def toXor : A Xor B = fold(Xor .left, Xor .right, (_, b) => Xor .right(b))
45
45
final def toEither : Either [A , B ] = fold(Left (_), Right (_), (_, b) => Right (b))
0 commit comments