
On Sun, 13 May 2007, David Roundy wrote:
I was just contemplating hashes, and it occurred to me that it would be nice to be able to compute the hash of a lazily constructed bytestring and lazily consume its output without requiring the whole string to ever be in memory. Or in general, it'd be nice to be able to perform two simultaneous consumptions of a lazy list without requiring that the entire list be stored.
How about reading the same file twice? do l1 <- readFile "foo" l2 <- readFile "foo" let len = length l1 writeFile "bar" l2 ... Another solution would be loop fusion: do l <- readFile "foo" len <- writeFileAndComputeLength "bar" l ... A compiler might be able to do that for you. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: tom.schrijvers@cs.kuleuven.be