ContT

object ContT
Companion
class
trait Sum
trait Mirror
class Object
trait Matchable
class Any

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Inherited from
Mirror

Value members

Concrete methods

def apply[M[_], A, B](fn: B => M[A] => M[A]): ContT[M, A, B]

Build a computation that makes use of a callback, also known as a continuation.

Build a computation that makes use of a callback, also known as a continuation.

Example:

 ContT.apply { callback =>
   for {
     a <- doFirstThing()
     b <- doSecondThing(a)
     c <- callback(b)
     d <- doFourthThing(c)
   } yield d
 }
def callCC[M[_], A, B, C](f: B => ContT[M, A, C] => ContT[M, A, B])(M: Defer[M]): ContT[M, A, B]
def defer[M[_], A, B](b: => B): ContT[M, A, B]

Similar to pure but evaluation of the argument is deferred.

Similar to pure but evaluation of the argument is deferred.

This is useful for building a computation which calls its continuation as the final step. Instead of writing:

 ContT.apply { cb =>
   val x = foo()
   val y = bar(x)
   val z = baz(y)
   cb(z)
 }

you can write:

 ContT.defer {
   val x = foo()
   val y = bar(x)
   baz(y)
 }
def later[M[_], A, B](fn: => B => M[A] => M[A]): ContT[M, A, B]

Similar to apply but evaluation of the argument is deferred.

Similar to apply but evaluation of the argument is deferred.

def liftF[M[_], A, B](mb: M[B])(M: FlatMap[M]): ContT[M, A, B]

Lifts the M[B] into an ContT[M, A, B].

Lifts the M[B] into an ContT[M, A, B].

scala> import cats._, data._,  implicits._
scala> val a: EitherT[Eval, String, Int] = 1.pure[EitherT[Eval, String, *]]
scala> val c: cats.data.ContT[EitherT[Eval, String, *], Int, Int] = ContT.liftF(a)
scala> c.run(EitherT.rightT(_)).value.value
res0: Either[String, Int] = Right(1)
scala> c.run(_ => EitherT.leftT("a")).value.value
res1: Either[String, Int] = Left(a)
def liftK[M[_], B](M: FlatMap[M]): FunctionK[M, [_] =>> ContT[M, B, _$8]]

Same as liftF, but expressed as a FunctionK for use with mapK

Same as liftF, but expressed as a FunctionK for use with mapK

scala> import cats._, data._
scala> trait Foo[F[_]] { def bar: F[Int] }
scala> def mapK[F[_], G[_]](fooF: Foo[F])(f: F ~> G): Foo[G] = new Foo[G] { def bar: G[Int] = f(fooF.bar) }
scala> val eitherTFoo = new Foo[EitherT[Eval, String, *]] { def bar = EitherT.rightT(1) }
scala> val contTFoo: Foo[ContT[EitherT[Eval, String, *], Int, *]] = mapK(eitherTFoo)(ContT.liftK)
scala> contTFoo.bar.run(EitherT.rightT(_)).value.value
res0: Either[String, Int] = Right(1)
def pure[M[_], A, B](b: B): ContT[M, A, B]

Lift a pure value into ContT

Lift a pure value into ContT

def resetT[M[_], A, B](contT: ContT[M, B, B])(`evidence$1`: Monad[M], `evidence$2`: Defer[M]): ContT[M, A, B]
def shiftT[M[_], A, B](f: B => M[A] => ContT[M, A, A])(`evidence$3`: Applicative[M], `evidence$4`: Defer[M]): ContT[M, A, B]
def tailRecM[M[_], A, B, C](a: A)(fn: A => ContT[M, C, Either[A, B]])(M: Defer[M]): ContT[M, C, B]

Implicits

Implicits

implicit def catsDataContTDefer[M[_], B]: Defer[[_] =>> ContT[M, B, _$19]]
implicit def catsDataContTMonad[M[_], A](`evidence$5`: Defer[M]): Monad[[_] =>> ContT[M, A, _$22]]