ANNOUNCE: HaRe, the Haskell Refactorer 0.6

Dear Haskellers, As part of our project on Refactoring Functional Programs http://www.cs.kent.ac.uk/projects/refactor-fp/ we are pleased to announce the availability of HaRe 0.6 (also known as HaRe 28/06/2010), a snapshot of our Haskell Refactorer prototype. Apart from bug-fixes, there are major changes since HaRe 0.5 and HaRe 0.4: A number of new refactorings have been added to HaRe. Some of these include: Adding and removing fields and constructors to data-type definitions, folding and unfolding against as-patterns, merging and splitting, converting between let and where constructs, introduce pattern matching, generative folding, and a clone detection and elimination tool. We have evolved the ongoing architecture of HaRe and derived an API (documented using Haddock) for program analysis and transformation. This allows HaRe to serve as a framework for end-users to build their own refactorings or just program transformations (or analyses). HaRe is available to download directly from here: http://www.cs.kent.ac.uk/projects/refactor-fp/hare/HaRe_28062010.tar.gz You can get HaRe 0.6 and the documentation about how to build your own refactorings via: http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html Please see the README.txt for build/use instructions and known issues, and let us know about any problems, bugs, suggestions or additional platforms you can confirm as working. You will need: 1. ghc-6.12.1 2. hint-0.3.2.3 (available from cabal) 3. unix/gnu tools (or cygwin tools, if on windows) 4. vim or emacs (we've tested with gvim 6.2 and with emacs 21.4) 5. If you intend on running the test suite, HUnit-1.0. Happy Refactoring! The HaRe Team (Chris Brown, Huiqing Li, Simon Thompson) Project email: refactor-fp at kent.ac.ukhttp://www.haskell.org/mailman/listinfo/haskell Background: Refactoring is the process of changing the structure of programs without changing their functionality, i.e., refactorings are meaning-preserving program transformations that implement design changes. For more details about refactoring, about our project and for background on HaRe, see our project pages. HaRe - the Haskell Refactorer: HaRe is our prototype tool supporting a collection of refactorings for Haskell 98 (see README.txt for known issues and limitations). It is implemented as a separate refactoring engine (on top of Programatica's Haskell frontend and Strafunski's generic traversal strategy library), with small scripting frontends that call this engine from either Vim or Emacs. Currently supported refactorings: Introduce Pattern Match : place cursor over pattern variable Introduce Sub pattern : place cursor over pattern variable Introduce Case Expression : place cursor over pattern variable Generative Fold : highlight expression to fold. Must have equation in comment directly before definition of highlighted expression. Clone Analysis : select from menu Clone Extraction : highlight clone from the clone class to extract, follow step-by-step instructions. Converting Let to Where : place cursor at start of identifier whose definition is to be moved Converting Where to Let : place cursor at start of identifier whose definition is to be moved. create type signatures : select from menu remove redundant declarations : highlight definition to clean up add constructor to data type : place cursor at start of data type, you'll be prompted to add the new Constructor name, followed by any Type parameters as a complete string Split a tuple : place cursor at start of top level definition that returns a tuple. Slicing based on a subexpression : highlight sub-expression to extract. Instantiate a general pattern : select a function equation and enter the new instances for each pattern in the argument set. Extract an expression : highlight an expression within a definition Convert data type to newtype : place cursor at start of data type add definition to merge : place cursor at start of definition that is to be merged merge definitions : use "add definition for merge" for each definition to be merged. then choose merge definitions from menu. fold function definition : highlight function equation to fold against. fold constant definition : highlight constant equation to fold against. convert pattern to an as pattern : highlight pattern to convert. unfold references to as patterns : place cursor over as pattern name. remove field from a data type : place cursor at start of field to remove. add field to data type : place cursor over start of constructor. enter new field name. add debug information : add trace calls to function by placing cursor at the start of the function to trace rename : place cursor at start of identifier to be renamed, you'll be prompted for a new name Lift def to top level : place cursor at start of identifier whose definition is to be moved Lift def one level : place cursor at start of identifier whose definition is to be moved Demote : place cursor at start of identifier whose definition is to be moved Introduce new def : highlight expression to be named, you'll be prompted for a new name Unfold def : place cursor at start of identifier where its definition is to be unfolded Generalise def : place cursor at start of identifier where its definition is to be unfolded Remove def : place cursor at start of identifier whose definition is to be removed Duplicate def : place cursor at start of identifier whose definition is to be duplicated, you'll be prompted for a new name Add one parameter : place cursor at start of identifier whose definition is to be modified, you'll be prompted for a new name rm one parameter : place cursor in formal parameter which is to be removed Move def to another module : place cursor at start of the identifier whose definition is to be moved, you'll be prompted for the module name Clean imports : cursor position does not matter, just choose the command from the refactor menu Make import explicit : place cursor at the start of the module name in the import declaration Add to export : place cursor at start of the identifier which is to be added to the export Remove from export : place cursor at start of the entry to be removed in the export list From concrete to abstract data type: place cursor at start of the data type name Add field names : place cursor at start of the data type name Add discriminators : place cursor at start of the data type name Add constructors : place cursor at start of the data type name Eliminate nested patterns : place cursor at start of the data type name Eliminate patterns : place cursor at start of the data type name Create an ADT module : place cursor at start of the data type name Eliminate intermediate list: cursor position does not matter, just choose the command from the menu. Caveats (see also README.txt): Please keep in mind that this is a prototype, so we do not recommend to use it on your productions sources just yet. Just play with it to get an idea of tool-supported refactoring in Haskell, and send us your feedback and bug-reports. Our goal is to develop this into a tool that many of you will find indispensable for Haskell development. Regards, The HaRe team.

