Complete p004 in haskell