Mon, 4 Mar 2002 20:35:01 -0600 (CST)
On Mon, 4 Mar 2002, Tom Pledger wrote:
> Nguyen Phan Dung writes:
> | mylist :: [Integer]
> | mylist = [1..1000000000]
> | In Hugs, I type mylist to print out all the elements inside. However,
> | after printing about 22000 elements, the system crashs & outputs:
> | "Garbage collection fails to reclaim sufficient memory"
> The declaration of mylist is a pattern binding, not a function binding
> - see section 4.4.3 of the Haskell 98 report.
> What that means in this particular case is that the system saves the
> result in case you want to use it again, rather than freeing the part
> of the list it's already printed.
> Try typing [1..1000000000] at the Hugs prompt instead.
So would wrapping such possibly fiendish entities as [1..] with the
"const" function and replacing all references to the toplevel binding with
"(binding ())" make sure that the first part of the list could be thrown
away and re-computed if needed?
Or does one need to NOINLINE it as well?
Example to make myself clear:
mylist = const [1..1000000000]
main = print (mylist ())
It seems like we had a discussion about something very similar to this a
few months ago on some haskell.org list.