Note [Handling never-exported TyThings under Backpack]
DEFINITION: A "never-exported TyThing" is a TyThing whose 'Name' will never be mentioned in the export list of a module (mi_avails). Unlike implicit TyThings (Note [Implicit TyThings]), non-exported TyThings DO have a standalone IfaceDecl declaration in their interface file. Originally, Backpack was designed under the assumption that anything you could declare in a module could also be exported; thus, merging the export lists of two signatures is just merging the declarations of two signatures writ small. Of course, in GHC Haskell, there are a few important things which are not explicitly exported but still can be used: in particular, dictionary functions for instances, Typeable TyCon bindings, and coercion axioms for type families also count. When handling these non-exported things, there two primary things we need to watch out for: * Signature matching/merging is done by comparing each of the exported entities of a signature and a module. These exported entities may refer to non-exported TyThings which must be tested for consistency. For example, an instance (ClsInst) will refer to a non-exported DFunId. In this case, 'checkBootDeclM' directly compares the embedded 'DFunId' in 'is_dfun'. For this to work at all, we must ensure that pointers in 'is_dfun' refer to DISTINCT 'DFunId's, even though the 'Name's (may) be the same. Unfortunately, this is the OPPOSITE of how we treat most other references to 'Name's, so this case needs to be handled specially. The details are in the documentation for 'typecheckIfacesForMerging'. and the Note [Resolving never-exported Names] in GHC.IfaceToCore. * When we rename modules and signatures, we use the export lists to decide how the declarations should be renamed. However, this means we don't get any guidance for how to rename non-exported entities. Fortunately, we only need to rename these entities *consistently*, so that 'typecheckIfacesForMerging' can wire them up as needed. The details are in Note [rnIfaceNeverExported] in 'GHC.Iface.Rename'. The root cause for all of these complications is the fact that these logically "implicit" entities are defined indirectly in an interface file. #13151 gives a proposal to make these *truly* implicit.
References 3
- rnIfaceNeverExported GHC.Iface.Rename
- Resolving never-exported Names GHC.IfaceToCore
- Implicit TyThings GHC.Types.TyThing
Referenced by 3
- rnIfaceNeverExported GHC.Iface.Rename
- Resolving never-exported Names GHC.IfaceToCore
- Grand plan for Typeable GHC.Tc.Instance.Typeable