Add problem 6 in Haskell