Fs2 Stream.Compiler is not found (could not find implicit value Compiler[[x]F[x],G])

為{幸葍}努か 提交于 2020-02-24 03:56:47

问题


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
                     ^


回答1:


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



来源:https://stackoverflow.com/questions/56329032/fs2-stream-compiler-is-not-found-could-not-find-implicit-value-compilerxfx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!