CE 2.x.Monix 3.4。第1行编译,第2行给出编译错误:
cats.kernel.Order[A]类型的发散隐式展开从对象Eq中的方法catsKernelOrderForFunction0开始Stream.sleep_(5.seconds(.compile.dlean.as(ExitCode.Success(//2
import cats.effect.{ExitCode, Timer}
import fs2.Stream
import monix.eval.{Task, TaskApp}
import scala.concurrent.duration.DurationInt
object ImplicitsFreeze extends TaskApp {
def run(args: List[String]): Task[ExitCode] = {
Stream.sleep_(5.seconds)(implicitly[Timer[Task]]).compile.drain.as(ExitCode.Success) // 1
// Stream.sleep_(5.seconds).compile.drain.as(ExitCode.Success) // 2
}
}
添加效果类型的注释解决了问题
Stream.sleep_[Task](5.seconds).compile.drain.as(ExitCode.Success) // 2