You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently HLS suggests a code action to export identifier only if GHC determined it as unused and produced a warning like
-- Foo.hs:4:1: warning: [-Wunused-top-binds] Defined but not used: ‘f’
-- Foo.hs:5:1: warning: [-Wunused-top-binds] Defined but not used: type constructor or class ‘F’
-- Foo.hs:6:1: warning: [-Wunused-top-binds] Defined but not used: data constructor ‘Bar’
However I, as a user, could want to export already used type to make it available in other modules. I'd like HLS to automate adding of the name to the export list for me.
For instance, the user may want to export an internal type already used by an exported function. This is the simplest case where GHC won't produce a warning that the type is unused and thus no code action to export it would be offered.
Describe the solution you'd like
For each unexported toplevel function, datatype, type family, type class, etc identifier provide a code action to export it. In a perfect world also provide this suggestion for each not yet exported constructor name but this seems like harder to implement for no good reason. Most of the datatype exports export all constructors via (..).
However it's not entirely clear to me how to check that a given name is already exported other than analyzing existing exprot list by hand, which may be suboptimal since it duplicates logic already present in GHC for checking what's exported.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Currently HLS suggests a code action to export identifier only if GHC determined it as unused and produced a warning like
However I, as a user, could want to export already used type to make it available in other modules. I'd like HLS to automate adding of the name to the export list for me.
For instance, the user may want to export an internal type already used by an exported function. This is the simplest case where GHC won't produce a warning that the type is unused and thus no code action to export it would be offered.
Describe the solution you'd like
For each unexported toplevel function, datatype, type family, type class, etc identifier provide a code action to export it. In a perfect world also provide this suggestion for each not yet exported constructor name but this seems like harder to implement for no good reason. Most of the datatype exports export all constructors via
(..)
.Additional context
Currently the code action to export unused identifier from GHC's warning is implemented by
suggestExportUnusedTopBinding
at https://github.com/haskell/haskell-language-server/blob/master/ghcide/src/Development/IDE/Plugin/CodeAction.hs#L557. This may be a good chance to extract into a standalone plugin that does what's described above sincesuggestExportUnusedTopBinding
suggests to export a name only in a subset of all cases that the new plugin would.However it's not entirely clear to me how to check that a given name is already exported other than analyzing existing exprot list by hand, which may be suboptimal since it duplicates logic already present in GHC for checking what's exported.
The text was updated successfully, but these errors were encountered: