3 ms·
Help My Haskell program consumes more memory the longer it runs
- zetalyrae 3y ago>Strict data and lazy functions is the default you should be using for all production Haskell code. This, for the most part, gives you the best of both worlds. How does this interact with the rest of the ecosystem? Sprinkling `!` everywhere seems like the kind of thing that could be prevented by having a build system-wide option. But then, some libraries might make the assumption that they have strict data, leading to other performance problems elsewhere.
- unhammer 3y agoAs the post says, there is compiler option, StrictData. You can turn it on per file/module or for the whole project. Unless you know what you're doing (or are doing homework problems in algorithms and data structures), you probably want it on. It interacts just fine – the extension (like !'s) just governs the constructors defined in the modules where you've turned it on. AFAIK there's no Haskell extension which can change the strictness of imported constructors. E.g. basic lists are lazy, so in your (StrictData) module with `data StrictInt = MkStrictInt Int` you can make a lazy value `x = (MkStrictInt 1) : x` of type `[StrictInt]` which uses strict constructors inside it (lazy spine, strict leaves).
- byjmor6 3y agoLazy evaluation, despite its occasional usefulness, has been a strong *net loss* for me. I'm a very experienced Haskell dev and have a solid understanding of its evaluation. Still, the practical difficulty of lazy eval in complex, iterative/recursive code that calls into many deeply nested 3rd party libraries, is horrible. Some apps can live with this, mine can't.