refactoring Haskell