did #12 in haskell