HsModule is pass-polymorphic for no good reason?
Currently, `HsModule` is defined to be polymorphic over GHC passes. That is, it is defined like so:
```hs
data HsModule pass
= HsModule {
hsmodName :: Maybe (Located ModuleName),
hsmodExports :: Maybe (Located [LIE pass]),
hsmodImports :: [LImportDecl pass],
hsmodDecls :: [LHsDecl pass],
hsmodDeprecMessage :: Maybe (Located WarningTxt),
hsmodHaddockModHeader :: Maybe LHsDocString
}
deriving instance Data (HsModule GhcPs)
deriving instance Data (HsModule GhcRn)
deriving instance Data (HsModule GhcTc)
```
However, every single use site for `HsModule` that I can find only instantiates `pass` to `GhcPs`, which suggests that `HsModule` is only ever used for parsed code, but not renamed or typechecked code. In light of this, is there any good reason to keep around the `pass` parameter? We could make the code simpler by removing it:
```diff
diff --git a/compiler/GHC/Hs.hs b/compiler/GHC/Hs.hs
index 103539a41b..ecd891b52e 100644
--- a/compiler/GHC/Hs.hs
+++ b/compiler/GHC/Hs.hs
@@ -63,12 +63,12 @@ import Data.Data hiding ( Fixity )
-- | Haskell Module
--
-- All we actually declare here is the top-level structure for a module.
-data HsModule pass
+data HsModule
= HsModule {
hsmodName :: Maybe (Located ModuleName),
-- ^ @Nothing@: \"module X where\" is omitted (in which case the next
-- field is Nothing too)
- hsmodExports :: Maybe (Located [LIE pass]),
+ hsmodExports :: Maybe (Located [LIE GhcPs]),
-- ^ Export list
--
-- - @Nothing@: export list omitted, so export everything
@@ -82,11 +82,11 @@ data HsModule pass
-- ,'ApiAnnotation.AnnClose'
-- For details on above see note [Api annotations] in ApiAnnotation
- hsmodImports :: [LImportDecl pass],
+ hsmodImports :: [LImportDecl GhcPs],
-- ^ We snaffle interesting stuff out of the imported interfaces early
-- on, adding that info to TyDecls/etc; so this list is often empty,
-- downstream.
- hsmodDecls :: [LHsDecl pass],
+ hsmodDecls :: [LHsDecl GhcPs],
-- ^ Type, class, value, and interface signature decls
hsmodDeprecMessage :: Maybe (Located WarningTxt),
-- ^ reason\/explanation for warning/deprecation of this module
@@ -113,12 +113,10 @@ data HsModule pass
-- hsmodImports,hsmodDecls if this style is used.
-- For details on above see note [Api annotations] in ApiAnnotation
--- deriving instance (DataIdLR name name) => Data (HsModule name)
-deriving instance Data (HsModule GhcPs)
-deriving instance Data (HsModule GhcRn)
-deriving instance Data (HsModule GhcTc)
+deriving instance Data HsModule
```
If this sounds like a good idea, I can offer a patch. I have already confirmed that the test suite passes even with this change (after updating one type signature in the test suite).
issue