Exercise 6.10: Reimplement map and map2 in terms of flatMap.