c

tofu.data.calc

CalcContextInstance

class CalcContextInstance[F[+_, +_], R, S, E] extends WithRun[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], R]

Linear Supertypes
WithRun[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], R], Unlift[[ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], [ζ$9$]CalcM[F, R, S, S, E, ζ$9$]], RunContext[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]], WithLocal[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], R], WithContext[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], R], Local[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]], Context[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]], WithProvide[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], R], Lift[[ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], [ζ$9$]CalcM[F, R, S, S, E, ζ$9$]], Provide[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]], ContextBase, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CalcContextInstance
  2. WithRun
  3. Unlift
  4. RunContext
  5. WithLocal
  6. WithContext
  7. Local
  8. Context
  9. WithProvide
  10. Lift
  11. Provide
  12. ContextBase
  13. AnyRef
  14. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CalcContextInstance()

Type Members

  1. type Ctx = R
    Definition Classes
    WithRunWithContextContextWithProvideProvide
  2. type Lower[A] = CalcM[F, Any, S, S, E, A]

    Result effect type without any notion of context

    Result effect type without any notion of context

    Definition Classes
    WithProvideProvide

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. def andThen[H[_]](ugh: Unlift[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], H])(implicit arg0: Monad[H]): Unlift[[ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], H]
    Definition Classes
    Unlift
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def asWithContext: WithContext[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], R]
    Definition Classes
    WithContextContext
  7. def ask[A](f: (CalcContextInstance.Ctx) ⇒ A): CalcM[F, R, S, S, E, 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
    WithContextContext
    Note

    It does not affect context itself.

  8. def askF[A](f: (CalcContextInstance.Ctx) ⇒ CalcM[F, R, S, S, E, A])(implicit F: FlatMap[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]): CalcM[F, R, S, S, E, A]

    Same as ask but f is effectual

    Same as ask but f is effectual

    Definition Classes
    WithContextContext
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @IntrinsicCandidate()
  10. val context: CalcM[F, R, S, S, E, R]
    Definition Classes
    CalcContextInstanceContext
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def extract[A](extract: Extract[CalcContextInstance.Ctx, A]): ContextExtractInstance[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], CalcContextInstance.Ctx, 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
    WithContextContext
  14. val functor: Functor[[ζ$11$]CalcM[F, R, S, S, E, ζ$11$]]
    Definition Classes
    CalcContextInstanceContext
  15. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def lift[A](fa: CalcM[F, Any, S, S, E, A]): CalcM[F, R, S, S, E, 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
    CalcContextInstanceUnliftWithProvideLiftProvide
  19. def liftF: FunctionK[[ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], [ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]
    Definition Classes
    Lift
  20. def local[A](fa: CalcM[F, R, S, S, E, A])(project: (R) ⇒ R): CalcM[F, R, S, S, E, 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
    CalcContextInstanceWithLocalLocal
    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 ()
  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  24. def runContext[A](fa: CalcM[F, R, S, S, E, A])(ctx: R): CalcM[F, Any, S, S, E, 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
    CalcContextInstanceWithProvideProvide
    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
      ()
  25. def runContextK(ctx: CalcContextInstance.Ctx): ~>[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], Lower]

    Same as runContext but higher-kinded.

    Same as runContext but higher-kinded.

    Definition Classes
    WithProvideProvide
    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 )
  26. def runEquivalent[A](eq: Equivalent[Ctx, A]): WithRun[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], 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 value of type A

    Definition Classes
    WithRunRunContext
  27. def runExtract[A](extract: Extract[A, CalcContextInstance.Ctx]): WithProvide[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], 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
    WithProvideProvide
  28. def self: WithRun[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], R]
    Definition Classes
    WithRunRunContextWithProvideProvide
  29. def subIso(implicit G: Functor[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]): CalcM[F, R, S, S, E, IsoK[[ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], [ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]]
    Definition Classes
    Unlift
  30. def subcontext[A](contains: Contains[CalcContextInstance.Ctx, A]): WithLocal[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], 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
    WithLocalLocal
  31. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  32. def toString(): String
    Definition Classes
    AnyRef → Any
  33. def unlift: CalcM[F, R, S, S, E, ~>[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$]]]

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

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

    Definition Classes
    WithRunUnliftRunContext
    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 *
  34. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  36. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

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

Inherited from WithRun[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], R]

Inherited from Unlift[[ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], [ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]

Inherited from RunContext[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]

Inherited from WithLocal[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], R]

Inherited from WithContext[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], R]

Inherited from Local[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]

Inherited from Context[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]

Inherited from WithProvide[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$], [ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], R]

Inherited from Lift[[ζ$10$]CalcM[F, Any, S, S, E, ζ$10$], [ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]

Inherited from Provide[[ζ$9$]CalcM[F, R, S, S, E, ζ$9$]]

Inherited from ContextBase

Inherited from AnyRef

Inherited from Any

Ungrouped