Packages

final class IndexedReaderWriterStateT[F[_], E, L, SA, SB, A] extends Serializable

Represents a stateful computation in a context F[_], from state SA to state SB, with an initial environment E, an accumulated log L and a result A.

In other words, it is a pre-baked stack of ReaderT[F, E, A], WriterT[F, L, A] and IndexedStateT[F, SA, SB, A].

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

Instance Constructors

  1. new IndexedReaderWriterStateT(runF: F[(E, SA) ⇒ F[(L, 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]): IndexedReaderWriterStateT[F, E, L, SA, SC, B]

    Modify the resulting state using f and the resulting value using g.

  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]): IndexedReaderWriterStateT[F, E, L, S0, SB, A]

    Modify the initial state using f.

  8. def dimap[S0, S1](f: (S0) ⇒ SA)(g: (SB) ⇒ S1)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, S0, S1, A]

    Modify the initial state using f and the resulting state using g.

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def flatMap[SC, B](f: (A) ⇒ IndexedReaderWriterStateT[F, E, L, SB, SC, B])(implicit F: FlatMap[F], L: Semigroup[L]): IndexedReaderWriterStateT[F, E, L, SA, SC, B]

    Modify the result of the computation by feeding it into f, threading the state through the resulting computation and combining the log values.

  12. def flatMapF[B](faf: (A) ⇒ F[B])(implicit F: FlatMap[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, B]

    Like map, but allows the mapping function to return an effectful value.

  13. def get(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, SB]

    Get the input state, without modifying it.

  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]): IndexedReaderWriterStateT[F, E, L, SA, SB, B]

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

  17. def inspectAsk[B](f: (E, SB) ⇒ B)(implicit F: Monad[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, B]

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

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

    scala> import cats.implicits._
    scala> type Env = String
    scala> type Log = List[String]
    scala> val xOpt: IndexedReaderWriterStateT[Option, Env, Log, Int, Int, Int] = IndexedReaderWriterStateT.get
    scala> val xAsk: IndexedReaderWriterStateT[Option, Env, Log, Int, Int, String] = xOpt.inspectAsk(_ + _)
    scala> val input = 5
    scala> xOpt.run("env", input)
    res0: Option[(Log, Int, Int)] = Some((List(),5,5))
    scala> xAsk.run("env", 5)
    res1: Option[(Log, Int, String)] = Some((List(),5,env5))
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def listen(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, (A, L)]

    Example:

    Example:

    scala> import cats.implicits._
    scala> val x: IndexedReaderWriterStateT[Option, String, String, Int, Int, Unit] = IndexedReaderWriterStateT.tell("something")
    scala> val y: IndexedReaderWriterStateT[Option, String, String, Int, Int, (Unit, String)] = x.listen
    scala> y.run("environment", 17)
    res0: Option[(String, Int, (Unit, String))] = Some((something,17,((),something)))
  20. def local[EE](f: (EE) ⇒ E)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, EE, L, SA, SB, A]

    Modify the initial environment using f.

    Modify the initial environment using f.

    scala> import cats.implicits._
    scala> type Env = String
    scala> type GlobalEnv = (Int, Env)
    scala> type Log = List[String]
    scala> val xLocal: IndexedReaderWriterStateT[Option, Env, Log, Int, Int, Int] = IndexedReaderWriterStateT.get
    scala> val xGlobal: IndexedReaderWriterStateT[Option, GlobalEnv, Log, Int, Int, Int] = xLocal.local(_._2)
    scala> val globalEnv: GlobalEnv = (5, "env")
    scala> xGlobal.run(globalEnv, 5)
    res0: Option[(List[String], Int, Int)] = Some((List(),5,5))
  21. def map[B](f: (A) ⇒ B)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, B]

    Modify the result of the computation using f.

  22. def mapK[G[_]](f: ~>[F, G])(implicit F: Functor[F]): IndexedReaderWriterStateT[G, E, L, SA, SB, A]

    Modify the context F using transformation f.

  23. def mapWritten[LL](f: (L) ⇒ LL)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, LL, SA, SB, A]

    Modify the written log value using f.

  24. def modify[SC](f: (SB) ⇒ SC)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SC, A]

    Modify the resulting state.

  25. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  27. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  28. def reset(implicit F: Functor[F], L: Monoid[L]): IndexedReaderWriterStateT[F, E, L, SA, SB, A]

    Clear the log.

  29. def run(env: E, initial: SA)(implicit F: Monad[F]): F[(L, SB, A)]

    Run the computation using the provided initial environment and state.

  30. def runA(env: E, initial: SA)(implicit F: Monad[F]): F[A]

    Like run, but discards the final state and log.

  31. def runEmpty(env: E)(implicit F: Monad[F], SA: Monoid[SA]): F[(L, SB, A)]

    Run the computation using the provided environment and an empty state.

  32. def runEmptyA(env: E)(implicit F: Monad[F], SA: Monoid[SA]): F[A]

    Like runEmpty, but discards the final state and log.

  33. def runEmptyL(env: E)(implicit F: Monad[F], SA: Monoid[SA]): F[L]

    Like runEmpty, but discards the final state and value.

  34. def runEmptyS(env: E)(implicit F: Monad[F], SA: Monoid[SA]): F[SB]

    Like runEmpty, but discards the final value and log.

  35. val runF: F[(E, SA) ⇒ F[(L, SB, A)]]
  36. def runL(env: E, initial: SA)(implicit F: Monad[F]): F[L]

    Like run, but discards the final state and value.

  37. def runS(env: E, initial: SA)(implicit F: Monad[F]): F[SB]

    Like run, but discards the final value and log.

  38. def semiflatTransform[LL, SC, B](f: (L, SB, A) ⇒ F[(LL, SC, B)])(implicit F: Monad[F]): IndexedReaderWriterStateT[F, E, LL, SA, SC, B]

    Like transform, but does it in the monadic context F.

    Like transform, but does it in the monadic context F.

    scala> import cats.implicits._
    scala> type Env = String
    scala> type Log = List[String]
    scala> val xOpt0: IndexedReaderWriterStateT[Option, Env, Log, Int, Int, Int] = IndexedReaderWriterStateT.get
    scala> val xOpt: IndexedReaderWriterStateT[Option, Env, Log, Int, Int, Int] = xOpt0.tell("xxx" :: Nil)
    scala> val xHead: IndexedReaderWriterStateT[Option, Env, Log, Int, Int, String] = xOpt.semiflatTransform((l, s, a) => l.headOption.map(h => (l, s, h + a)))
    scala> val input = 5
    scala> xOpt.run("env", input)
    res0: Option[(Log, Int, Int)] = Some((List(xxx),5,5))
    scala> xHead.run("env", 5)
    res1: Option[(Log, Int, String)] = Some((List(xxx),5,xxx5))
  39. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  40. def tell(l: L)(implicit F: Functor[F], L: Semigroup[L]): IndexedReaderWriterStateT[F, E, L, SA, SB, A]

    Add a value to the log.

  41. def toString(): String
    Definition Classes
    AnyRef → Any
  42. def transform[LL, SC, B](f: (L, SB, A) ⇒ (LL, SC, B))(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, LL, SA, SC, B]

    Transform the resulting log, state and value using f.

  43. def transformF[G[_], LL, SC, B](f: (F[(L, SB, A)]) ⇒ G[(LL, SC, B)])(implicit F: Monad[F], G: Applicative[G]): IndexedReaderWriterStateT[G, E, LL, 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> type Env = String
    scala> type Log = List[String]
    scala> val xError: IndexedReaderWriterStateT[ErrorOr, Env, Log, Int, Int, Int] = IndexedReaderWriterStateT.get
    scala> val xOpt: IndexedReaderWriterStateT[Option, Env, Log, Int, Int, Int] = xError.transformF(_.toOption)
    scala> val input = 5
    scala> xError.run("env", input)
    res0: ErrorOr[(Log, Int, Int)] = Right((List(),5,5))
    scala> xOpt.run("env", 5)
    res1: Option[(Log, Int, Int)] = Some((List(),5,5))
  44. def transformS[R](f: (R) ⇒ SA, g: (R, SB) ⇒ R)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, R, R, A]

    Transform the state used.

    Transform the state used. See StateT for more details.

    scala> import cats.implicits._ // needed for StateT.apply
    scala> type Env = String
    scala> type Log = List[String]
    scala> type S[SA, SB, A] = IndexedReaderWriterStateT[Option, Env, Log, SA, SB, A]
    scala> type GlobalEnv = (Int, String)
    scala> val x: S[Int, Int, Double] = IndexedReaderWriterStateT((env: Env, x: Int) => Option(("Addition" :: Nil, x + 1, x.toDouble)))
    scala> val xt: S[GlobalEnv, GlobalEnv, Double] = x.transformS[GlobalEnv](_._1, (t, i) => (i, t._2))
    scala> val input = 5
    scala> x.run("env", input)
    res0: Option[(Log, Int, Double)] = Some((List(Addition),6,5.0))
    scala> xt.run("env", (input, "hello"))
    res1: Option[(Log, GlobalEnv, Double)] = Some((List(Addition),(6,hello),5.0))
  45. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  46. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  47. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  48. def written(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, L]

    Retrieve the value written to the log.

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