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
  • 35,312
  • 13
  • 75
  • 106

0 Answers0