Skip to content

Substitute minimal imports / add explicit exports #56

Closed
@jrp2014

Description

@jrp2014

GHC has a -ddump-minimal-imports flag. Would it be possible to use the haskell-language-server apparatus to write a new app to apply the minimal imports (optionally ignoring Prelude, perhaps) generated automatically? And across a whole project, rather than file by files in the editor?

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 derived 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, as well as using the compiler to "annotate" existing code. and make more explicit what the compiler is seeing / deriving.

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 or it could provide a good demo plugin project for haskell-language-server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions