did #14 in haskell