Solution to 7 in Haskell.