Haskell: Solved problem 4