Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Haskell's laziness can also be a notorious source of "space leaks": an algorithm that appears O(1) in space, such as summing up a list of numbers, can actually use O(n) space by accumulating unevaluated invocations of (+) in memory. With more complex data structures, the proportion of expected memory usage to actual memory usage can get even worse.

In larger Haskell programs, I've found that the most challenging issue to debug: "why does my program use way too much memory?".



Practically, the way to go here is: make your data structures strict (with "!") and make your control structures lazy.

So, don't create a list of numbers if you intend to sum it, use a non- lazy data structure.

The trick is that Haskell's common default structures are lazy.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: