ANN: fix-imports-0.1.2

Not sure if anyone else is using this, but I've fixed some bugs and bumped fix-imports by a few more versions. Here's copy paste from the package description: 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. Changes since last announcement: Mon Jul 11 23:00:19 PDT 2011 qdunkan@gmail.com * version 0.1.2 Mon Jul 11 22:58:56 PDT 2011 qdunkan@gmail.com * fix but where multiple comments above an import are lost Fri Jul 1 15:16:40 PDT 2011 qdunkan@gmail.com * don't reload file if no changes were made Fri Jul 1 14:43:02 PDT 2011 qdunkan@gmail.com * sort and format the import block even if imports weren't added or removed Wed Jun 15 12:39:12 PDT 2011 qdunkan@gmail.com * version 0.1.1 Wed Jun 15 12:14:31 PDT 2011 qdunkan@gmail.com * upgrade to haskell-src-exts 1.11, which removes the mandatory fixities Wed Jun 15 12:11:27 PDT 2011 qdunkan@gmail.com * fix bug causing qualified vs. non-qualified imports to be sorted inconsistently Thu Jun 2 12:10:08 PDT 2011 qdunkan@gmail.com * more specific versions for base

On 12 July 2011 16:09, Evan Laforge
Not sure if anyone else is using this, but I've fixed some bugs and bumped fix-imports by a few more versions.
Here's copy paste from the package description:
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.
This sounds interesting; it would be helpful if you could provide an example if you could provide an example in the README or description of what exactly this program does however. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Mon, Jul 11, 2011 at 11:48 PM, Ivan Lazar Miljenovic
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.
This sounds interesting; it would be helpful if you could provide an example if you could provide an example in the README or description of what exactly this program does however.
Sure, well... it's like the paragraph above :) As an example, I just hack away in haskell normally. When I've edited a chunk, and have a feeling a changed the dependencies, I hit ',a' in vim, and it will remove imports that are no longer used, and add imports that are now needed. As a bonus it'll sort and format the import list. That way I don't have to figure out if there are new modules needed, go to the top of the file, sift past the module haddock and find the right spot in the potentially large import list (and maybe I can't just ! out to 'sort' for that if some are qualified and some are unqualified), and type all that repetitive 'import qualified Blah.Blah.Blah as Blah' stuff. And I don't have to wait for ghc to warn me about redundant imports and then go delete them one by one. In addition to being generally convenient, I've found I'm more willing to use tiny helper functions like 'Maybe.fromMaybe' instead of just 'maybe x id' since the hassle of possibly adding the new import has been eliminated. It's a standalone program so it doesn't have to be vim, but that's what I use, so that's what I include binding glue for. I've also got an unrelated simple thing that keeps the currently edited haskell module in a file so I can type :L in ghci to load the module currently being edited. Very convenient, especially when modules start getting nested.

On 12 July 2011 17:18, Evan Laforge
On Mon, Jul 11, 2011 at 11:48 PM, Ivan Lazar Miljenovic
wrote: 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.
This sounds interesting; it would be helpful if you could provide an example if you could provide an example in the README or description of what exactly this program does however.
Sure, well... it's like the paragraph above :)
I meant more in the "Before: ... After: ..." sense ;-) (i.e. visually being able to tell what your program does, rather than just a description). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

I meant more in the "Before: ... After: ..." sense ;-) (i.e. visually being able to tell what your program does, rather than just a description).
Oh, ok, I guess I can do that too: Before: module M where import ZZ.Out.Of.Order import qualified No.Longer.Needed as Needed -- x = Needed.y -- just removed this y = New.something -- just added this After: module M where import qualified Heavily.Nested.New as New import ZZ.Out.Of.Order -- x = Needed.y -- just removed this y = New.something -- just added this

On 12.07.2011 09:59, Evan Laforge wrote:
I meant more in the "Before: ... After: ..." sense ;-) (i.e. visually being able to tell what your program does, rather than just a description).
Oh, ok, I guess I can do that too:
Before:
module M where import ZZ.Out.Of.Order import qualified No.Longer.Needed as Needed
-- x = Needed.y -- just removed this y = New.something -- just added this
After:
module M where import qualified Heavily.Nested.New as New import ZZ.Out.Of.Order
-- x = Needed.y -- just removed this y = New.something -- just added this
I also spend some time on managing imports. I'll try this program. However, usually I have a mix of qualified and unqualified imports, since some libraries are designed for unqualified imports.

On Wed, Jul 13, 2011 at 12:08 PM, Henning Thielemann
I also spend some time on managing imports. I'll try this program. However, usually I have a mix of qualified and unqualified imports, since some libraries are designed for unqualified imports.
You can still use unqualified imports, it just won't manage those for you. Automatically managing unqualified imports is solvable but harder.

I have used it a little and it worked quite nicely. One thing that to look out for though is that it first checks for modules from the current directory down -- so running it in somewhere you happen to have ghc sources too, will have all that come with it imported from there (and lines like "import path.to.ghc.DataMaybe (fromJust)" added). But this probably happens only when testing the program in the root of your home directory... (The reason I'm not using it regularly is that I haven't figured out a good way to use it, when developing with Notepad++ over sftp in another environment) -- Markus Läll

On Wed, Jul 13, 2011 at 3:05 PM, Markus Läll
One thing that to look out for though is that it first checks for modules from the current directory down -- so running it in somewhere you happen to have ghc sources too, will have all that come with it imported from there (and lines like "import path.to.ghc.DataMaybe (fromJust)" added). But this probably happens only when testing the program in the root of your home directory...
Yeah, currently the most annoying thing is when it guesses wrong. It's set up to work with my project, but you can tweak the search heuristic easily enough by editing findLocalModule. I'll have it skip non-capitalized directories, but a better solution is to not edit modules in your home directory :)
(The reason I'm not using it regularly is that I haven't figured out a good way to use it, when developing with Notepad++ over sftp in another environment)
Well, if anyone makes bindings for other editors, feel free to send a patch.
participants (4)
-
Evan Laforge
-
Henning Thielemann
-
Ivan Lazar Miljenovic
-
Markus Läll