我有IO[Throwable, Seq[IO[Nothing, String]]],我想把它变成IO[Throwable, Seq[String]]。知道怎么回事吗?我尝试使用flatten,但我得到了奇怪的隐式丢失错误。
No implicits found for parameter asTraversable: IO[Nothing, Step] => GenTraversableOnce[B_]谢谢!
发布于 2018-12-22 18:10:54
我找到了解决方案:
val data1: IO[Throwable, Seq[IO[Nothing, String]]]
val data2: IO[Throwable, IO[Nothing, Seq[String]]] = data1.map(IO.sequence)
val data3: IO[Throwable, Seq[String]] = data2.flatten只需一步即可完成:
data1.flatMap(IO.sequence)https://stackoverflow.com/questions/53894367
复制相似问题