[Haskell-cafe] hash of a lazy bytestring?

Henning Thielemann lemming at henning-thielemann.de
Sun May 13 16:55:15 EDT 2007


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.  Another example would be computing the length of an ordinary list:
>
> do l <- readFile "foo"
>    let len = length l
>    writeFile "bar" l
>    putStrLn $ "Length is " ++ show l

An elegant implementation of 'wc' is another example.



More information about the Haskell-Cafe mailing list