Working through chapter 7.3 of Programming in Haskell.