Effective Haskell: B6.0, Chapter 2, p.83: Suggestion: Distinguish thunks by name

Hi, I got a bit sidetracked, but I now have time to continue with your book, which I am enjoying a lot. You explain the co-recursion in chapter 2 really well and I think that showing how the (lazy) evaluation works step-by-step is very helpful and corrected a wrong idea I had about how foldr operates, thanks!

I have just one recommendation regarding naming:

I think that all is very well explained, but some of the readers may get confused that all thunks are named <thunk> when in case of the Fibonacci numbers, in each step one is the tail of the other. So, to use different names for different things, maybe something like <thunk_n> and <thunk_n+1> could be helpful. Maybe it would even be enough to distinguish them “locally” as <thunk0> and <thunk1>.

1 Like