1

I assume this is an easy one but I’m running into problem where the FlatMap or Functor of a Monix Task cannot be found. I use a "type alias" to simplify a long type signiture but then in the for-comprehession I receive a "could not find implicit value" error. If I remove the type alias then it works because Monix has cats support. Would anyone have a suggestion on how to tell the compiler that TaskEither is a Monix Task and can just use the cats instances provided by Monix Task. Type alias:

type TaskEither[A] = Task[Either[Erratum, A]]

Method where the error occurs: Note: getBotForUser and processBotDetails are both wrapped in a Kleisli similar to findCreateBot method

def findCreateBot(msg: Routing): Kleisli[TaskEither, DBRepo[MySQLProfile, ServiceConfig[Config]], ActorRef] ={
    import Task._
    for {
      bot <- XmppRepository[MySQLProfile, ServiceConfig[Config]].getBotForUser(msg.routingHeader.to.userID)
      botRef <- processBotDetails(bot)
    } yield botRef
  }

error message:

XMPPGateway.scala:61:14: could not find implicit value for parameter F: cats.Functor[MyTypes.TaskEither]
[error]       botRef <- processBotDetails(bot)
[error]  

        ^

error message:

XMPPGateway.scala:60:11: could not find implicit value for parameter F: cats.FlatMap[MyTypes.TaskEither]
[error]       bot <- XmppRepository[MySQLProfile, ServiceConfig[Config]].getBotForUser(msg.routingHeader.to.userID)
[error]  

     ^
Adam Wayland
  • 354
  • 1
  • 2
  • 9

1 Answers1

0

If u use an cats either, u must import cats.data._ import cats.implicits._

znndrd
  • 79
  • 1
  • 8
  • Hi Ed.Zanon, I have tried those imports but the problem is that the compiler does not recognize TaskEither as Task[Either[Erratum, A]]. The Task FlatMap instance is in scope, i.e import Task._ – Adam Wayland Jul 20 '18 at 17:17