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.