Yves Pare`s  wrote:

> I cannot help smiling when I hear Java/C#/Python developers telling about
> the "wondeful features" of their languages ;)
> (- We have generators! We can _yield_ values! [1]
>  - Yeah, so nice... We have simple lists... with lazy evaluation)

Just for the record, lazy lists per se are sufficient only for
simplest generators. Re-writing an accumulating traversal to
accommodate suspension by hand is too ungainly and error prone. Still,
if we just add exceptions (the Either monad), we can idiomatically
write all the generator examples of Python or Icon, for example. If we
do not need effects other than yielding or non-determinism, [Either e a],
which is ErrorT e [] a, suffices. If we need IO or mutable state,
we should replace [] with LogicT (which is the monad of lazy lists
with effect).

The following web page talks about lazy lists and generators 
        http://okmij.org/ftp/continuations/generators.html
in (perhaps too) great detail.



_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to