Finish #5 in Haskell