4 ms·
>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.
by zetalyrae 4y 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 4y 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).