from Beginning Haskell book