Problem 31: Add Haskell solution