Suggestion to add entity information to HieFile
Namespace is used to distinguish between different kinds of names that appear in a Haskell program in ghc. But namespaces are falling too much behind the the number of entities that ghc can offers.
- By ghc 9.8.2: we are only having:
VarName, DataName, TvName, TcClsName, FldName. - While we are having entities(simplified from
TyThing):patsyn, class, class method, type syn, type family...
~~It might be a good idea to expand the namespace to support some more discrete classification as mentioned above. Like what we did with field name, varName is refined to field name in the rename stage. As a result, It can offer a cheap way to query more accurately what entity the occname refers to, especially combining with #24244 to expose the NameSpace constructor. ~~
The primary motivation is to ease the implementation of our tools and protocols without having to query tyThing or Id. It is expecially useful for tools are depend only on HieFile. Some related issue in HLS https://github.com/haskell/haskell-language-server/issues/4119
Protocols that need this information are:
-
SymbolKindin LSIF for document symbols - Semantic token's
tokenTypesin LSP for semantic tokens -
Kindin scip
Some tools for haskell that benefits:
Static-ls, HLS and other tools or library that wish to generate result for the above protocols solely based on HieFile.
After discussion with simon, we probally should take another approach than messing up with namespaces,
create the a new data type for EntityInfo from TyThing and store it in the IdentifierDetails of the HieFile. (direct store of TyThing is too much).