Skip to content

[new plugin] Add explicit export lists to each module using the minimal import lists #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jrp2014 opened this issue Mar 14, 2020 · 13 comments
Labels
type: enhancement New feature or request

Comments

@jrp2014
Copy link

jrp2014 commented Mar 14, 2020

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.

@ndmitchell
Copy link
Collaborator

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).

@ndmitchell
Copy link
Collaborator

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.

@jrp2014
Copy link
Author

jrp2014 commented Mar 14, 2020

Grand.

@jneira
Copy link
Member

jneira commented Oct 2, 2020

It should be a plugin in hls so transferred

@jneira jneira transferred this issue from haskell/ghcide Oct 2, 2020
@jneira
Copy link
Member

jneira commented Oct 2, 2020

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

pepeiborra added a commit that referenced this issue Dec 27, 2020
We were calling runCradle multiple times per cradle, concurrently. For Cabal
cradles this function runs Cabal, which is neither fast nor designed to be run
concurrently
@jneira
Copy link
Member

jneira commented Nov 26, 2021

Not sure i minimize imports could be part of the organize imports action in #719

@pepeiborra
Copy link
Collaborator

pepeiborra commented Nov 27, 2021

Minimize imports is exactly what the refine imports plugin does.

@jneira
Copy link
Member

jneira commented Nov 27, 2021

nice, so this can be close as already implmented :-)

@jneira jneira closed this as completed Nov 27, 2021
@isovector
Copy link
Collaborator

isovector commented Jan 25, 2022

I think this should still be open --- we don't yet have "make exports explicit," do we?

@ocharles
Copy link
Contributor

@isovector #450 (comment) writes

The "make exports explicit" was implemented by #436

@ocharles
Copy link
Contributor

Edit: whoops. I think that was a mis-comment, because #436 is about imports.

@jneira
Copy link
Member

jneira commented Jan 25, 2022

ugh, yeah, noted in the original comment. Change the title as minimise imports is already implemented

@isovector @ocharles thanks for the correction!

@jneira jneira changed the title Minimise imports, make exports explicit Add explicit export lists to each module using the minimal import lists Jan 25, 2022
@jneira jneira reopened this Jan 25, 2022
@hasufell
Copy link
Member

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?

@hasufell hasufell changed the title Add explicit export lists to each module using the minimal import lists [new plugin] Add explicit export lists to each module using the minimal import lists Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants