Why are strings linked lists?

Tomasz Zielonka t.zielonka at students.mimuw.edu.pl
Mon Dec 8 17:15:15 EST 2003


On Mon, Dec 08, 2003 at 02:24:51PM -0000, Simon Marlow wrote:
> 
> Just compiling the code (instead of running it in GHCi) is enough to
> prevent CAFs from leaking.

Ah, I see the story is a bit different that I thought.

Please correct me I am wrong:

When I compiled the code with -O2 there was no leak because t was
optimised into a tight loop with no allocs. In other words: the CAF was
not garbage-collected, but there was not much to collect.

We see two things interacting here:
 
 1. GHCi not reclaiming CAFs

 2. Deforestation (and probably some other optimisations)

This interaction made me believe that CAF leaks were eliminated by some
optimisation turned on by -O2.

But then... what trick does GHC use to prevent CAF leaks?

Best regards,
Tomek

-- 
.signature: Too many levels of symbolic links


More information about the Haskell mailing list