
On Tue, May 13, 2008 at 2:20 AM, Don Stewart
Note the use of strict pairs. Key to ensuring the accumulators end up in registers. The performance difference here is due to fold (and all left folds) not fusing in normal build/foldr fusion.
The vector version runs about the same speed as unoptimsed C.
These "tricks" going into Real World Haskell? When you say someone needs to get familiar with the "STG paper" it scares me (a beginner) off a little, an I've been making an effort to approach the papers. I could barely understand the Fusion one and getting familiar with compiler internals sounds like something I'd not be ready for. Probably if I really looked at ghc-core I'd be pleasantly surprised but I'm totally biased against even looking. Gcc is hard to read, thus ghc is also. So while you are right about all this when you say it, I think your goal is to persuade. RWH has some of the best practical prose I've read yet. Well done there. Hopefully chapter 26 will be crammed full of this stuff? -- Darrin