[Haskell-cafe] Compile time checking of space leaks

Clinton Mead clintonmead at gmail.com
Mon May 17 01:50:14 UTC 2021

I've asked a question on stackoverflow, which is basically a typical
question about folds and space leaks due to laziness, in this case
complicated by a Maybe and foldM:


That's getting answered, but when I saw the answers, I noticed people are
using a fairly mechanical process, basically going through how the code
would be evaluated step by step, to determine whether there's a space leak
or not. And that tends to be the case for most of these questions.

It's complicated enough that it's hard to keep track of in my head, but I
thought to myself, wouldn't a computer be able to check this much more
quickly and reliably?

There doesn't seem to be much human intuition required here, just a lot of
pen and paper work to try to determine whether you've got an unevaluated
thunk hanging around at the end of an iteration.

I understand doing this analysis for the whole program may be impossible,
but we can certainly do it for parts, because flesh and blood human beings
can do it for stackoverflow answers.

Is there anything I can get that helps me identify space leaks like this at
compile time (that is, pre-runtime)? Either from GHC or from another tool?
Or do we just have to rely on squishy humans to do this as compile time and
our only automated tools have to be delayed til runtime?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210517/24902bf0/attachment.html>

More information about the Haskell-Cafe mailing list