exercise 1.4 in haskell