1
foo x y = x*x + y

fat x y = let xx = x*x in xx + y

bar x = \y -> x*x + y

baz x = let xx = x*x in \y -> xx + y

foo' = foo 2

fat' = fat 2

bar' = bar 2

baz' = baz 2

Will repeated calling of foo', fat', bar', or baz' result in different runtime performances? Basically, I am interested in how GHC will keep values around and when it relinquishes intermediate values. Would using a where clause result in different results if I replaced let with it?

Thomas Eding
  • 33,388
  • 12
  • 68
  • 104

0 Answers0