Skip to content

Commit

Permalink
Add convenience wrapper for Xor.fromOption in XorT.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkotsbakws committed May 31, 2016
1 parent 2fb4d1d commit 02e794c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/scala/cats/data/XorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ trait XorTFunctions {
def apply[E, A](eit: Either[E,A])(implicit F: Applicative[F]): XorT[F, E, A] =
XorT(F.pure(Xor.fromEither(eit)))
}

final def fromOption[F[_], E, A](opt: Option[A], ifNone: => E): XorT[F, E, A] = fromXor[F](Xor.fromOption(opt, ifNone))
}

private[data] abstract class XorTInstances extends XorTInstances1 {
Expand Down

0 comments on commit 02e794c

Please sign in to comment.