tag:blogger.com,1999:blog-46705059878316956002024-03-08T03:32:59.210-08:00Haskell ToolsUnknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4670505987831695600.post-8226880822238268992017-05-22T06:40:00.001-07:002017-05-22T06:40:27.524-07:000.7 releaseThe 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.<br />
<br />
<h4>
Implemented handling of preprocessor conditional pragmas</h4>
<div>
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.</div>
<div>
<br /></div>
<div>
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.<br />
<br /></div>
<h4>
Enhancements for Rename refactoring</h4>
<div>
The rename definition refactoring have been updated, now it can rename module aliases (as ... modifiers in imports).</div>
<div>
<br /></div>
<div>
So, for example, in <span style="font-family: "courier new" , "courier" , monospace;">import Data.List as LL</span>, you can rename <span style="font-family: "courier new" , "courier" , monospace;">LL</span>, and all qualified names that contain <span style="font-family: "courier new" , "courier" , monospace;">LL </span>will be also renamed.</div>
<div>
<br /></div>
<div>
Checks on scoping rules have been also revised for safer refactoring.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4670505987831695600.post-89335577611446696832017-05-09T01:10:00.002-07:002017-05-09T01:10:59.071-07:00Rename definition refactoringTo 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.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">f :: (Num a, Integral a) => a -> a -> a</span><br />
<span style="font-family: Courier New, Courier, monospace;">f a b = (a + b) `div` 2</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">g :: Point -> Point -> Point</span><br />
<span style="font-family: Courier New, Courier, monospace;">g p1 p2 = Point (f (x p1) (x p2)) (f (y p1) (y p2))</span><br />
<br />
After renaming <span style="font-family: Courier New, Courier, monospace;">f</span> to <span style="font-family: Courier New, Courier, monospace;">avg </span>all occurrences are replaced:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">avg :: (Num a, Integral a) => a -> a -> a</span><br />
<span style="font-family: Courier New, Courier, monospace;">avg a b = (a + b) `div` 2</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">g :: Point -> Point -> Point</span><br />
<span style="font-family: Courier New, Courier, monospace;">g p1 p2 = Point (avg (x p1) (x p2)) (avg (y p1) (y p2))</span><br />
<br />
Rename definitions supports the GHC extension <span style="font-family: Courier New, Courier, monospace;">DuplicateRecordFields</span><span style="font-family: inherit;">, so it can select the renamed field of multiple fields with the same name. It also supports </span><span style="font-family: Courier New, Courier, monospace;">RecordWildCards</span>, so implicit bindings of fields will also be renamed. Modules can also be refactored, however the .cabal files are not updated automatically.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4670505987831695600.post-25392275124632358992017-04-05T23:43:00.000-07:002017-04-05T23:43:23.900-07:00Announcing Haskell ToolsThe 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.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://haskelltools.org/img/demoanimation.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://haskelltools.org/img/demoanimation.gif" height="227" width="400" /></a></div>
<br />
Currently 7 refactorings are supported, that are common tasks for a developer:<br />
<br />
<ul>
<li>Rename a definition</li>
<li>Extract an expression as a binding</li>
<li>Inline a binding</li>
<li>Generate type signature for a binding</li>
<li>Organize imports of a module</li>
<li>Move a binding to an outer scope</li>
<li>Generate exports of a module</li>
</ul>
<br />
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.<br />
<br />
Give it a try!<br />
<br />
<a href="https://github.com/haskell-tools/haskell-tools">Haskell Tools</a> - <a href="https://github.com/nboldi/haskell-tools-atom">Haskell Tools in Atom</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4670505987831695600.post-25380165974899420352017-01-18T13:48:00.001-08:002017-04-05T23:45:44.645-07:00Haskell Tools RefactHaskell 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.<br />
<br />
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.<br />
<br />
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.<br />
<br />
Check out the <a href="http://haskelltools.org/">demo website</a>, where you can try out the tool without the need to install anything.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-4670505987831695600.post-90794858205833193402017-01-18T12:18:00.004-08:002017-01-18T12:18:59.646-08:00Dear 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.<br />
<br />
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.Unknownnoreply@blogger.com0