trait WithProvide[F[_], G[_], C] extends Provide[F] with Lift[G, F]
Synonym for Provide with explicit C
as Ctx
and G
as Lower
for better type inference
Can be seen as transformation F[*] = C => G[*]
- Alphabetic
- By Inheritance
- WithProvide
- Lift
- Provide
- ContextBase
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- type Ctx = C
- Definition Classes
- WithProvide → Provide
- type Lower[A] = G[A]
Result effect type without any notion of context
Result effect type without any notion of context
- Definition Classes
- WithProvide → Provide
Abstract Value Members
- 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 typeCtx => Lower[A]
so this method creates something like_ => la
which has typeCtx => Lower[A]
- Definition Classes
- WithProvide → Lift → Provide
- abstract def runContext[A](fa: F[A])(ctx: Ctx): Lower[A]
Runs
fa
providingctx
to it.Runs
fa
providingctx
to it.One can treat F as function of type
Ctx => Lower[A]
so this method applies it toctx
.- fa
Contextual computation
- returns
Result of running fa and providing it context
- Definition Classes
- WithProvide → Provide
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 ()
Example:
Concrete 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 clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def liftF: FunctionK[G, F]
- Definition Classes
- Lift
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def runContextK(ctx: Ctx): ~>[F, Lower]
Same as runContext but higher-kinded.
Same as runContext but higher-kinded.
- Definition Classes
- WithProvide → Provide
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 )
Example: - 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 typeA
- Definition Classes
- WithProvide → Provide
- def self: WithProvide[F, G, C]
- Definition Classes
- WithProvide → Provide
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated