2
votes

I have the following class:

class MyBot[F[_] : FlatMap]

In this class I have a function:

private def handleCallback(): F[Boolean]

In my understanding this should work:

handleCallback().flatMap(..)

But it throws: cannot resolve symbol flatMap

What do I miss?

2

2 Answers

2
votes

The solution of Mon Calamari did not fix my problem, but when checking FlatMap on the suggested Blog I spotted:

import cats.implicits._ which I missed - and fixed my problem - everything stayed the same.

1
votes

You'd need to summon an instance of FlatMap[F] and use its methods to flatMap:

class MyBot[F[_]](implicit F: FlatMap[F]) {

  def handleCallback: F[Boolean] = ...

  def flatMapCallback: F[Boolean] = F.flatMap(handleCallback) { bool => 
    ...
  }

}

More details in great blog from eed3si9n: http://eed3si9n.com/herding-cats/