trait Provide[F[_]] extends ContextBase

Allows to evaluate contextual computation with some context

The main use case for it is to obtain some context Lower[Ctx], and then to run another contextual computation F[A] that can use F[Ctx] inside.

F

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

Annotations
@deprecated
Deprecated

(Since version 0.10.3) Migrate to With* typeclasses

Linear Supertypes
ContextBase, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Provide
  2. ContextBase
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. abstract type Ctx
  2. abstract type Lower[A]

    Result effect type without any notion of context

Abstract Value Members

  1. 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]

  2. 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

    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
      ()
  3. abstract def self: WithProvide[F, Lower, Ctx]

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 clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  14. def runContextK(ctx: Ctx): ~>[F, Lower]

    Same as runContext but higher-kinded.

    Same as runContext but higher-kinded.

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

  16. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  17. def toString(): String
    Definition Classes
    AnyRef → Any
  18. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  20. 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 ContextBase

Inherited from AnyRef

Inherited from Any

Ungrouped