How does the GHC garbage collector / runtime know that it can create an array `inplace'
问题 For example main = do let ls = [0..10000000] print ls This will create the array 'inplace', using O(1) memory. The following edit causes the program to run out of memory while executing. main = do let ls = [0..10000000] print ls print ls ls in this case must be kept in memory to be printed again. It would actually be heaps more memory efficient to recalculate the array again 'inplace' than to try to keep this in place. That's an aside though. My real question is "how and when does GHC