If I have an EnumeratorT and a corresponding IterateeT I can run them together:

val en: EnumeratorT[String, Task] = EnumeratorT.enumList(List("a", "b", "c"))
val it: IterateeT[String, Task, Int] = IterateeT.length

(it &= en).run : Task[Int]

If the enumerator monad is "bigger" than the iteratee monad, I can use up or, more generally, Hoist to "lift" the iteratee to match:

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]

But what do I do when the iteratee monad is "bigger" than the enumerator monad?

val en: EnumeratorT[String, Id] = ...
val it: IterateeT[String, Task, Int] = ...

it &= ???

There doesn't seem to be a Hoist instance for EnumeratorT, nor any obvious "lift" method.

This question has an open bounty worth +50 reputation from Ronnie Oosting ending in 15 hours.

One or more of the answers is exemplary and worthy of an additional bounty.

  • 24
    +1 for a neat question, but off the top I'm not sure of my head that this is possible in the general case, since an Enumerator is really just a wrapper around a StepT => IterateeT, which suggests that you'll need to "step down" from a StepT[E, BigMonad, A]. – Travis Brown Nov 13 '14 at 21:06
  • 3
    Yeah, I found that when I tried to implement it directly. But logically an Enumerator is just an effectful source, right? It feels like I should be able to use a thing that can supply A to supply Task[A]. – lmm Nov 13 '14 at 23:38

protected by Suraj Rao Feb 3 at 10:22

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Browse other questions tagged or ask your own question.