Scala diverging implicit expansion for cats.effect.Timer when using monix TaskApp

211 views Asked by At

CE 2.x. Monix 3.4. Line 1 compiles, line 2 gives a compilation error:

diverging implicit expansion for type cats.kernel.Order[A] starting with method catsKernelOrderForFunction0 in object 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
  }

}
1

There are 1 answers

0
Kamil Kloch On

Adding annotation of the effect type solves the issue

Stream.sleep_[Task](5.seconds).compile.drain.as(ExitCode.Success) // 2