problem6 in haskell