Serialize wired-in names as external names when creating HIE files
Edit: I created a new issue instead of editing this one, keeping this issue as a reference.
Edit: it turns out that we can use `isKnownOrigName_maybe` to reconstruct wired-in names from `Module` and `OccName`. This retains access to `TyThing` and helps with some pretty-printing related stuff for e.g. `[]` vs `List`. I'll update the issue description once CI for !14562 looks good.
## Motivation
1. #18329 proposes HIE file compatibility across different GHC versions.
2. [sol/ghc-hie](https://github.com/sol/ghc-hie) allows reading HIE files across multiple versions of GHC.
A key challenge for both (1) and (2) is dealing with wired-in names.
1. The list of wired-in names and their uniques frequently change between GHC versions.
2. The key difference between a wired-in name and an external name is that a wired-in name has a `TyThing` attached, while an external name hasn't.
- `TyThing` is a large and deeply nested data type. Supporting it across different GHC versions is hard.
- GHC needs `TyThing` during type checking, but it is not commonly useful when working with HIE files.
Serializing wired-in names as external names essentially strips `TyThing` from the `HieAST`. This immediately benefits `sol/ghc-hie` and it is one incremental step towards #18329.
## Proposal
GHC serializes wired-in names by storing their `Unique`.
A consumer of HIE files needs to know all wired-in names of the specific GHC version that was used to create the HIE file. Without that list of wired-in names it is not possible to reconstruct `Module`, `OccName` and `TyThing` from the `Unique`.
I propose to directly store `Module` and `OccName` for wired-in names, as we already do for external names, forgoing access to `TyThing`.
Specifically:
- Remove the `KnownKeyName` constructor from `HieName`
- Use `ExternalName` instead
This will benefit both `sol/ghc-hie` and #18329.
!14562 implements this.
## Alternative
If forgoing access to `TyThing` is not an option for some reason, then I propose to instead store `Module` and `OccName` in addition to the `Unique` for wired-in names.
Specifically:
- Change `KnownKeyName Unique` to `KnownKeyName Unique Module OccName`
This will benefit `sol/ghc-hie`, but not #18329.
!14563 implements this.
issue