Class/Object

cats.data

StateT

Related Docs: object StateT | package data

Permalink

final class StateT[F[_], S, A] extends Serializable

StateT[F, S, A] is similar to Kleisli[F, S, A] in that it takes an S argument and produces an A value wrapped in F. However, it also produces an S value representing the updated state (which is wrapped in the F context along with the A value.

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StateT
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StateT(runF: F[(S) ⇒ F[(S, A)]])

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def flatMap[B](fas: (A) ⇒ StateT[F, S, B])(implicit F: Monad[F]): StateT[F, S, B]

    Permalink
  10. def flatMapF[B](faf: (A) ⇒ F[B])(implicit F: Monad[F]): StateT[F, S, B]

    Permalink
  11. def get(implicit F: Monad[F]): StateT[F, S, S]

    Permalink

    Get the input state, without modifying the state.

  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. def inspect[B](f: (S) ⇒ B)(implicit F: Monad[F]): StateT[F, S, B]

    Permalink

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

  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. def map[B](f: (A) ⇒ B)(implicit F: Monad[F]): StateT[F, S, B]

    Permalink
  17. def modify(f: (S) ⇒ S)(implicit F: Monad[F]): StateT[F, S, A]

    Permalink

    Modify the state (S) component.

  18. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. def run(initial: S)(implicit F: FlatMap[F]): F[(S, A)]

    Permalink

    Run with the provided initial state value

  22. def runA(s: S)(implicit F: FlatMap[F]): F[A]

    Permalink

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

  23. def runEmpty(implicit S: Monoid[S], F: FlatMap[F]): F[(S, A)]

    Permalink

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

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

    Permalink

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

  25. def runEmptyS(implicit S: Monoid[S], F: FlatMap[F]): F[S]

    Permalink

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

  26. val runF: F[(S) ⇒ F[(S, A)]]

    Permalink
  27. def runS(s: S)(implicit F: FlatMap[F]): F[S]

    Permalink

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

  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  29. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  30. def transform[B](f: (S, A) ⇒ (S, B))(implicit F: Monad[F]): StateT[F, S, B]

    Permalink

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

  31. def transformF[G[_], B](f: (F[(S, A)]) ⇒ G[(S, B)])(implicit F: FlatMap[F], G: Applicative[G]): StateT[G, S, B]

    Permalink

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

  32. def transformS[R](f: (R) ⇒ S, g: (R, S) ⇒ R)(implicit F: Monad[F]): StateT[F, R, A]

    Permalink

    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.std.option._ // 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))
  33. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped