Solve #50 in Haskell.