[Haskell-cafe] Where does η-equivalence stop?

Richard Eisenberg lists at richarde.dev
Thu Jun 30 03:50:54 UTC 2022

No, you're right. My comment about "lazy" was more relevant to a second example that I removed (because it sneakily relied on `seq` and is thus redundant with other mention of `seq`). Thanks for correcting.


> On Jun 29, 2022, at 3:02 AM, Tom Ellis <tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> wrote:
> 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.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

More information about the Haskell-Cafe mailing list