Using Cats, I have my functor declarations in a package object. This works fine, except for the futureFunctor
, as it requires an implicit ExecutionContext
:
package object util {
implicit val futureFunctor: Functor[Future] = new Functor[Future] {
//requires execution context:
def map[A, B](fa: Future[A])(f: A => B): Future[B] = fa map f
}
...
}
Is there a way to implement futureFunctor
such that it can acquire the execution context from the calling scope? I would hate to have to create a new implementation within each calling class instead of in the package. I am dependency-injecting my execution contexts into my classes, so just importing the global here isn't really practical. Thanks.