Only possible to work on IO as it allows us to exit the monad
Append to an appendable, always returns Done for a line, cont for everything else TODO - should it be a pair including the appendable?
drop while iteratee, returning the possibly remaining data
Same as dropWhile but captures the Monad in F
Takes Input[E] converts via toMany to an EphemeralStream[A].
Takes Input[E] converts via toMany to an EphemeralStream[A]. This in turn is fed to the destination iteratee. The inputs can be 1 -> Many, Many -> 1, or indeed 1 -> 1.
The callers must take care of what kind of continnuation Iteratee is returned in a Done.
If the dest returns EOF, the toMany is in turn called with EOF for any needed resource control processing.
Calls the function param with the fed data and returns its result - consider Scalaz 7 map directly rather than composing
Extract the Some(value) from a Done or None if it was not Done.
Extract the continuation from a Done
Extract the continuation from a Done, or the continuation itself
Extract the continuation from a Done
Extract the Some(value) from a Done or None if it was not Done.
filter iteratee, greedily taking all content until eof
"find" iteratee, finds Some(first) or None
Based on Scalaz 7 flatMap but exposes the monad through the f parameter
Stepwise fold, each element is evaluated but each one is returned as a result+resumable iter.
Stepwise fold but the result of f is bound to F
Folds over the Iteratee with Cont or Done and Empty, returning with Done and EOF.
Folds over the Iteratee with Cont or Done and Empty, returning with Done and EOF. If there is a ping pong on enumerator -> Cont -> enumerator then we'll of course get an infinite loop.
foldI returns a ResumableIter that performs a fold until a done, this folds over the enumerator to return a value.
combine with onDone to get through chunks of data.
Enumeratee that folds over the Iteratee with Cont or Done and Empty, returning with Done and EOF.
Enumeratee that folds over the Iteratee with Cont or Done and Empty, returning with Done and EOF.
Converts ResumableIters on Done via a fold, returning Done only when receiving EOF from the initIter.
NB - This can be thought of the reverse of toResumableIter but also accumulating.
Helper to identify dones
Helper for done and eof
Helper for done and eof
Helper for done and empty
Helper for done and empty
is this iteratee actually "empty"
Taken from huynhjl's answer on StackOverflow, just abstracting the type to allow for better implicit inference
Taken from huynhjl's answer on StackOverflow, just abstracting the type to allow for better implicit inference
def iteratorEnumerator[E](iter: Iterator[E]) = new EnumeratorT[E, Trampoline] { override def apply[A]: StepT[E, Trampoline, A] => IterateeT[E, Trampoline, A] = { case step if iter.isEmpty => iterateeT[E, Trampoline, A](Free.point(step)) case step @ Done(acc, input) => iterateeT[E, Trampoline, A](Free.point(step)) case step @ Cont(k) => val x : E = iter.next
k(Element(x)) >>== { s => s.mapContOr(_ => sys.error("diverging iteratee"), apply(s)) } } }
Maps a given input to a function returning a Input[EphemeralStream].
Maps a given input to a function returning a Input[EphemeralStream]. If the Input is El it returns it, if EOF empty and continues on empty.
onDone, iterates over the list of iteratees applying the element, when the resulting list contains a Done then the list of Dones is returned.
onDone, iterates over the list of iteratees applying the element, when the resulting list contains a Done then the list of Dones is returned.
One can use tuples or pattern matching to discern which of the original lists iteratees have matched.
Due to the return type of this iteratee all items in the list must return the same type and must return both an A and an IterV with the same interface to continue with the next and maintain state.
In the case of EOF, an empty list is returned
Repeating fold on done, calling f with the result to accumulate with side effects, stopping when stopOn is true and returns the accumulated value continuation iteratee pair.
Repeating fold on done, calling f with the result to accumulate with side effects, stopping when stopOn is true and returns the accumulated value continuation iteratee pair.
marks a continuation resumableiter as actually being EOF - i.e.
marks a continuation resumableiter as actually being EOF - i.e. don't attempt to evaluate it
keeps a running count of each element, probably not of much use unless combined but acts as a good poc for ResumableIter
Sums an iteratee up, consider using the Scalaz IterateeT monadic sum instead
Converts a normal IterV[E,A] to a ResumableIter.
Converts a normal IterV[E,A] to a ResumableIter.
Does so by folding over the iter once for an input and when its Done starting again with the original iter. This is close to restarting the iter on a new "stream", otherwise all attempts to keep the Cont will be made.
Converts the iteratee/enumerator/source triple into a Iterator.
Converts the iteratee/enumerator/source triple into a Iterator. This is only possible in IO given the ability to exit the monad _and_ trampoline.
For most uses iterate is a better option
Enumeratee that converts input 1:1 String => Int, enumerator Iterator[String] but IterV[Int, Int]
Enumeratee that converts input 1:1 String => Int, enumerator Iterator[String] but IterV[Int, Int]
Collection of iterateees