Unify module name checks
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
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.
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.
- hls-module-name-plugin
-
hls-cabal-plugin -
ghcide:
Getting hs-source-dirs
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.