
* Jan-Willem Maessen
It seems to be a common misconception that eta-abstracting your functions in this way will speed up or otherwise improve your code.
Simon PJ has already provided a good explanation of why GHC eta expands. Let me take another tack and describe why the code you wrote without eta expansion probably doesn't provide you with any actual benefit. Roughly speaking, you're creating a chain of closures whose contents exactly describe the contents of your list (ie you've created something that's isomorphic to your original list structure), and so you should expect no benefit at all.
Thanks for the analysis. I used myFoldl as a minimal example to ask the question. Here's an example of real code where this does make a difference: https://github.com/feuerbach/regex-applicative/tree/03ca9c852f06bf9a9d515056... You can run the benchmark (on a POSIX system) using cd benchmark && ./runbenchmark.sh With the current version I get 2.62 seconds. If I remove -fno-do-lambda-eta-expansion for Text/Regex/Applicative/Compile.hs, the benchmark takes 2.74 seconds. What's even more interesting (and puzzling!), if remove -fno-do-lambda-eta-expansion for Text/Regex/Applicative/Types.hs, the benchmark takes 2.82 seconds. I appreciate any thoughts about this. -- Roman I. Cheplyaka :: http://ro-che.info/