fix-imports: Program to manage the imports of a haskell module

[ bsd3, editor, haskell, ide, program ] [ Propose Tags ]

fix-imports is a small standalone program to manage the import block of a haskell program. It will try to add import lines for qualified names with no corresponding import, remove unused import lines, and sort the import block according to some heuristic you can define. This only works for qualified imports! Unqualified imports are left untouched.

It's most convenient if bound to an editor key.

Recent major changes:

  • version 1.0.1

  • Fix a bunch of bugs: properly recognize unqualified imports as imports, never import the current module, don't pick up modules with the same suffix but a different name.

  • version 1.0.0

  • Change name from FixImports to fix-imports, which is more unixy.

  • Change ghc-pkg parsing from String to Text. It's noticeably faster.

  • Add a more flexible system for prioritizing imports. When there are several possibilities for a module name, they are all given to a single function to decide. The config file moved from fix-imports-priority to .fix-imports and can now specify sort orders for packages and modules by prefix.

  • Make -i includes for non-existent dirs ignored instead of causing an error.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.1.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 2.1.0, 2.2.0, 2.3.0, 2.4.0
Dependencies base (>=3 && <5), containers, cpphs, directory, filepath, haskell-src-exts (>=1.11), process, split, text, uniplate [details]
License BSD-3-Clause
Author Evan Laforge
Maintainer Evan Laforge <qdunkan@gmail.com>
Category Editor, Haskell, IDE
Source repo head: darcs get http://ofb.net/~elaforge/darcs/fix-imports/
Uploaded by EvanLaforge at 2012-04-13T19:24:58Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables fix-imports
Downloads 10452 total (44 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Successful builds reported [all 7 reports]

Readme for fix-imports-1.0.1

[back to package description]
There are a few things which can be configured.  Edit src/Main.hs and mess with
the Config it passes in.  There isn't much configurability but what there is
should be documented in the modules in which it is defined.

See the vimrc for an exmaple of how it can be bound to a key in vim.

It'll reformat the import lines, including an import list if you have one.
Sorry about that.  The formatting style of Language.Haskell.Exts.prettyPrint
is not my personal style.  If it ever bothers me enough maybe I'll write my
own formatter, or come up with a way to not reformat unqualified imports.

Also, it will search for modules starting from '.', so you should be in the
root of the module hierarchy.  It wouldn't be hard to add a -i flag though.

haskell-src-exts will crash the program if it gets an ambigious operator
fixity parse.  I don't know why it does that, but if you get a crash like that
you can add your custom operators to the Config.

It can be a little slow.  Most of this is probably that it rebuilds the
package index on every run.  So if you have a large package db and it's too
slow, caching the package index would probably help.