Haskell puzzle