Because I can see it coming: this is a different question than What optimizations can GHC be expected to perform reliably? because I'm not asking for the most reliable optimizations, just the most clever/powerful.
I'm specifically looking for non-intuitive optimizations that GHC makes that can have serious impacts on performance and demonstrate the power of compiler optimizations related to lazy evaluation or purity. And direct explanations about how to get at them.
The best answers will have:
Stream fusion is probably the biggest one. It turns something like sum . map (+1) . filter (>5)
, which nominally allocates two new lists, into a simple loop that operates in constant space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With