
It seems to me the same difference would hold in a strict language too. Am I missing something? (A difference between strict and lazy here would be that in a lazy language `slowFunction 1000` would not be computed at all if the list is empty.) Tom On Tue, Jun 28, 2022 at 06:57:14PM +0000, Richard Eisenberg wrote:
My best understanding is that eta-equivalence holds only in total languages, and even there without regard to performance. So you can hunt for eta-equivalence trouble anywhere that non-totality or performance comes into play.
For example, compare (A) `f (slowFunction 1000)` and (B) `\x -> f (slowFunction 1000) x`. If we map (A) over a list, then `slowFunction 1000` is computed once. If we map (B) over a list, then `slowFunction 1000` is computed for each element of the list.
Note that this example is very bare-bones: no extensions, no parametricity-busting `seq`, no compiler flags. All it relies on is a non-strict functional language.