Solve 2 in Haskell