did #3 in haskell