Solve #38 in Haskell.