[back to project home page]

HaRe -- The Haskell Refactorer (a refactoring demo)


Here are some screenshots from the example refactoring we used for the demo in Uppsala (using GVim):

The original program and the refactoring menu (detached)


First, let's generalise over the 0 in the nil-case. Highlight the 0, select generaliseDef, and enter n as the name of the new parameter:


That done, we do the same for the (+) in the cons-case:


Now, we better rename our function to reflect its more general definition. Position the cursor on the start of sum, select rename, and enter fold as the new name:


The partial application fold (+) 0 is our old sum function, and we can introduce a definition for that expression. Highlight the expression, select introNewDef, and enter sum as the name for the new definition:


And since that definition might be reusable, we better move it to the top level. Position the cursor on the start of sum, then select liftToTopLevel: