5

I am trying to compile the stream, but somehow Compiler is not in scope, what context bound is needed for bringing it in scope?

import cats.Monad

def compilingStream[F[_]: Monad]: F[List[Int]] = {
  val stream: fs2.Stream[F, Int] = fs2.Stream.emit(1).covary[F]
  stream.head.compile.toList
}


error: could not find implicit value for parameter compiler: fs2.Stream.Compiler[[x]F[x],G]
         stream.head.compile.toList
                     ^

Mikhail Golubtsov
  • 6,285
  • 3
  • 29
  • 36

1 Answers1

7

Fs2 Stream#compile now requires a Sync[F] (see this):

  import cats.effect.Sync

  def compilingStream[F[_]: Sync]: F[List[Int]] = {
    val stream: fs2.Stream[F, Int] = fs2.Stream.emit(1).covary[F]
    stream.head.compile.toList
  }

This is communicated by the library maintainer:

fs2 Stream#compile now requires a Sync[F]. Even on completely pure streams. Because of resource management. Sad. Panda.

Daniel Spiewak

Mikhail Golubtsov
  • 6,285
  • 3
  • 29
  • 36
Valy Dia
  • 2,781
  • 2
  • 12
  • 32
  • I see, I though it was required, but I couldn't find a online resource to confirm it! I'll update the answer accordingly! Thanks – Valy Dia May 27 '19 at 18:59