我认为这是一个简单的问题,但我遇到了无法找到 Monix 任务的 FlatMap 或 Functor 的问题。我使用“类型别名”来简化长类型签名,但随后在 for-comprehession 中收到“找不到隐式值”错误。如果我删除类型别名,那么它会起作用,因为 Monix 支持猫。是否有人对如何告诉编译器 TaskEither 是 Monix 任务并且可以只使用 Monix Task 提供的猫实例提出建议。键入别名:
type TaskEither[A] = Task[Either[Erratum, A]]
发生错误的方法: 注意:getBotForUser 和 processBotDetails 都被包裹在一个类似于 findCreateBot 方法的 Kleisli 中
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
}
错误信息:
XMPPGateway.scala:61:14: could not find implicit value for parameter F: cats.Functor[MyTypes.TaskEither]
[error] botRef <- processBotDetails(bot)
[error]
^
错误信息:
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]
^