1

CE 2.x。莫尼克斯 3.4。第 1 行编译,第 2 行给出编译错误:

从对象 Eq Stream.sleep_(5.seconds).compile.drain.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
  }

}
4

1 回答 1

1

添加效果类型的注释解决了这个问题

Stream.sleep_[Task](5.seconds).compile.drain.as(ExitCode.Success) // 2
于 2021-07-14T09:39:43.373 回答