did #5 in haskell