[Haskell-cafe] Refactoring status

C.M.Brown cmb21 at kent.ac.uk
Thu Jan 3 15:12:52 EST 2008


> Currently, I'm trying to learn arrows and Yampa (mainly to see how well it
> compares to my own dataflow/reactive stuff that was written in C#, C++ and
> assembler)

Arrows won't work with HaRe at the moment, therefore Yampa won't either;
which is a shame.

> First of all, let's see if I get the concept of a "syntax directed editor"
> right. The idea is, that I (or my company), has a specific indentation rule,
> naming convention rule, etc... When I get code from someone else (in a
> syntax tree form ala XML), it will immediately show the text using my
> conventions.

Yep, this was what I was thinking to some extent.

Furthermore, when I need to perform refactoring, a rename is
> just *one* change to the entire system, no matter how many other files use
> the name; no more merging for stupid renames.

I'm a little confused as to what you mean here. A renaming renames all
(and only those) uses of an identifier within a particular definition, and
not every use of a particular name. The binding structure of the program
must not be affected; and there must be no introduction of ambiguity in
the namespace. You can do this with HaRe, but HaRe currently refactors
Programatica data types. If you can
somehow convert your AST into what HaRe expects then the refactoring will
work, but you will need to tweak our pretty printer (and turn off layout
preservation).

When diffing, whitespace,
> indentation, etc does not matter; the structure of the files is compared
> instead.

There is also (preliminary at the moment) duplicate code detection built
into HaRe. This is based on the principle of looking at the shape of functions and
expressions, concentrating on where variables are bound and whether one
term is an intance of another. Duplicate expressions can be converted into
a more general abstraction, transforming the duplicate expressions into
function calls (parameterised by their differences).

Cheers,
Chris.


More information about the Haskell-Cafe mailing list