problem 6 in haskell