2017. május 22., hétfő

0.7 release

The new 0.7 release of Haskell-tools is out! It can be installed from the latest stackage nightly (--resolver=nightly-2017-05-20), or from hackage.

Implemented handling of preprocessor conditional pragmas

The preprocessor directives #if, #ifdef, #else, #endif are widely used as a tool for keeping backward compatibility in haskell packages. They are used in 5-10% of all packages registered on stackage. Although we don't encourage preprocessor usage in haskell source code, we decided that we have to create some kind of support for a restricted set of preprocessor pragmas.

From now, conditional preprocessor pragmas are supported for Haskell-tools. These pragmas are kept even if their related elements are removed. Currently the new pragma-keeping methods are used only in Organize imports (as imports are very likely to be conditionally enabled), but later we will ensure the preprocessor-compatibility for other refactorings.

Enhancements for Rename refactoring

The rename definition refactoring have been updated, now it can rename module aliases (as ... modifiers in imports).

So, for example, in import Data.List as LL, you can rename LL, and all qualified names that contain LL will be also renamed.

Checks on scoping rules have been also revised for safer refactoring.

2017. május 9., kedd

Rename definition refactoring

To rename a definition, select one of the occurrences. All occurrences (even in other modules) of the selected name will be renamed. Every Haskell definition (function, type, variable, constructor, field, typeclass, etc...) can be renamed.

f :: (Num a, Integral a) => a -> a -> a
f a b = (a + b) `div` 2

g :: Point -> Point -> Point
g p1 p2 = Point (f (x p1) (x p2)) (f (y p1) (y p2))

After renaming f to avg all occurrences are replaced:

avg :: (Num a, Integral a) => a -> a -> a
avg a b = (a + b) `div` 2

g :: Point -> Point -> Point
g p1 p2 = Point (avg (x p1) (x p2)) (avg (y p1) (y p2))

Rename definitions supports the GHC extension DuplicateRecordFields, so it can select the renamed field of multiple fields with the same name. It also supports RecordWildCards, so implicit bindings of fields will also be renamed. Modules can also be refactored, however the .cabal files are not updated automatically.

2017. április 5., szerda

Announcing Haskell Tools

The Beta version of Haskell Tools is released! You can use Haskell Tools to refactor your haskell code whether it is a set of cabal packages with hundreds of source files, or just a single module. It has an Atom plugin that enables you to use it in a rich development environment.


Currently 7 refactorings are supported, that are common tasks for a developer:

  • Rename a definition
  • Extract an expression as a binding
  • Inline a binding
  • Generate type signature for a binding
  • Organize imports of a module
  • Move a binding to an outer scope
  • Generate exports of a module

We tested the tool in the wild, refactoring packages on stackage. Our success rate is above 80%, so it is likely that your code can be successfully refactored with Haskell-tools.

Give it a try!

Haskell Tools - Haskell Tools in Atom

2017. január 18., szerda

Haskell Tools Refact

Haskell Tools Refact (ht-refact) is a refactoring tool for haskell. Refactoring means program transformation that keeps the semantics of a program, but improves the structure. So the refactored program can more flexible, shorter, easier to read or even faster than the original.

Haskell is a very good language for refactoring. One reason is that pure haskell functions cannot cause side effects. So in many occasions the program can safely be restructured, for example calls to functions can safely replaced with the bodies of the functions and vica versa.

The refactoring tool uses GHC as a backend, so it will always have the latest features and language extensions. It keeps the layout and comments of the original source code.

Check out the demo website, where you can try out the tool without the need to install anything.

Dear Haskellers!

I proudly announce the start of this blog. It is aimed for Haskell programmers around the world. Here I will write about a set of Haskell development tool named Haskell Tools that I'm currently working on, and especially about the refactoring tool called Haskell Tools Refact that I developed in the last year. This refactoring tool is now the main focus of this research & development project.

So I hope that you will enjoy the tools in your work or hobby projects. On this blog you will find news, tutorials, feature announcements for the tools.