Packages

final class IndexedStateT[F[_], SA, SB, A] extends Serializable

IndexedStateT[F, SA, SB, A] is a stateful computation in a context F yielding a value of type A. The state transitions from a value of type SA to a value of type SB.

Note that for the SA != SB case, this is an indexed monad. Indexed monads are monadic type constructors annotated by an additional type for effect tracking purposes. In this case, the annotation tracks the initial state and the resulting state.

Given IndexedStateT[F, S, S, A], this yields the StateT[F, S, A] monad.

Source
IndexedStateT.scala
Linear Supertypes
Serializable, Serializable, AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. IndexedStateT
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new IndexedStateT(runF: F[(SA) ⇒ F[(SB, A)]])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def bimap[SC, B](f: (SB) ⇒ SC, g: (A) ⇒ B)(implicit F: Functor[F]): IndexedStateT[F, SA, SC, B]
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @IntrinsicCandidate()
  7. def contramap[S0](f: (S0) ⇒ SA)(implicit F: Functor[F]): IndexedStateT[F, S0, SB, A]
  8. def dimap[S0, S1](f: (S0) ⇒ SA)(g: (SB) ⇒ S1)(implicit F: Functor[F]): IndexedStateT[F, S0, S1, A]
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def flatMap[B, SC](fas: (A) ⇒ IndexedStateT[F, SB, SC, B])(implicit F: FlatMap[F]): IndexedStateT[F, SA, SC, B]
  12. def flatMapF[B](faf: (A) ⇒ F[B])(implicit F: FlatMap[F]): IndexedStateT[F, SA, SB, B]
  13. def get(implicit F: Functor[F]): IndexedStateT[F, SA, SB, SB]

    Get the input state, without modifying the state.

  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  16. def inspect[B](f: (SB) ⇒ B)(implicit F: Functor[F]): IndexedStateT[F, SA, SB, B]

    Inspect a value from the input state, without modifying the state.

  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def map[B](f: (A) ⇒ B)(implicit F: Functor[F]): IndexedStateT[F, SA, SB, B]
  19. def mapK[G[_]](f: ~>[F, G])(implicit F: Functor[F]): IndexedStateT[G, SA, SB, A]

    Modify the context F using transformation f.

  20. def modify[SC](f: (SB) ⇒ SC)(implicit F: Functor[F]): IndexedStateT[F, SA, SC, A]

    Modify the state (S) component.

  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  24. def run(initial: SA)(implicit F: FlatMap[F]): F[(SB, A)]

    Run with the provided initial state value

  25. def runA(s: SA)(implicit F: FlatMap[F]): F[A]

    Run with the provided initial state value and return the final value (discarding the final state).

  26. def runEmpty(implicit S: Monoid[SA], F: FlatMap[F]): F[(SB, A)]

    Run with S's empty monoid value as the initial state.

  27. def runEmptyA(implicit S: Monoid[SA], F: FlatMap[F]): F[A]

    Run with S's empty monoid value as the initial state and return the final value (discarding the final state).

  28. def runEmptyS(implicit S: Monoid[SA], F: FlatMap[F]): F[SB]

    Run with S's empty monoid value as the initial state and return the final state (discarding the final value).

  29. val runF: F[(SA) ⇒ F[(SB, A)]]
  30. def runS(s: SA)(implicit F: FlatMap[F]): F[SB]

    Run with the provided initial state value and return the final state (discarding the final value).

  31. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  32. def toString(): String
    Definition Classes
    AnyRef → Any
  33. def transform[B, SC](f: (SB, A) ⇒ (SC, B))(implicit F: Functor[F]): IndexedStateT[F, SA, SC, B]

    Like map, but also allows the state (S) value to be modified.

  34. def transformF[G[_], B, SC](f: (F[(SB, A)]) ⇒ G[(SC, B)])(implicit F: FlatMap[F], G: Applicative[G]): IndexedStateT[G, SA, SC, B]

    Like transform, but allows the context to change from F to G.

    Like transform, but allows the context to change from F to G.

    scala> import cats.implicits._
    scala> type ErrorOr[A] = Either[String, A]
    scala> val xError: IndexedStateT[ErrorOr, Int, Int, Int] = IndexedStateT.get
    scala> val xOpt: IndexedStateT[Option, Int, Int, Int] = xError.transformF(_.toOption)
    scala> val input = 5
    scala> xError.run(input)
    res0: ErrorOr[(Int, Int)] = Right((5,5))
    scala> xOpt.run(5)
    res1: Option[(Int, Int)] = Some((5,5))
  35. def transformS[R](f: (R) ⇒ SA, g: (R, SB) ⇒ R)(implicit F: Functor[F]): IndexedStateT[F, R, R, A]

    Transform the state used.

    Transform the state used.

    This is useful when you are working with many focused StateTs and want to pass in a global state containing the various states needed for each individual StateT.

    scala> import cats.implicits._ // needed for StateT.apply
    scala> type GlobalEnv = (Int, String)
    scala> val x: StateT[Option, Int, Double] = StateT((x: Int) => Option((x + 1, x.toDouble)))
    scala> val xt: StateT[Option, GlobalEnv, Double] = x.transformS[GlobalEnv](_._1, (t, i) => (i, t._2))
    scala> val input = 5
    scala> x.run(input)
    res0: Option[(Int, Double)] = Some((6,5.0))
    scala> xt.run((input, "hello"))
    res1: Option[(GlobalEnv, Double)] = Some(((6,hello),5.0))
  36. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  38. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped