Reputation: 14813
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?
Upvotes: 3
Views: 989
Reputation: 14813
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.
Upvotes: 3
Reputation: 4463
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/
Upvotes: 1