Go to: Tool Homepage - Downloads - User Guide - Examples
ghc --make Client.hs
1. Open in Emacs an Haskell file.
2. Load the file describing HaRe in Emacs : ESC-x load-file RETURN
and type HAREPATH/editors/Emacs/haskell-refac.el
where HAREPATH
is the directory containing the refactorer source code (for instance, /local/HaRe_28062010
). Note that this can be done automatically at Emacs startup by editing your Emacs config file.
3. Activate the HaRe mode in emacs : ESC-x haskell-refac-mode RETURN
4. Create a “HaRe project” containing the files of your program. First click in Refactor>Projects>New Project. Then add the other files in the project, by one of the two following methods.
You need also to call Refactor>Project>Chase imports to include the Haskell library files in the project.
5. You may need to set an Emacs variable for the chase imports operation (see HaRe README). You can use the refactorer. Most operation need that you select a sub-expression or place the cursor at the beginning of an identifier before you call the operation from the Refactorer menu.
6. For some operations, we provide an additional interface (menu Name-based operations) that do not need you to select a region of the file, but prompt you for the names of the function you want to refactor. This interface is the one that is used to build restructuring transformations.
A structure transformation is a sequence of refactoring operations. Instead of using the Emacs menu to interactively run the sequence of operations, we record the sequence of refactoring operations into an emacs-lisp file.
The following gives instruction to run an example of restructuring transformation with our system.
1. Download the archive with the sources of the example from download and extract it. This archive contains an example of Haskell program and the transformation scripts.
2. Run Emacs and open the extracted Haskell files.
3. Create an HaRe project (see instructions in the previous section) containing the 6 files of the program (two of these files are not imported by other modules and cannot be “chased”, they have to be added by the Refactor>Projects>Add file menu). This is done only once for each program.
4. Open the emacs-lisp file transformation_pfun_pdata in emacs. This file contains the sequence of operations defining the transformation of the inital program (operation-centered) and a data-centered version of it.
5. While the buffer with the emacs-lisp program is the active buffer, type ESC-x evaluate-buffer
. If you have sub-windows showing the Haskell program, you should see the sequence of recatorings beeing performed and, after a while, you get the program in the data-centered architecture.
6. (OPTIONAL) You may also run the transformation step-by-step by selecting a part of the code in the buffer containing the transformation code, and doing ESC-x evaluate-region
. You can also edit the script file to experiment with the transformation.
See the list of operations available in View Switcher.