trait RunContext[F[_]] extends Local[F] with Provide[F]

Combination of Local and Provide

F

context-aware effect e.g.ReaderT[Lower, Ctx, *]

Annotations
@deprecated
Deprecated

(Since version 0.10.3) Migrate to With* typeclasses

Linear Supertypes
Provide[F], Local[F], Context[F], ContextBase, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RunContext
  2. Provide
  3. Local
  4. Context
  5. ContextBase
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. abstract type Ctx
    Definition Classes
    Provide
  2. abstract type Lower[A]

    Result effect type without any notion of context

    Result effect type without any notion of context

    Definition Classes
    Provide

Abstract Value Members

  1. abstract def context: F[Ctx]
    Definition Classes
    Context
  2. abstract def functor: Functor[F]
    Definition Classes
    Context
  3. abstract def lift[A](la: Lower[A]): F[A]

    Converts context-unaware computation into contextual one by ignoring context

    Converts context-unaware computation into contextual one by ignoring context

    One can treat F[A] as function of type Ctx => Lower[A] so this method creates something like _ => la which has type Ctx => Lower[A]

    Definition Classes
    Provide
  4. abstract def local[A](fa: F[A])(project: (Ctx) => Ctx): F[A]

    Alters context for computation

    Alters context for computation

    fa

    computation that is going to run with different context

    project

    pure function

    returns

    result of ran computation fa

    Definition Classes
    Local
    Example:
    1. Example of usage is to hide sensitive information

       case class UserContext( id: String, phoneNumber: String
        //very sensitive )
      
      def hidePartOfPhoneNumber: String => String = ???
      
      def contextualLogInfo[F[_]](message: String)(implicit hasUserContext: UserContext In F): F[Unit] = ??? //logs both
      message AND UserContext
      
      def program[F[_]: Monad] = for { user <- obtainUserSomehow[F] implicit0(hasUserContext: In[User, F]) <-
      Context.const[F, User](user.toContext) logUser = contextualLogInfo[F](s"Successfully obtained user") _ <-
      logUser.local(hidePartOfPhoneNumber) //logs only part of phone number } yield ()
  5. abstract def runContext[A](fa: F[A])(ctx: Ctx): Lower[A]

    Runs fa providing ctx to it.

    Runs fa providing ctx to it.

    One can treat F as function of type Ctx => Lower[A] so this method applies it to ctx.

    fa

    Contextual computation

    returns

    Result of running fa and providing it context

    Definition Classes
    Provide
    Example:
    1. Example of usage is to hide sensitive information across a part of service

       import tofu.syntax.context._
      
      case class UserContext( id: String, phoneNumber: String //very sensitive ) def hidePartOfPhoneNumber: String =>
      String = ???
      
      def contextualLogInfo[F[_]](message: String)(implicit hasUserContext: UserContext In F): F[Unit] = ??? //logs both
      message AND UserContext
      
      def program[F[_]: WithRun[*[_], G[_], UserContext], G[_]: Monad] = for { user <- obtainUserSomehow[G] logUser =
      contextualLogInfo[F](s"Successfully obtained user") _ <- runContext[F](logUser)(user.toContext) //G[Unit] } yield
      ()
  6. abstract def self: WithRun[F, Lower, Ctx]
    Definition Classes
    RunContextProvide

Concrete 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 ask[A](f: (Ctx) => A): F[A]

    Returns context modified by pure function f.

    Returns context modified by pure function f.

    For example one can use it like that:

    Context[F].ask(myCtx => myCtx.toString)

    Also there is more convenient syntax:

    import tofu.syntax.context._
    
    ask[F](myCtx => myCtx.toString)
    Definition Classes
    Context
    Note

    It does not affect context itself.

  6. def askF[A](f: (Ctx) => F[A])(implicit F: FlatMap[F]): F[A]

    Same as ask but f is effectual

    Same as ask but f is effectual

    Definition Classes
    Context
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def extract[A](extract: Extract[Ctx, A]): WithContext[F, A]

    Allows to focus context on its inside with lens.

    Allows to focus context on its inside with lens.

    extract

    lens that can extract value of type A from Ctx

    Definition Classes
    Context
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  17. def runContextK(ctx: Ctx): ~>[F, Lower]

    Same as runContext but higher-kinded.

    Same as runContext but higher-kinded.

    Definition Classes
    Provide
    Example:
    1.  trait ProcessHandler[G[_]] { def mapK[M[_]](fk: G ~> M): ProcessHandler[M] = ??? //...other methods } type
        WithMyContext[F[_], A] = ReaderT[F, MyCtx, A] val contextualProcessHandler: ProcessHandler[IO WithMyContext *] =
        ???
      
      val processHandler: ProcessHandler[IO] = processHandler.mapK( WithProvide[IO WithMyContext *, IO,
      MyCtx].runContextK )
  18. def runEquivalent[A](eq: Equivalent[Ctx, A]): WithRun[F, Lower, A]

    Allows to focus Provide on inner parts of its context with equivalence lens.

    Allows to focus Provide on inner parts of its context with equivalence lens.

    eq

    lens that can convert from Ctx to A

  19. def runExtract[A](extract: Extract[A, Ctx]): WithProvide[F, Lower, A]

    Allows to focus Provide on inner parts of its context with lens.

    Allows to focus Provide on inner parts of its context with lens.

    extract

    lens that can extract from Ctx value of type A

    Definition Classes
    Provide
  20. def subcontext[A](contains: Contains[Ctx, A]): WithLocal[F, A]

    Allows to focus Local on inner parts of its context with lens.

    Allows to focus Local on inner parts of its context with lens.

    contains

    lens that can extract from Ctx or set some value of type A

    Definition Classes
    Local
  21. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  22. def toString(): String
    Definition Classes
    AnyRef → Any
  23. def unlift: F[~>[F, Lower]]

    Allows to convert some context-unaware computation into contextual one.

    Allows to convert some context-unaware computation into contextual one.

    Example:
    1.  trait ProcessHandler[G[_]] { def mapK[M[_]](fk: G ~> M): ProcessHandler[M] = ??? //...other methods }
      
      type WithMyContext[F[_], A] = ReaderT[F, MyCtx, A]
      
      val processHandler: ProcessHandler[IO WithMyContext *] = ???
      
      val contextualHandler: IO WithMyContext ProcessHandler[IO] = processHandler.mapK( WithRun[WithMyContext[IO, *],
      IO, MyCtx].unlift.map(fk => processHandler.mapK(fk)) ) //now it is able to process MyCtx but is wrapped in IO
      WithMyContext *
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

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

Inherited from Provide[F]

Inherited from Local[F]

Inherited from Context[F]

Inherited from ContextBase

Inherited from AnyRef

Inherited from Any

Ungrouped