monad binding and garbage collection

Lars Lundgren lars@prover.com
Thu, 17 Jan 2002 10:40:48 +0100 (CET)


On Thu, 17 Jan 2002, Christian Schuhegger wrote:

> buildIOList :: [a] -> IO [a]
> buildIOList li = return li
> 
> main = do {li <- buildIOList [1..];
>            putStr (show (take 100000000 li));
>           }

I take it you know that
    
    do li <- buildIOList [1..]
       ...

is equal to 

    do let li = [1..] 
       ...

There is no need to to lift a value to the IO monad, if all you are
going to do is immediatelly extract it.

Mvh
/Lars L