Notes on FP in scala Chapter 4.