kostja kostja - 1 year ago 173
Scala Question

missing Cats Functor[Future] instance

I am trying to use

to combine methods returning
in a for-comprehension.

import cats.data._
import cats.implicits._
import cats.instances.future._

for {
data <- OptionT(repo.getData(id))

The compiler error I am getting:

could not find implicit value for parameter F cats.Functor[scala.concurrent.Future]

This recent example suggests that this is (was?) possible.

so do the docs in the pull request for adding

and the (cats

What am I missing here?

Thank you

Answer Source

By importing cats.implicits._ you are actually already importing cats.syntax.AllSyntax and cats.instances.AllInstances

Try using just those imports:

import cats.data._
import cats.implicits._

or (according to your needs):

import cats.data._
import cats.instances.future._

you may also need:

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

Note: of course you have to implicitly provide an actual ExecutionContext in a production environment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download