haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Unify module name checks

Open fendor opened this issue 2 years ago • 3 comments

Is your enhancement request related to a problem? Please describe.

I know of at least two locations where we check a module name for sanity, e.g. each component starts with an upper char. The plugins hls-cabal-plugin, hls-module-name-plugin and ghcide itself (until #3779 lands) are known to do that. However, they do not share any code.

Describe the solution you'd like

Common sanity checks should be performed by everyone in the same, predictable way.

Additional context

One bug in hls-module-name-plugin #3784

fendor avatar Sep 01 '23 07:09 fendor

Furthermore, this would provide a place to turn it into a saner check that looks for .cabal files and their hs-src-dirs to actually work out the module prefix more correctly.

michaelpj avatar Sep 01 '23 10:09 michaelpj

Here's a few locations that might be interesting for working on this issue:

Module Name Manipulation

There's a few types (ModuleName, Text, [Text], etc.) and different syntactical forms (Data.Text, Data/Text.hs, src/Data/Text.hs, etc.) in use for refering to modules. This is an (incomplete) list of code that works with theses representations.

Getting hs-source-dirs

  • hls-cabal-plugin does that in multiple places:
  • ghcide as well:

pbrinkmeier avatar Oct 13 '24 10:10 pbrinkmeier

I think an easy first step would be making the hs-source-dirs stuff consistent. Basically provide a common interface to map components of a GenericPackageDescription to source directories.

pbrinkmeier avatar Oct 13 '24 10:10 pbrinkmeier