
Robin Green wrote:
In my opinion, in Haskell, you don't need coroutines because you have lazy evaluation.
You example below is simply an example of a heterogenous list being read. The simplest way to implement a heterogenous list in Haskell is to use a tuple. Or you could use the HList package.
Not quite. The consumer, useSimple, is an example of a heterogenous list being read. The producer, simple, is an example of producing a heterogenous list, value by value, on demand. You don't get that from HList for free. The difference between coroutines and lazy evaluation is that in the latter the consumer has full control. Producer supplies all the thunks, consumer picks which thunk to evaluate. Of course the producer could return a pair of first value and the rest of the computation, but then any control structure can be encoded using continuations. The question is one of notational convenience.