我正在尝试创建一个 Stream[Eval, String] 如下:
import cats.Eval
import cats.effect.{ExitCode, IO, IOApp}
import fs2._
object StringEval extends IOApp {
def evalString: Eval[String] = Eval.always{
val r = new scala.util.Random(31)
r.nextString(4)
}
override def run(args: List[String]): IO[ExitCode] = {
Stream
.eval(evalString)
.repeat
.compile
.lastOrError
.start
.as(ExitCode.Success)
}
}
但问题是我得到一个编译错误说:
Error:(17, 8) could not find implicit value for parameter compiler: fs2.Stream.Compiler[[x]cats.Eval[x],G]
.compile
我似乎无法得到错误?我错过了什么?错误指的是什么?