找不到 Fs2 Stream.Compiler(找不到隐含值 Compiler[[x]F[x],G]) [英] Fs2 Stream.Compiler is not found (could not find implicit value Compiler[[x]F[x],G])

查看:45
本文介绍了找不到 Fs2 Stream.Compiler(找不到隐含值 Compiler[[x]F[x],G])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译流,但不知何故 Compiler 不在范围内,需要什么上下文绑定才能将其纳入范围?

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
                     ^

推荐答案

Fs2 Stream#compile 现在需要 Sync[F](请参阅 这个):

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 现在需要 Sync[F].即使在完全纯净的流上.因为资源管理.伤心.熊猫.

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

丹尼尔·斯皮瓦克

这篇关于找不到 Fs2 Stream.Compiler(找不到隐含值 Compiler[[x]F[x],G])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