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.
- Alphabetic
- By Inheritance
- IndexedStateT
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new IndexedStateT(runF: F[(SA) ⇒ F[(SB, A)]])
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def bimap[SC, B](f: (SB) ⇒ SC, g: (A) ⇒ B)(implicit F: Functor[F]): IndexedStateT[F, SA, SC, B]
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- def contramap[S0](f: (S0) ⇒ SA)(implicit F: Functor[F]): IndexedStateT[F, S0, SB, A]
- def dimap[S0, S1](f: (S0) ⇒ SA)(g: (SB) ⇒ S1)(implicit F: Functor[F]): IndexedStateT[F, S0, S1, A]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def flatMap[B, SC](fas: (A) ⇒ IndexedStateT[F, SB, SC, B])(implicit F: FlatMap[F]): IndexedStateT[F, SA, SC, B]
- def flatMapF[B](faf: (A) ⇒ F[B])(implicit F: FlatMap[F]): IndexedStateT[F, SA, SB, B]
-
def
get(implicit F: Functor[F]): IndexedStateT[F, SA, SB, SB]
Get the input state, without modifying the state.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
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.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) ⇒ B)(implicit F: Functor[F]): IndexedStateT[F, SA, SB, B]
-
def
mapK[G[_]](f: ~>[F, G])(implicit F: Functor[F]): IndexedStateT[G, SA, SB, A]
Modify the context
F
using transformationf
. -
def
modify[SC](f: (SB) ⇒ SC)(implicit F: Functor[F]): IndexedStateT[F, SA, SC, A]
Modify the state (
S
) component. -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
run(initial: SA)(implicit F: FlatMap[F]): F[(SB, A)]
Run with the provided initial state value
-
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).
-
def
runEmpty(implicit S: Monoid[SA], F: FlatMap[F]): F[(SB, A)]
Run with
S
's empty monoid value as the initial state. -
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). -
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). - val runF: F[(SA) ⇒ F[(SB, A)]]
-
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).
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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. -
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
toG
.Like transform, but allows the context to change from
F
toG
.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))
-
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
StateT
s and want to pass in a global state containing the various states needed for each individualStateT
.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))
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()