Questions tagged «iterate»

1
Scalaz迭代:“提升” EnumeratorT以匹配“ IterateeT”以获得“更大”的单子
如果有EnumeratorT和,IterateeT我可以一起运行它们: val en: EnumeratorT[String, Task] = EnumeratorT.enumList(List("a", "b", "c")) val it: IterateeT[String, Task, Int] = IterateeT.length (it &= en).run : Task[Int] 如果枚举数monad比iteratee monad“更大”,我可以使用up或更广泛地说,Hoist“提升” iterae以匹配: val en: EnumeratorT[String, Task] = ... val it: IterateeT[String, Id, Int] = ... val liftedIt = IterateeT.IterateeTMonadTrans[String].hoist( implicitly[Task |>=| Id]).apply(it) (liftedIt &= en).run: Task[Int] 但是,当iteratee monad比枚举器monad“更大”时,我该怎么办? …

1
使用Scalaz 7 zipWithIndex / group枚举避免内存泄漏
背景 如该问题所述,我正在使用Scalaz 7迭代器在恒定堆空间中处理大量(即无边界)数据流。 我的代码如下所示: type ErrorOrT[M[+_], A] = EitherT[M, Throwable, A] type ErrorOr[A] = ErrorOrT[IO, A] def processChunk(c: Chunk, idx: Long): Result def process(data: EnumeratorT[Chunk, ErrorOr]): IterateeT[Vector[(Chunk, Long)], ErrorOr, Vector[Result]] = Iteratee.fold[Vector[(Chunk, Long)], ErrorOr, Vector[Result]](Nil) { (rs, vs) => rs ++ vs map { case (c, i) => processChunk(c, i) …
106 scala  scalaz  iterate 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.