Skip to content

Commit

Permalink
Add liftK to IorT
Browse files Browse the repository at this point in the history
  • Loading branch information
frroliveira committed Nov 21, 2017
1 parent 5be9cb1 commit adc87b7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/main/scala/cats/data/IorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@ object IorT extends IorTInstances {
*/
final def liftF[F[_], A, B](fb: F[B])(implicit F: Applicative[F]): IorT[F, A, B] = right(fb)

/**
* Same as [[liftF]], but expressed as a FunctionK for use with [[IorT.mapK]]
* {{{
* scala> import cats._, data._, implicits._
* scala> val a: OptionT[Eval, Int] = 1.pure[OptionT[Eval, ?]]
* scala> val b: OptionT[IorT[Eval, String, ?], Int] = a.mapK(IorT.liftK)
* scala> b.value.value.value
* res0: cats.data.Ior[String,Option[Int]] = Right(Some(1))
* }}}
*/
final def liftK[F[_], A](implicit F: Functor[F]): F ~> IorT[F, A, ?] =
new (F ~> IorT[F, A, ?]) {
def apply[B](fb: F[B]): IorT[F, A, B] = right(fb)
}

/**
* Uses the [[http://typelevel.org/cats/guidelines.html#partially-applied-type-params Partially Applied Type Params technique]] for ergonomics.
*/
Expand Down

0 comments on commit adc87b7

Please sign in to comment.