我正在尝试编译流,但不知何故Compiler不在范围内,将其置于范围内需要什么上下文限制?
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
^
Run Code Online (Sandbox Code Playgroud)
Fs2 Stream#compile现在需要一个Sync[F](请参阅此):
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
}
Run Code Online (Sandbox Code Playgroud)
这是由库维护者传达的:
fs2 Stream#compile现在需要Sync [F]。即使在完全纯净的溪流上。由于资源管理。伤心。熊猫。
丹尼尔·斯皮瓦克(Daniel Spiewak)
| 归档时间: |
|
| 查看次数: |
142 次 |
| 最近记录: |