<div dir="ltr"><div>All of us love to read explicit import lists (especially in an unknown module), but we all hate to write and maintain them.</div><div><br></div><div>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 <i>Importify</i>.</div><div><br></div><div><i>Importify</i> 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 <a href="https://github.com/serokell/importify/issues?q=is%3Aissue+is%3Aopen+label%3Ahacktoberfest">Importify</a> and Serokell’s own custom Prelude <a href="https://github.com/serokell/universum/issues?q=is%3Aissue+is%3Aopen+label%3Ahacktoberfest">Universum</a> during <a href="https://github.com/blog/2433-celebrate-open-source-this-october-with-hacktoberfest">Hacktoberfest</a>.</div><div><br></div><div><i>Importify</i> is all about decluttering the import blocks. It can remove:</div><div><br></div><div>- unused symbols in explicit import lists</div><div>- unused qualified imports</div><div>- unused implicit imports</div><div>- unnecessarily hidden symbols</div><div><br></div><div>Highlights of the functionality of <i>Importify</i> 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 <a href="https://hackage.haskell.org/package/autoexporter">autoexporter</a>.</div><div><br></div><div><i>Importify </i>works extremely well with large Haskell projects — we use it to great success to clean up <a href="https://github.com/input-output-hk/cardano-sl/">Cardano SL</a>. 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. </div><div><br></div><div>In the future, we plan for <i>Importify </i>to be able to add used symbols to imports automatically. To speed up <i>Importify </i>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 <i>implicit</i> and <i>explicit</i>, and between <i>qualified</i> and <i>unqualified</i> forms. Finally, we will be adding functionality to resolve merge conflicts in import section automatically.</div><div><br></div><div>If you notice that managing imports becomes a slog, feel free to try this tool out yourself. Spotted a bug? <a href="mailto:bugs@serokell.io">Contact us.</a></div><div><br></div><div>To those, who are in the mood for some hacking this Autumn, we’re looking forward to your #Hacktoberfest contributions!</div><div><br></div></div>