Solve #28 in Haskell.