worked through chapter 4 of real-world haskell