Decouple Language.Haskell.Syntax.Decls from GHC.Unit.Module.Warnings
The **`Language.Haskell.Syntax.Decls`** module depends on `GHC.Unit.Module.Warnings` to import the `WarningTxt` data-type which is used by the `WarnDecl` data-type defined therein. The dependence on `WarningTxt` is core to the Haskell AST, so care must be taken to transfer the most parsimonious definitions into the **`Language.Haskell`** "namespace" and leave all other decoupled definitions in **`GHC.Unit.Module.Warnings`**.
**The plan to decouple by altering the `WarnDecl` dependency on `WarningTxt`:**
1. Move `WarningTxt` to **`Language.Haskell.Syntax.Decls`**
2. Add extension points to both constructors of `WarningTxt` and an extension point for additional constructors
3. Move the occurrences of `SourceText` in both constructors of `WarningTxt` to the `XWarningTxt` and `XDeprecatedTxt` extension points
4. Substitute `[LocatedE (WithHsDocIdentifiers StringLiteral pass)]` in both by `[XRec pass (WithHsDocIdentifiers StringLiteral pass)]`
- This will add another coupling edge to **`GHC.Hs.Doc`**. That's fine, as all edges to **`GHC.Hs.Doc`** will be tackled simultanteously at a later date.
- Communication with `XRec` somehow that the location annotation for `WithHsDocIdentifiers StringLiteral pass` here is `LocatedE = GenLocated EpaLocation`. To do this, `type instance Anno (WithHsDocIdentifiers StringLiteral pass) = EpaLocation` is needed. See `Note [XRec and Anno in the AST]` and `Note [XRec and SrcSpans in the AST]`
5. Finally, move the `InWarningCategory` field to the **`Language.Haskell.Syntax.Decls`** as well (because `InWarningCategory` records a property of the AST).
- Add a `pass` type arg and add extension points to `InWarningCategory`
- The `EpToken` and `SourceText` are for exact print. Move them to the extension point.
- Get rid of the `LocatedE WarningCategory` using `XRec pass WarningCategory`, see above
- Move `WarningCategory` to **`Language.Haskell.Syntax.Decls`** as well
- This will add another coupling edge to **`GHC.Utils.FastString`**, which is fine. That will be decoupled later.
Some deviation from the plan above may be necessary, but generally the decoupling endeavor should be straight forward.
issue