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

I’m glad you are enjoying the book! I see what you mean about the <thunk> references. My initial goal was to use a name that made it clear that we don’t know too much about what’s inside of the thunk, merely that it is some arbitrary thunk. I might try both your suggestion of adding clearly names, as well as an aside to explain that we don’t care too much about the details of the thunks, and see which one ends up seeming to be more clear when I try both approaches. I really appreciate the note!

1 Like