如何为BufferedReader创建枚举器?
我发现一篇比较旧的文章:http://apocalisp.wordpress.com/2010/10/17/scalaz-tutorial-enumeration-based-io-with-iteratees/,看起来它在Scalaz 6.0.4上无法使用。
我尝试基于这里的示例创建枚举器:Idiomatic construction to check whether a collection is ordered。
我发现一篇比较旧的文章:http://apocalisp.wordpress.com/2010/10/17/scalaz-tutorial-enumeration-based-io-with-iteratees/,看起来它在Scalaz 6.0.4上无法使用。
我尝试基于这里的示例创建枚举器:Idiomatic construction to check whether a collection is ordered。
implicit val ListEnumerator = new Enumerator[List] {
def apply[E, A](e: List[E], i: IterV[E, A]): IterV[E, A] = e match {
case List() => i
case x :: xs => i.fold(done = (_, _) => i,
cont = k => apply(xs, k(El(x))))
}
}
但我不明白如何将IO Monad与Enumerator结合使用。