cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

Add `FiberLocal.Make`

Open kubukoz opened this issue 4 years ago • 11 comments
trafficstars

Follow-up to #1393.

I think users will likely want to create fiber locals for an abstract effect. We can surely create them in IO and other effects that have this functionality, it is probably possible for monad transformers too (I might be missing something).

It would be great to have an abstraction for this that people can depend on instead of sticking to IO:

object FiberLocal {
  trait Make[F[_]] {
    def make(a: A): F[FiberLocal[F, A]]
  }

  object Make {
    implicit val makeForIO: Make[IO] = ...
    
    implicit def makeForOptionT[F[_]: Make]: Make[OptionT[F, *]] = ...
  }
}

kubukoz avatar Mar 26 '21 15:03 kubukoz