I'm trying to create a Stream[Eval, String] as follows :
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)
}
}
But the problem is that I'm getting a compilation error saying :
Error:(17, 8) could not find implicit value for parameter compiler: fs2.Stream.Compiler[[x]cats.Eval[x],G]
.compile
I can't seem to get the error ? what am I missing? What does the error refer to ?
Fs2 Stream.Compiler is not found (could not find implicit value Compiler[[x]F[x],G])
Fs2
Stream#compile
now requires aSync[F]
Eval
doesn't have instance of Sync
, IO
does.
Try
def evalString: IO[String] = {
val r = new scala.util.Random(31)
Sync[IO].delay(r.nextString(4))
}
Stream
.eval(evalString)
.repeat
.compile
.lastOrError
.start
.as(ExitCode.Success)