Iteratees
Iteratee is defined as a trait, Iteratee[E, +A]
, where E is the input type and A is the result type. The state of an Iteratee is represented by an instance of Step
, which is defined as follows:
sealed trait Step[E, +A] { def it: Iteratee[E, A] = this match { case Step.Done(a, e) => Done(a, e) case Step.Cont(k) => Cont(k) case Step.Error(msg, e) => Error(msg, e) } } object Step { //done state of an iteratee case class Done[+A, E](a: A, remaining: Input[E]) extends Step[E, A] //continuing state of an iteratee. case class Cont[E, +A](k: Input[E] => Iteratee[E, A]) extends Step[E, A] //error state of an iteratee case class Error[E](msg: String, input: Input[E]) extends Step[E, Nothing] }
The input used here represents an element of the data stream, which can be empty, an element, or an end of file indicator. Therefore, Input
is defined as follows:
sealed trait Input[+E] { def map[U](f: (E => U)): Input[U] = this match { case Input...