Skip to content

Commit

Permalink
Merge pull request typelevel#1215 from zmccoy/make-lifT-accessible
Browse files Browse the repository at this point in the history
Put liftT on the companion object of XorT
  • Loading branch information
kailuowang authored Aug 20, 2016
2 parents 6137fee + 1e277cd commit 61a2a16
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion core/src/main/scala/cats/data/XorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ trait XorTFunctions {

final def pure[F[_], A, B](b: B)(implicit F: Applicative[F]): XorT[F, A, B] = right(F.pure(b))

/**
* Alias for [[XorT.right]]
* {{{
* scala> import cats.data.XorT
* scala> import cats.implicits._
* scala> val o: Option[Int] = Some(3)
* scala> val n: Option[Int] = None
* scala> XorT.liftT(o)
* res0: cats.data.XorT[Option,Nothing,Int] = XorT(Some(Right(3)))
* scala> XorT.liftT(n)
* res1: cats.data.XorT[Option,Nothing,Int] = XorT(None)
* }}}
*/
final def liftT[F[_], A, B](fb: F[B])(implicit F: Functor[F]): XorT[F, A, B] = right(fb)

/** Transforms an `Xor` into an `XorT`, lifted into the specified `Applicative`.
*
* Note: The return type is a FromXorPartiallyApplied[F], which has an apply method
Expand Down Expand Up @@ -280,7 +295,7 @@ private[data] abstract class XorTInstances extends XorTInstances1 {
type TC[M[_]] = Functor[M]

def liftT[M[_]: Functor, A](ma: M[A]): XorT[M, E, A] =
XorT(Functor[M].map(ma)(Xor.right))
XorT.liftT(ma)
}

implicit def catsMonoidForXorT[F[_], L, A](implicit F: Monoid[F[L Xor A]]): Monoid[XorT[F, L, A]] =
Expand Down

0 comments on commit 61a2a16

Please sign in to comment.