Hello Chris, Chris Brown wrote:
we are pleased to announce the availability of HaRe 0.6
Great, I want to try it! While skimming the installation instructions I wondered why I couldn't just do cabal install HaRe Are there any problems with putting HaRe on Hackage? I will probably install HaRe anyway but I guess it would be easier if I could just use cabal-install. Thanks! Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.)

Sebastian Fischer
Hello Chris,
Chris Brown wrote:
we are pleased to announce the availability of HaRe 0.6
Great, I want to try it!
While skimming the installation instructions I wondered why I couldn't just do
cabal install HaRe
Are there any problems with putting HaRe on Hackage?
Just because they haven't is my guess. I've tried playing with an older version of HaRe; it's build system is a little weird but I'm sure it can be converted into a Cabal-compatible format. Part of the problem if memory serves is the use of embedded libraries that aren't on Hackage either. The other possible problem is the license; I'm not sure what license HaRe is under.
I will probably install HaRe anyway but I guess it would be easier if I could just use cabal-install.
Of course, it would also be nice if HaRe could parse more than just Haskell98... :p (I know, I know, it isn't easy to change parsers, etc.).
Thanks! Sebastian
-- Underestimating the novelty of the future is a time-honored tradition. (D.G.)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Hi Ivan,
I've tried playing with an older version of HaRe; it's build system is a little weird but I'm sure it can be converted into a Cabal-compatible format. Part of the problem if memory serves is the use of embedded libraries that aren't on Hackage either.
That's correct. HaRe builds on top of Strafunski and (a slightly modified) Programatica. It may be possible to wrap these up into a utils package for HaRe.
Of course, it would also be nice if HaRe could parse more than just Haskell98... :p (I know, I know, it isn't easy to change parsers, etc.).
HaRe works over the full Haskell 98 standard. We certainly wish to move HaRe over to GHC Haskell in the future, and this is currently an ongoing effort: if you have any ideas on how to help us do this please contact us. Kindest regards, Chris

Chris BROWN
Of course, it would also be nice if HaRe could parse more than just Haskell98... :p (I know, I know, it isn't easy to change parsers,
etc.).
HaRe works over the full Haskell 98 standard. We certainly wish to move HaRe over to GHC Haskell in the future, and this is currently an ongoing effort: if you have any ideas on how to help us do this please contact us.
I talked with you and Simon Thompson about this at PEPM, and at the time you said that haskell-src-exts didn't have what you needed for HaRe. What exactly do you need in a parser for it to be suitable for HaRe? -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On 29 Jun 2010, at 15:55, Ivan Lazar Miljenovic wrote:
Chris BROWN
writes: Of course, it would also be nice if HaRe could parse more than just Haskell98... :p (I know, I know, it isn't easy to change parsers,
etc.).
HaRe works over the full Haskell 98 standard. We certainly wish to move HaRe over to GHC Haskell in the future, and this is currently an ongoing effort: if you have any ideas on how to help us do this please contact us.
I talked with you and Simon Thompson about this at PEPM, and at the time you said that haskell-src-exts didn't have what you needed for HaRe. What exactly do you need in a parser for it to be suitable for HaRe?
We need static semantics, including location information and a preservation of comments. Chris.

Chris BROWN
On 29 Jun 2010, at 15:55, Ivan Lazar Miljenovic wrote:
I talked with you and Simon Thompson about this at PEPM, and at the time you said that haskell-src-exts didn't have what you needed for HaRe. What exactly do you need in a parser for it to be suitable for HaRe?
We need static semantics, including location information and a preservation of comments.
The Annotated part of haskell-src-exts provides this I think: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.9.0/doc/html/... -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

The Annotated part of haskell-src-exts provides this I think: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.9.0/doc/html/...
Thanks, Ivan, I'll take a look at this. I wonder if would be possible to write a mapping for haskell-exts-annotated data types -> programmatica data types. At the very least, HaRe would then be able to parse non Haskell 98. The problem, however, would be the generated refactored file: we currently use a combination of the transformed token stream and AST to build a refactored file. There may have to be some sort of mapping back to haskell-exts-annoted data type first, before generation begins. Regards, Chris.

On Jun 30, 2010, at 12:51 AM, Ivan Lazar Miljenovic wrote:
Chris BROWN
writes: On 29 Jun 2010, at 15:55, Ivan Lazar Miljenovic wrote:
I talked with you and Simon Thompson about this at PEPM, and at the time you said that haskell-src-exts didn't have what you needed for HaRe. What exactly do you need in a parser for it to be suitable for HaRe?
We need static semantics, including location information and a preservation of comments.
Doesn't that mean that hare requires also type information? Even though haskell-src-exts is impressive, I doubt it comes with a typechecker for GHC Haskell.
The Annotated part of haskell-src-exts provides this I think: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.9.0/doc/html/...

Doesn't that mean that hare requires also type information? Even though haskell-src-exts is impressive, I doubt it comes with a typechecker for GHC Haskell.
HaRe does require a type checker, but we use hint for that, not Programmatica. So haskell-src-exts shouldn't interfere... but it would be nice to move over to a fully type-decorated AST, if possible. Chris.

Hi Sebastian,
Great, I want to try it!
Thanks for you interest!
While skimming the installation instructions I wondered why I couldn't just do
cabal install HaRe
Are there any problems with putting HaRe on Hackage?
I've looked at this before and I must say it's certainly not trivial to do this. In the build of HaRe, we build a (modified) version of Programatica as a dependency to the refactoring engine. We also need to have vim and emacs scripts available to the user after the install. One approach would be to separate out the Programatica part of HaRe into a hare-utils package, and then build hare on top of that dependency. If you have any advice or experience with using cabal or any tips on getting HaRe cabalised we'd love to hear from you. Kindest regards, Chris.

Chris Brown wrote:
Are there any problems with putting HaRe on Hackage?
I've looked at this before and I must say it's certainly not trivial to do this. [...] We also need to have vim and emacs scripts available to the user after the install.
The ghc-mod package [1] provides emacs scripts under ~/.cabal/share/. If you can solve the other issues, this would be a sensible option for HaRe too. Cheers, Sebastian [1]: http://www.mew.org/~kazu/proj/ghc-mod/en/ -- Underestimating the novelty of the future is a time-honored tradition. (D.G.)
participants (4)
-
Chris BROWN
-
Ivan Lazar Miljenovic
-
José Iborra
-
Sebastian Fischer