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
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. IndexedStateT
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

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(classOf[java.lang.CloneNotSupportedException]) @native()
  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: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  12. def flatMap[B, SC](fas: (A) => IndexedStateT[F, SB, SC, B])(implicit F: FlatMap[F]): IndexedStateT[F, SA, SC, B]
  13. def flatMapF[B](faf: (A) => F[B])(implicit F: FlatMap[F]): IndexedStateT[F, SA, SB, B]
  14. def get(implicit F: Functor[F]): IndexedStateT[F, SA, SB, SB]

    Get the input state, without modifying the state.

  15. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. 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.

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

    Modify the context F using transformation f.

  21. def modify[SC](f: (SB) => SC)(implicit F: Functor[F]): IndexedStateT[F, SA, SC, A]

    Modify the state (S) component.

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

    Run with the provided initial state value

  26. 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).

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

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

  28. 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).

  29. 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).

  30. val runF: F[(SA) => F[(SB, A)]]
  31. 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).

  32. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  33. def toString(): String
    Definition Classes
    AnyRef → Any
  34. 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.

  35. 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.syntax.all._
    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))
  36. 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.syntax.all._ // 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))
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped