[plt-dev] I love Haskell (not an April Fools Joke!), feature request for 'for'

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Apr 5 15:39:57 EDT 2009

On Apr  5, Matthias Felleisen wrote:
> 
> 1. Is this going into the code base?

Already did, I'll send a message shortly.


> 2. Why is for on lazy things not practical?

There are two kinds of laziness that you can talk about:

* Iterating over a lazy sequence like an infinite list.

    (for ([x (in-lazy-list (letrec ([l (lazy-append '(1 2 3) l)])
                             l))])
      ...)

* Having the sequence value itself be lazy.

    (for ([x (letrec ([seq (lazy-sequence-append (in-list '(1 2 3))
                                                 seq)])
               seq)])
      ...)

The first kind seems to me useful, and would be easy to implement.
The second is harder (it requires changing the `for' implementation
for the reason I said earlier), and I don't see much practical use of
that.

(A `for' in a lazy language, should be lazy in both ways, of course.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the dev mailing list.