Adding problem 2 solution in Haskell