[Haskell-beginners] Hack “Importify” by Serokell During #Hacktoberfest!
gints.dreimanis at serokell.io
Wed Oct 18 15:49:57 UTC 2017
All of us love to read explicit import lists (especially in an unknown
module), but we all hate to write and maintain them.
>From our point of view, it is obligatory for any code that goes into
production to have only explicit imports. That way, the code is easier to
comprehend – no one is confused about the location of a stray type or
identifier, even when reading from GitHub or a simple editor. There are,
however, usability and maintainability issues with explicit imports, which
make enforcing explicit imports in style guides a topic for discussion. To
enjoy the benefits of explicit imports while keeping the drawbacks in
check, we have implemented *Importify*.
*Importify* is a tool developed by Serokell tooling team led by Dmitry
Kovalnikov. It is a refactoring tool that helps import management in
Haskell code. We’re getting close to releasing it on Hackage, but it
requires some polishing. You can contribute to Importify
and Serokell’s own custom Prelude Universum
*Importify* is all about decluttering the import blocks. It can remove:
- unused symbols in explicit import lists
- unused qualified imports
- unused implicit imports
- unnecessarily hidden symbols
Highlights of the functionality of *Importify* are that it works deeply
with explicit import lists (it can, for instance, remove unused
constructors), and it works with hiding imports. The latter feature isn’t
present in any open-source refactoring tool that is known to us. It is also
compatible with autoexporter
*Importify *works extremely well with large Haskell projects — we use it to
great success to clean up Cardano SL
<https://github.com/input-output-hk/cardano-sl/>. Importify only parses
source code instead of building projects. For a project of the size of
Cardano SL it takes only two minutes to build Importify cache while
building it would take forty minutes on the same machine.
In the future, we plan for *Importify *to be able to add used symbols to
imports automatically. To speed up *Importify *runs, we will implement a
cache server that caches each Hackage package. You will be able to upload
caches for your projects there as well. Next on the roadmap is
functionality to convert imports between *implicit* and *explicit*, and
between *qualified* and *unqualified* forms. Finally, we will be adding
functionality to resolve merge conflicts in import section automatically.
If you notice that managing imports becomes a slog, feel free to try this
tool out yourself. Spotted a bug? Contact us. <bugs at serokell.io>
To those, who are in the mood for some hacking this Autumn, we’re looking
forward to your #Hacktoberfest contributions!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners