How can I get at the cleverest optimizations that GHC makes?
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)
sum . map (+1) . filter (>5)
sum . map (+1) . filter (>5)
, which nominally allocates two new lists, into a simple loop that operates in constant space.
上一篇: GHC优化
下一篇: 我怎样才能得到GHC最聪明的优化?