FS2Provide
Attributes
- Graph
-
- Supertypes
-
trait WithProvide[[_] =>> Stream[F, _$55], [_] =>> Stream[G, _$56], R]trait Lift[[_] =>> Stream[G, _$56], [_] =>> Stream[F, _$55]]trait Provide[[_] =>> Stream[F, _$55]]trait ContextBaseclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
Members list
Value members
Concrete methods
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]
Attributes
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
.
Value parameters
- fa
-
Contextual computation
Attributes
- Returns
-
Result of running fa and providing it context
- Example
-
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 ()
Inherited methods
Attributes
- Inherited from:
- Lift
Same as runContext but higher-kinded.
Same as runContext but higher-kinded.
Attributes
- Example
-
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 )
- Definition Classes
-
WithProvide -> Provide
- Inherited from:
- WithProvide
Allows to focus Provide on inner parts of its context with lens.
Allows to focus Provide on inner parts of its context with lens.
Value parameters
- extract
-
lens that can extract from
Ctx
value of typeA
Attributes
- Definition Classes
-
WithProvide -> Provide
- Inherited from:
- WithProvide
Attributes
- Inherited from:
- WithProvide