[new plugin] Add explicit export lists to each module using the minimal import lists
GHC has a -ddump-minimal-imports flag. Would it be possible to use the ghcide apparatus to write a new app to apply the minimal imports (optionally ignoring Prelude, perhaps) generated automatically?
For bonus points, it should also be possible to use the set of minimal imports across a project to add explicit export lists to each module using the minimal import lists.
Of course, weeder does some of this at the module level, but not the module contents level.
Presumably, this would help faster compilation and provide GHC with better optimization opportunities.
Undoubtedly the automatically-generated results would need hand tweaking, but I think that it might be a great help to some older code bases that have developed a certain amount of cruft that this sort of analysis could help improve. Doing it by hand, with a shell script or two would be one approach, but it would be good to have something a bit more robust (eg, preserving comments).
Perhaps someone has already done this.
The idea is that ghcide is a small core, and that plugins are used to extend it. Most of the plugins are going to live in the https://github.com/haskell/haskell-language-server repo, so I suspect that is the place to ask for a plugin to be created (or even better, to write one yourself).
Oh, and for implementation, we don't need to rely on dump minimal imports flag - we have all the information in hand in the GHC AST, so it should be pretty easy to make the imports precisely minimal.
Grand.
It should be a plugin in hls so transferred
The "make exports explicit" was implemented by #436
EDIT: wrong comment, #436 is about make imports explicit and the issue is about make exports explicit
Not sure i minimize imports could be part of the organize imports action in #719
Minimize imports is exactly what the refine imports plugin does.
nice, so this can be close as already implmented :-)
I think this should still be open --- we don't yet have "make exports explicit," do we?
@isovector https://github.com/haskell/haskell-language-server/issues/450#issuecomment-702603386 writes
The "make exports explicit" was implemented by #436
Edit: whoops. I think that was a mis-comment, because #436 is about imports.
ugh, yeah, noted in the original comment. Change the title as minimise imports is already implemented
@isovector @ocharles thanks for the correction!
I think this should still be open --- we don't yet have "make exports explicit," do we?
Afaiu this should be a new plugin then?