Haskell refactoring