Wolfgang Jeltsch pushed to branch wip/jeltsch/smaller-pit at Glasgow Haskell Compiler / GHC

Commits:

24 changed files:

Changes:

  • compiler/GHC/Driver/Downsweep.hs
    ... ... @@ -898,7 +898,8 @@ readFixedModule (DownsweepEnv { ds_hsc_env = hsc_env }) key =
    898 898
             -- part of the compiler.
    
    899 899
             lookupIfaceByModuleHsc hsc_env (mnkToModule key) >>= \case
    
    900 900
               Just iface -> return (MaybeErr.Succeeded iface)
    
    901
    -          Nothing -> readIface (hsc_hooks hsc_env) (hsc_logger hsc_env) (hsc_dflags hsc_env) (hsc_NC hsc_env) (mnkToModule key) (ml_hi_file loc)
    
    901
    +          Nothing    -> fmap retainedModIface <$>
    
    902
    +                        readIface (hsc_hooks hsc_env) (hsc_logger hsc_env) (hsc_dflags hsc_env) (hsc_NC hsc_env) (mnkToModule key) (ml_hi_file loc)
    
    902 903
           return $ case read_result of
    
    903 904
             MaybeErr.Succeeded iface -> Just (FixedModule loc (ifaceEdges (mi_deps iface)))
    
    904 905
             -- Skip any failure, we might try to read a .hi-boot file for
    

  • compiler/GHC/Driver/Env.hs
    ... ... @@ -387,10 +387,10 @@ lookupIfaceByModule
    387 387
             :: HomeUnitGraph
    
    388 388
             -> PackageIfaceTable
    
    389 389
             -> Module
    
    390
    -        -> IO (Maybe ModIface)
    
    390
    +        -> IO (Maybe RetainedModIface)
    
    391 391
     lookupIfaceByModule hug pit mod
    
    392 392
       = HUG.lookupHugByModule mod hug >>= pure . \case
    
    393
    -       Just hm -> Just (hm_iface hm)
    
    393
    +       Just hm -> Just (retainedModIface (hm_iface hm))
    
    394 394
            Nothing -> lookupModuleEnv pit mod
    
    395 395
        -- If the module does come from the home package, why do we look in the PIT as well?
    
    396 396
        -- (a) In OneShot mode, even home-package modules accumulate in the PIT
    
    ... ... @@ -399,7 +399,7 @@ lookupIfaceByModule hug pit mod
    399 399
        -- We could eliminate (b) if we wanted, by making GHC.Prim belong to a package
    
    400 400
        -- of its own, but it doesn't seem worth the bother.
    
    401 401
     
    
    402
    -lookupIfaceByModuleHsc :: HscEnv -> Module -> IO (Maybe ModIface)
    
    402
    +lookupIfaceByModuleHsc :: HscEnv -> Module -> IO (Maybe RetainedModIface)
    
    403 403
     lookupIfaceByModuleHsc hsc_env mod = do
    
    404 404
       eps <- hscEPS hsc_env
    
    405 405
       lookupIfaceByModule (hsc_HUG hsc_env) (eps_PIT eps) mod
    

  • compiler/GHC/Driver/Main/Interactive.hs
    ... ... @@ -148,7 +148,7 @@ hscIsGHCiMonad :: HscEnv -> String -> IO Name
    148 148
     hscIsGHCiMonad hsc_env name
    
    149 149
       = runHsc hsc_env $ ioMsgMaybe $ hoistTcRnMessage $ isGHCiMonad hsc_env name
    
    150 150
     
    
    151
    -hscGetModuleInterface :: HscEnv -> Module -> IO ModIface
    
    151
    +hscGetModuleInterface :: HscEnv -> Module -> IO RetainedModIface
    
    152 152
     hscGetModuleInterface hsc_env0 mod = runInteractiveHsc hsc_env0 $ do
    
    153 153
       hsc_env <- getHscEnv
    
    154 154
       ioMsgMaybe $ hoistTcRnMessage $ getModuleInterface hsc_env mod
    
    ... ... @@ -270,7 +270,7 @@ hscCheckSafe' m l = do
    270 270
                 _ | isHomeModule home_unit mod      -> True
    
    271 271
                 _ -> isUnitTrusted unit_state (moduleUnit m)
    
    272 272
     
    
    273
    -    lookup' :: Module -> Hsc (Maybe ModIface)
    
    273
    +    lookup' :: Module -> Hsc (Maybe RetainedModIface)
    
    274 274
         lookup' m = do
    
    275 275
             hsc_env <- getHscEnv
    
    276 276
             iface <- liftIO $ lookupIfaceByModuleHsc hsc_env m
    

  • compiler/GHC/Driver/Main/Passes.hs
    ... ... @@ -1335,7 +1335,7 @@ hscCheckSafe' m l = do
    1335 1335
                 _ | isHomeModule home_unit mod      -> True
    
    1336 1336
                 _ -> isUnitTrusted unit_state (moduleUnit m)
    
    1337 1337
     
    
    1338
    -    lookup' :: Module -> Hsc (Maybe ModIface)
    
    1338
    +    lookup' :: Module -> Hsc (Maybe RetainedModIface)
    
    1339 1339
         lookup' m = do
    
    1340 1340
             hsc_env <- getHscEnv
    
    1341 1341
             iface <- liftIO $ lookupIfaceByModuleHsc hsc_env m
    

  • compiler/GHC/Driver/Plugins.hs
    ... ... @@ -224,7 +224,7 @@ data PluginWithArgs = PluginWithArgs
    224 224
     data LoadedPlugin = LoadedPlugin
    
    225 225
       { lpPlugin :: PluginWithArgs
    
    226 226
       -- ^ the actual plugin together with its commandline arguments
    
    227
    -  , lpModule :: ModIface
    
    227
    +  , lpModule :: RetainedModIface
    
    228 228
       -- ^ the module containing the plugin
    
    229 229
       }
    
    230 230
     
    

  • compiler/GHC/Driver/Session/Inspect.hs
    ... ... @@ -87,7 +87,7 @@ data ModuleInfo = ModuleInfo {
    87 87
             minf_type_env  :: TypeEnv,
    
    88 88
             minf_exports   :: [AvailInfo],
    
    89 89
             minf_instances :: [ClsInst],
    
    90
    -        minf_iface     :: Maybe ModIface,
    
    90
    +        minf_iface     :: Maybe RetainedModIface,
    
    91 91
             minf_safe      :: SafeHaskellMode,
    
    92 92
             minf_modBreaks :: Maybe InternalModBreaks
    
    93 93
       }
    
    ... ... @@ -140,7 +140,7 @@ getHomeModuleInfo hsc_env mdl =
    140 140
         Nothing  -> return Nothing
    
    141 141
         Just hmi -> do
    
    142 142
           let details  = hm_details hmi
    
    143
    -          iface    = hm_iface hmi
    
    143
    +          iface    = retainedModIface (hm_iface hmi)
    
    144 144
           return (Just (ModuleInfo {
    
    145 145
                             minf_type_env  = md_types details,
    
    146 146
                             minf_exports   = md_exports details,
    
    ... ... @@ -187,7 +187,7 @@ modInfoLookupName minf name = withSession $ \hsc_env -> do
    187 187
          Just tyThing -> return (Just tyThing)
    
    188 188
          Nothing      -> liftIO (lookupType hsc_env name)
    
    189 189
     
    
    190
    -modInfoIface :: ModuleInfo -> Maybe ModIface
    
    190
    +modInfoIface :: ModuleInfo -> Maybe RetainedModIface
    
    191 191
     modInfoIface = minf_iface
    
    192 192
     
    
    193 193
     -- | Retrieve module safe haskell mode
    

  • compiler/GHC/HsToCore/Usage.hs
    ... ... @@ -276,7 +276,7 @@ mk_mod_usage_info uc home_unit home_unit_ids this_mod direct_imports imp_decls u
    276 276
         --  a) we used something from it; has something in used_names
    
    277 277
         --  b) we imported it, even if we used nothing from it
    
    278 278
         --     (need to recompile if its export list changes: export_fprint)
    
    279
    -    mkUsage :: Module -> ModIface -> Maybe Usage
    
    279
    +    mkUsage :: Module -> RetainedModIface -> Maybe Usage
    
    280 280
         mkUsage mod iface
    
    281 281
           | toUnitId (moduleUnit mod) `Set.notMember` home_unit_ids
    
    282 282
           = Just $ UsagePackageModule{ usg_mod      = mod,
    
    ... ... @@ -302,9 +302,9 @@ mk_mod_usage_info uc home_unit home_unit_ids this_mod direct_imports imp_decls u
    302 302
                           usg_entities = Map.toList ent_hashs,
    
    303 303
                           usg_safe     = imp_safe }
    
    304 304
           where
    
    305
    -        finsts_mod = mi_finsts iface
    
    305
    +        finsts_mod = mi_abi_finsts (mi_abi_hashes iface)
    
    306 306
             hash_env   = mi_hash_fn iface
    
    307
    -        mod_hash   = mi_mod_hash iface
    
    307
    +        mod_hash   = mi_abi_mod_hash (mi_abi_hashes iface)
    
    308 308
             imported_exports
    
    309 309
               = if not depend_on_exports
    
    310 310
                 then Nothing
    
    ... ... @@ -312,9 +312,9 @@ mk_mod_usage_info uc home_unit home_unit_ids this_mod direct_imports imp_decls u
    312 312
                   Just $
    
    313 313
                     HomeModImport
    
    314 314
                      { hmiu_orphanLikeHash
    
    315
    -                     = mi_orphan_like_hash iface
    
    315
    +                     = mi_abi_orphan_like_hash (mi_abi_hashes iface)
    
    316 316
                      , hmiu_importedAvails
    
    317
    -                     = moduleImportedAvails mod (mi_export_avails_hash iface) imp_decls
    
    317
    +                     = moduleImportedAvails mod (mi_abi_export_avails_hash (mi_abi_hashes iface)) imp_decls
    
    318 318
                      }
    
    319 319
     
    
    320 320
             by_is_safe (ImportedByUser imv) = imv_is_safe imv
    

  • compiler/GHC/Iface/Binary.hs
    ... ... @@ -197,7 +197,7 @@ getIfaceWithExtFields name_cache bh = do
    197 197
       modIfaceBinData <- freezeBinHandle bh start
    
    198 198
       pure $ mod_iface
    
    199 199
         & set_mi_ext_fields extFields
    
    200
    -    & set_mi_hi_bytes (FullIfaceBinHandle $ Strict.Just modIfaceBinData)
    
    200
    +    & set_mi_hi_bytes (Strict.Just modIfaceBinData)
    
    201 201
     
    
    202 202
     -- | This performs a get action after reading the dictionary and symbol
    
    203 203
     -- table. It is necessary to run this before trying to deserialise any
    
    ... ... @@ -276,10 +276,10 @@ writeBinIface profile traceBinIface compressionLevel hi_path mod_iface = do
    276 276
     putIfaceWithExtFields :: TraceBinIFace -> CompressionIFace -> WriteBinHandle -> ModIface -> IO ()
    
    277 277
     putIfaceWithExtFields traceBinIface compressionLevel bh mod_iface =
    
    278 278
       case mi_hi_bytes mod_iface of
    
    279
    -    FullIfaceBinHandle Strict.Nothing -> do
    
    279
    +    Strict.Nothing -> do
    
    280 280
           forwardPutRel_ bh (\_ -> put_ bh (mi_ext_fields mod_iface)) $ do
    
    281 281
             putWithUserData traceBinIface compressionLevel bh mod_iface
    
    282
    -    FullIfaceBinHandle (Strict.Just binData) -> putFullBinData bh binData
    
    282
    +    Strict.Just binData -> putFullBinData bh binData
    
    283 283
     
    
    284 284
     -- | Put a piece of data with an initialised `UserData` field. This
    
    285 285
     -- is necessary if you want to serialise Names or FastStrings.
    

  • compiler/GHC/Iface/Load.hs
    ... ... @@ -308,7 +308,7 @@ loadKnownKeyOccMaps
    308 308
         known_key_maps :: Module -> IfM lcl KnownKeyNameMaps
    
    309 309
         known_key_maps mod
    
    310 310
           = do { iface <- loadInterfaceWithException doc mod ImportBySystem
    
    311
    -           ; let !abi_hash = mi_mod_hash iface
    
    311
    +           ; let !abi_hash = mi_abi_mod_hash (mi_abi_hashes iface)
    
    312 312
                ; eps <- getEps
    
    313 313
                ; case lookupModuleEnv (eps_known_keys eps) mod of
    
    314 314
                    Just (cached_hash, kk_maps)
    
    ... ... @@ -321,7 +321,7 @@ loadKnownKeyOccMaps
    321 321
                                          (abi_hash, kk_maps) }
    
    322 322
                            ; return kk_maps } }
    
    323 323
     
    
    324
    -    build_maps :: ModIface -> KnownKeyNameMaps
    
    324
    +    build_maps :: RetainedModIface -> KnownKeyNameMaps
    
    325 325
         build_maps iface = (kk_map, occ_map)
    
    326 326
           where
    
    327 327
             kk_map :: UniqFM KnownKey Name
    
    ... ... @@ -628,7 +628,7 @@ loadSrcInterface :: SDoc
    628 628
                      -> ModuleName
    
    629 629
                      -> IsBootInterface     -- {-# SOURCE #-} ?
    
    630 630
                      -> PkgQual             -- "package", if any
    
    631
    -                 -> RnM ModIface
    
    631
    +                 -> RnM RetainedModIface
    
    632 632
     
    
    633 633
     loadSrcInterface doc scope mod want_boot maybe_pkg
    
    634 634
       = do { res <- loadSrcInterface_maybe doc scope mod want_boot maybe_pkg
    
    ... ... @@ -648,7 +648,7 @@ loadSrcInterface_maybe :: SDoc
    648 648
                            -> ModuleName
    
    649 649
                            -> IsBootInterface     -- {-# SOURCE #-} ?
    
    650 650
                            -> PkgQual             -- "package", if any
    
    651
    -                       -> RnM (MaybeErr MissingInterfaceError ModIface)
    
    651
    +                       -> RnM (MaybeErr MissingInterfaceError RetainedModIface)
    
    652 652
     
    
    653 653
     loadSrcInterface_maybe doc scope mod want_boot maybe_pkg
    
    654 654
       -- We must first find which Module this import refers to.  This involves
    
    ... ... @@ -667,7 +667,7 @@ loadSrcInterface_maybe doc scope mod want_boot maybe_pkg
    667 667
     -- rare operation, but in particular it is used to load orphan modules
    
    668 668
     -- in order to pull their instances into the global package table and to
    
    669 669
     -- handle some operations in GHCi).
    
    670
    -loadModuleInterface :: SDoc -> Module -> TcM ModIface
    
    670
    +loadModuleInterface :: SDoc -> Module -> TcM RetainedModIface
    
    671 671
     loadModuleInterface doc mod = initIfaceTcRn (loadSysInterface doc mod)
    
    672 672
     
    
    673 673
     -- | Load interfaces for a collection of modules.
    
    ... ... @@ -681,7 +681,7 @@ loadModuleInterfaces doc mods
    681 681
     -- | Loads the interface for a given Name.
    
    682 682
     -- Should only be called for an imported name;
    
    683 683
     -- otherwise loadSysInterface may not find the interface
    
    684
    -loadInterfaceForName :: SDoc -> Name -> TcRn ModIface
    
    684
    +loadInterfaceForName :: SDoc -> Name -> TcRn RetainedModIface
    
    685 685
     loadInterfaceForName doc name
    
    686 686
       = do { when debugIsOn $  -- Check pre-condition
    
    687 687
              do { this_mod <- getModule
    
    ... ... @@ -690,7 +690,7 @@ loadInterfaceForName doc name
    690 690
             initIfaceTcRn $ loadSysInterface doc (nameModule name) }
    
    691 691
     
    
    692 692
     -- | Loads the interface for a given Module.
    
    693
    -loadInterfaceForModule :: SDoc -> Module -> TcRn ModIface
    
    693
    +loadInterfaceForModule :: SDoc -> Module -> TcRn RetainedModIface
    
    694 694
     loadInterfaceForModule doc m
    
    695 695
       = do
    
    696 696
         -- Should not be called with this module
    
    ... ... @@ -724,23 +724,23 @@ loadWiredInHomeIface name
    724 724
     
    
    725 725
     ------------------
    
    726 726
     -- | Loads a system interface and throws an exception if it fails
    
    727
    -loadSysInterface :: SDoc -> Module -> IfM lcl ModIface
    
    727
    +loadSysInterface :: SDoc -> Module -> IfM lcl RetainedModIface
    
    728 728
     loadSysInterface doc mod_name = loadInterfaceWithException doc mod_name ImportBySystem
    
    729 729
     
    
    730 730
     ------------------
    
    731 731
     -- | Loads a user interface and throws an exception if it fails. The first parameter indicates
    
    732 732
     -- whether we should import the boot variant of the module
    
    733
    -loadUserInterface :: IsBootInterface -> SDoc -> Module -> IfM lcl ModIface
    
    733
    +loadUserInterface :: IsBootInterface -> SDoc -> Module -> IfM lcl RetainedModIface
    
    734 734
     loadUserInterface is_boot doc mod_name
    
    735 735
       = loadInterfaceWithException doc mod_name (ImportByUser is_boot)
    
    736 736
     
    
    737
    -loadPluginInterface :: SDoc -> Module -> IfM lcl ModIface
    
    737
    +loadPluginInterface :: SDoc -> Module -> IfM lcl RetainedModIface
    
    738 738
     loadPluginInterface doc mod_name
    
    739 739
       = loadInterfaceWithException doc mod_name ImportByPlugin
    
    740 740
     
    
    741 741
     ------------------
    
    742 742
     -- | A wrapper for 'loadInterface' that throws an exception if it fails
    
    743
    -loadInterfaceWithException :: SDoc -> Module -> WhereFrom -> IfM lcl ModIface
    
    743
    +loadInterfaceWithException :: SDoc -> Module -> WhereFrom -> IfM lcl RetainedModIface
    
    744 744
     loadInterfaceWithException doc mod_name where_from
    
    745 745
       = do
    
    746 746
         dflags <- getDynFlags
    
    ... ... @@ -749,7 +749,7 @@ loadInterfaceWithException doc mod_name where_from
    749 749
     
    
    750 750
     ------------------
    
    751 751
     loadInterface :: SDoc -> Module -> WhereFrom
    
    752
    -              -> IfM lcl (MaybeErr MissingInterfaceError ModIface)
    
    752
    +              -> IfM lcl (MaybeErr MissingInterfaceError RetainedModIface)
    
    753 753
     
    
    754 754
     -- loadInterface looks in both the HPT and PIT for the required interface
    
    755 755
     -- If not found, it loads it, and puts it in the PIT (always).
    
    ... ... @@ -796,7 +796,7 @@ loadInterface doc_str mod from
    796 796
                                  liftIO $ computeInterface hsc_env doc_str hi_boot_file mod
    
    797 797
             ; case read_result of {
    
    798 798
                 Failed err -> do
    
    799
    -                { let fake_iface = emptyFullModIface mod
    
    799
    +                { let fake_iface = emptyRetainedModIface mod
    
    800 800
     
    
    801 801
                     ; updateEps_ $ \eps ->
    
    802 802
                             eps { eps_PIT = extendModuleEnv (eps_PIT eps) (mi_module fake_iface) fake_iface }
    
    ... ... @@ -856,16 +856,7 @@ loadInterface doc_str mod from
    856 856
             ; new_eps_complete_matches <- tcIfaceCompleteMatches (mi_complete_matches iface)
    
    857 857
             ; purged_hsc_env <- getTopEnv
    
    858 858
     
    
    859
    -        ; let final_iface = iface
    
    860
    -                               & set_mi_decls     (panic "No mi_decls in PIT")
    
    861
    -                               & set_mi_insts     (panic "No mi_insts in PIT")
    
    862
    -                               & set_mi_defaults  (panic "No mi_defaults in PIT")
    
    863
    -                               & set_mi_fam_insts (panic "No mi_fam_insts in PIT")
    
    864
    -                               & set_mi_rules     (panic "No mi_rules in PIT")
    
    865
    -                               & set_mi_anns      (panic "No mi_anns in PIT")
    
    866
    -                               & set_mi_simplified_core (panic "No mi_simplified_core in PIT")
    
    867
    -
    
    868
    -              bad_boot = mi_boot iface == IsBoot
    
    859
    +        ; let bad_boot = mi_boot iface == IsBoot
    
    869 860
                               && isJust (lookupKnotVars (if_rec_types gbl_env) mod)
    
    870 861
                                 -- Warn against an EPS-updating import
    
    871 862
                                 -- of one's own boot file! (one-shot only)
    
    ... ... @@ -892,7 +883,7 @@ loadInterface doc_str mod from
    892 883
                     then eps { eps_PTE = addDeclsToPTE (eps_PTE eps) new_eps_decls }
    
    893 884
                else
    
    894 885
                     eps {
    
    895
    -                  eps_PIT          = extendModuleEnv (eps_PIT eps) mod final_iface,
    
    886
    +                  eps_PIT          = extendModuleEnv (eps_PIT eps) mod (retainedModIface iface),
    
    896 887
                       eps_PTE          = addDeclsToPTE   (eps_PTE eps) new_eps_decls,
    
    897 888
                       eps_iface_bytecode = add_bytecode (eps_iface_bytecode eps),
    
    898 889
                       eps_rule_base    = extendRuleBaseList (eps_rule_base eps)
    
    ... ... @@ -921,10 +912,8 @@ loadInterface doc_str mod from
    921 912
                       eps_defaults    =  extendModuleEnv (eps_defaults eps) mod new_eps_defaults
    
    922 913
                                                        }
    
    923 914
     
    
    924
    -        ; -- invoke plugins with *full* interface, not final_iface, to ensure
    
    925
    -          -- that plugins have access to declarations, etc.
    
    926
    -          res <- withPlugins (hsc_plugins hsc_env) (\p -> interfaceLoadAction p) iface
    
    927
    -        ; return (Succeeded res)
    
    915
    +        ; res <- withPlugins (hsc_plugins hsc_env) (\p -> interfaceLoadAction p) iface
    
    916
    +        ; return (Succeeded (retainedModIface res))
    
    928 917
         }}}}
    
    929 918
     
    
    930 919
     {- Note [Loading your own hi-boot file]
    
    ... ... @@ -1389,14 +1378,11 @@ ghcPrimIface
    1389 1378
           & set_mi_decls    []
    
    1390 1379
           & set_mi_fixities ghcPrimFixities
    
    1391 1380
           & set_mi_fix_fn (mkIfaceFixCache ghcPrimFixities)
    
    1392
    -      & set_mi_decl_warn_fn (mkIfaceDeclWarnCache ghcPrimWarns)
    
    1393
    -      & set_mi_export_warn_fn (mkIfaceExportWarnCache ghcPrimWarns)
    
    1394
    -      & set_mi_fix_fn (mkIfaceFixCache ghcPrimFixities)
    
    1395 1381
           & set_mi_docs (Just ghcPrimDeclDocs) -- See Note [GHC.Prim Docs] in GHC.Builtin
    
    1396 1382
           & set_mi_warns (toIfaceWarnings ghcPrimWarns) -- See Note [GHC.Prim Deprecations] in GHC.Builtin
    
    1397 1383
     
    
    1398 1384
       where
    
    1399
    -    empty_iface = emptyFullModIface gHC_PRIM
    
    1385
    +    empty_iface = emptyModIface gHC_PRIM
    
    1400 1386
     
    
    1401 1387
     -- | Get gHC_PRIM interface file
    
    1402 1388
     --
    

  • compiler/GHC/Iface/Load.hs-boot
    ... ... @@ -2,7 +2,7 @@ module GHC.Iface.Load where
    2 2
     
    
    3 3
     import GHC.Unit.Module (Module)
    
    4 4
     import GHC.Tc.Utils.Monad (IfM)
    
    5
    -import GHC.Unit.Module.ModIface (ModIface)
    
    5
    +import GHC.Unit.Module.ModIface (RetainedModIface)
    
    6 6
     import GHC.Utils.Outputable (SDoc)
    
    7 7
     
    
    8
    -loadSysInterface :: SDoc -> Module -> IfM lcl ModIface
    8
    +loadSysInterface :: SDoc -> Module -> IfM lcl RetainedModIface

  • compiler/GHC/Iface/Make.hs
    ... ... @@ -77,6 +77,7 @@ import GHC.Iface.Binary
    77 77
     
    
    78 78
     import GHC.Data.FastString
    
    79 79
     import GHC.Data.Maybe
    
    80
    +import qualified GHC.Data.Strict as Strict
    
    80 81
     
    
    81 82
     import GHC.HsToCore.Docs
    
    82 83
     import GHC.HsToCore.Usage
    
    ... ... @@ -394,7 +395,7 @@ mkIface_ hsc_env
    394 395
               & set_mi_docs             docs
    
    395 396
               & set_mi_abi_hashes       ()
    
    396 397
               & set_mi_ext_fields       emptyExtensibleFields
    
    397
    -          & set_mi_hi_bytes         PartialIfaceBinHandle
    
    398
    +          & set_mi_hi_bytes         Strict.Nothing
    
    398 399
     
    
    399 400
       where
    
    400 401
          cmp_rule     = lexicalCompareFS `on` ifRuleName
    

  • compiler/GHC/Iface/Recomp.hs
    ... ... @@ -68,7 +68,6 @@ import GHC.Unit.Home
    68 68
     import GHC.Unit.Module
    
    69 69
     import GHC.Unit.Module.ModIface
    
    70 70
     import GHC.Unit.Module.ModSummary
    
    71
    -import GHC.Unit.Module.Warnings
    
    72 71
     import GHC.Unit.Module.Deps
    
    73 72
     
    
    74 73
     import Control.Monad
    
    ... ... @@ -707,7 +706,7 @@ checkDependencies hsc_env summary iface
    707 706
             return $ needsRecompileBecause $ ModulePackageChanged new_name
    
    708 707
     
    
    709 708
     
    
    710
    -needInterface :: Module -> (ModIface -> IO RecompileRequired)
    
    709
    +needInterface :: Module -> (RetainedModIface -> IO RecompileRequired)
    
    711 710
                  -> IfG RecompileRequired
    
    712 711
     needInterface mod continue
    
    713 712
       = do
    
    ... ... @@ -727,7 +726,7 @@ needBytecode mod continue
    727 726
             Nothing -> return $ NeedsRecompile MustCompile
    
    728 727
             Just mbc -> liftIO $ continue mbc
    
    729 728
     
    
    730
    -tryGetModIface :: String -> Module -> IfG (Maybe ModIface)
    
    729
    +tryGetModIface :: String -> Module -> IfG (Maybe RetainedModIface)
    
    731 730
     tryGetModIface doc_msg mod
    
    732 731
       = do  -- Load the imported interface if possible
    
    733 732
         logger <- getLogger
    
    ... ... @@ -779,7 +778,7 @@ checkModUsage _ UsagePackageModule{
    779 778
       logger <- getLogger
    
    780 779
       needInterface mod $ \iface -> do
    
    781 780
         let reason = ModuleChanged (moduleName mod)
    
    782
    -    checkModuleFingerprint logger reason old_mod_hash (mi_mod_hash iface)
    
    781
    +    checkModuleFingerprint logger reason old_mod_hash (mi_abi_mod_hash (mi_abi_hashes iface))
    
    783 782
             -- We only track the ABI hash of package modules, rather than
    
    784 783
             -- individual entity usages, so if the ABI hash changes we must
    
    785 784
             -- recompile.  This is safe but may entail more recompilation when
    
    ... ... @@ -789,7 +788,7 @@ checkModUsage _ UsageMergedRequirement{ usg_mod = mod, usg_mod_hash = old_mod_ha
    789 788
       logger <- getLogger
    
    790 789
       needInterface mod $ \iface -> do
    
    791 790
         let reason = ModuleChangedRaw (moduleName mod)
    
    792
    -    checkModuleFingerprint logger reason old_mod_hash (mi_mod_hash iface)
    
    791
    +    checkModuleFingerprint logger reason old_mod_hash (mi_abi_mod_hash (mi_abi_hashes iface))
    
    793 792
     checkModUsage _  UsageHomeModuleBytecode{ usg_mod_name = mod_name
    
    794 793
                                                      , usg_unit_id = uid
    
    795 794
                                                      , usg_bytecode_hash = old_bytecode_hash } = do
    
    ... ... @@ -810,7 +809,7 @@ checkModUsage _ UsageHomeModule{
    810 809
         logger <- getLogger
    
    811 810
         needInterface mod $ \iface -> do
    
    812 811
          let
    
    813
    -         new_mod_hash    = mi_mod_hash iface
    
    812
    +         new_mod_hash    = mi_abi_mod_hash (mi_abi_hashes iface)
    
    814 813
              new_decl_hash   = mi_hash_fn  iface
    
    815 814
              reason = ModuleChanged (moduleName mod)
    
    816 815
     
    
    ... ... @@ -864,7 +863,7 @@ checkModUsage fc UsageDirectory{ usg_dir_path = dir,
    864 863
     -- Does this require recompilation?
    
    865 864
     --
    
    866 865
     -- See Note [When to recompile when export lists change?]
    
    867
    -checkHomeModImport :: Logger -> RecompReason -> Maybe HomeModImport -> ModIface -> IO RecompileRequired
    
    866
    +checkHomeModImport :: Logger -> RecompReason -> Maybe HomeModImport -> RetainedModIface -> IO RecompileRequired
    
    868 867
     checkHomeModImport _ _ Nothing _ = return UpToDate
    
    869 868
     checkHomeModImport logger reason
    
    870 869
       (Just (HomeModImport old_orphan_like_hash old_avails))
    
    ... ... @@ -901,8 +900,8 @@ checkHomeModImport logger reason
    901 900
                           2 (ppr changes)
    
    902 901
                      return $ needsRecompileBecause reason
    
    903 902
       where
    
    904
    -    new_orphan_like_hash = mi_orphan_like_hash iface
    
    905
    -    new_avails_hash      = mi_export_avails_hash iface
    
    903
    +    new_orphan_like_hash = mi_abi_orphan_like_hash (mi_abi_hashes iface)
    
    904
    +    new_avails_hash      = mi_abi_export_avails_hash (mi_abi_hashes iface)
    
    906 905
         new_exports          = mi_exports iface
    
    907 906
     
    
    908 907
     -- | The exported avails of a module have changed. Should this cause recompilation
    
    ... ... @@ -1299,8 +1298,6 @@ addAbiHashes hsc_env info
    1299 1298
               = iface_public
    
    1300 1299
           -- And these fields of deps should be in IfacePublic, but in good time.
    
    1301 1300
           Dependencies _ _ _ sig_mods trusted_pkgs boot_mods orph_mods fis_mods  = deps
    
    1302
    -      decl_warn_fn = mkIfaceDeclWarnCache (fromIfaceWarnings warns)
    
    1303
    -      export_warn_fn = mkIfaceExportWarnCache (fromIfaceWarnings $ warns)
    
    1304 1301
           fix_fn = mkIfaceFixCache fixities
    
    1305 1302
     
    
    1306 1303
           this_mod = mi_mod_info_module info
    
    ... ... @@ -1535,10 +1532,10 @@ addAbiHashes hsc_env info
    1535 1532
           }
    
    1536 1533
     
    
    1537 1534
         caches = IfaceCache
    
    1538
    -      { mi_cache_decl_warn_fn = decl_warn_fn
    
    1539
    -      , mi_cache_export_warn_fn = export_warn_fn
    
    1535
    +      { mi_cache_decl_warn_fn = ()
    
    1536
    +      , mi_cache_export_warn_fn = ()
    
    1540 1537
           , mi_cache_fix_fn = fix_fn
    
    1541
    -      , mi_cache_hash_fn = lookupOccEnv local_env
    
    1538
    +      , mi_cache_hash_fn = ()
    
    1542 1539
           }
    
    1543 1540
       return (final_iface_exts, caches, decls_w_hashes)
    
    1544 1541
       where
    
    ... ... @@ -1617,7 +1614,7 @@ getOrphanHashes hsc_env mods = do
    1617 1614
         get_orph_hash mod = do
    
    1618 1615
               iface <- initIfaceLoad hsc_env . withIfaceErr ctx
    
    1619 1616
                                 $ loadInterface (text "getOrphanHashes") mod ImportBySystem
    
    1620
    -          return (mi_orphan_hash iface)
    
    1617
    +          return (mi_abi_orphan_hash (mi_abi_hashes iface))
    
    1621 1618
     
    
    1622 1619
       mapM get_orph_hash mods
    
    1623 1620
     
    

  • compiler/GHC/Rename/Names.hs
    ... ... @@ -517,7 +517,7 @@ renamePkgQual unit_env mn mb_pkg = case mb_pkg of
    517 517
     -- interface, but without 'imp_mods'.
    
    518 518
     calculateAvails :: HomeUnit
    
    519 519
                     -> S.Set UnitId
    
    520
    -                -> ModIface
    
    520
    +                -> RetainedModIface
    
    521 521
                     -> IsSafeImport
    
    522 522
                     -> IsBootInterface
    
    523 523
                     -> ImportedBy
    
    ... ... @@ -525,8 +525,8 @@ calculateAvails :: HomeUnit
    525 525
     calculateAvails home_unit other_home_units iface mod_safe' want_boot imported_by =
    
    526 526
       let imp_mod    = mi_module iface
    
    527 527
           imp_sem_mod= mi_semantic_module iface
    
    528
    -      orph_iface = mi_orphan iface
    
    529
    -      has_finsts = mi_finsts iface
    
    528
    +      orph_iface = mi_abi_orphan (mi_abi_hashes iface)
    
    529
    +      has_finsts = mi_abi_finsts (mi_abi_hashes iface)
    
    530 530
           deps       = mi_deps iface
    
    531 531
           trust      = getSafeMode $ mi_trust iface
    
    532 532
           trust_pkg  = mi_trust_pkg iface
    
    ... ... @@ -1209,7 +1209,7 @@ gresFromAvail hsc_env prov avail =
    1209 1209
     gresFromAvails :: HscEnv -> Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt]
    
    1210 1210
     gresFromAvails hsc_env prov = concatMap (gresFromAvail hsc_env prov)
    
    1211 1211
     
    
    1212
    -importsFromIface :: HscEnv -> ModIface -> ImpDeclSpec -> Maybe NameSet -> GlobalRdrEnv
    
    1212
    +importsFromIface :: HscEnv -> RetainedModIface -> ImpDeclSpec -> Maybe NameSet -> GlobalRdrEnv
    
    1213 1213
     importsFromIface hsc_env iface decl_spec hidden = mkGlobalRdrEnv $ case hidden of
    
    1214 1214
         Nothing -> all_gres
    
    1215 1215
         Just hidden_names -> filter (not . (`elemNameSet` hidden_names) . greName) all_gres
    
    ... ... @@ -1225,7 +1225,7 @@ rnNamespaceSpecifier (DataNamespaceSpecifier x) = DataNamespaceSpecifier x
    1225 1225
     filterImports
    
    1226 1226
         :: HasDebugCallStack
    
    1227 1227
         => HscEnv
    
    1228
    -    -> ModIface
    
    1228
    +    -> RetainedModIface
    
    1229 1229
         -> ImpDeclSpec
    
    1230 1230
              -- ^ Import spec
    
    1231 1231
         -> Maybe (ImportListInterpretation, [LIE GhcPs])
    
    ... ... @@ -2327,7 +2327,7 @@ getMinimalImports ie_decls
    2327 2327
           where
    
    2328 2328
             doc = text "Compute minimal imports for" <+> ppr decl
    
    2329 2329
     
    
    2330
    -    to_ie :: GlobalRdrEnv -> ModIface -> AvailInfo -> RnM [IE GhcRn]
    
    2330
    +    to_ie :: GlobalRdrEnv -> RetainedModIface -> AvailInfo -> RnM [IE GhcRn]
    
    2331 2331
         -- The main trick here is that if we're importing all the constructors
    
    2332 2332
         -- we want to say "T(..)", but if we're importing only a subset we want
    
    2333 2333
         -- to say "T(A,B,C)".  So we have to find out what the module exports.
    
    ... ... @@ -2529,7 +2529,7 @@ DRFPatSynExport for a test of this.
    2529 2529
     -}
    
    2530 2530
     
    
    2531 2531
     badImportItemErr
    
    2532
    -  :: ModIface -> ImpDeclSpec -> IE GhcPs
    
    2532
    +  :: RetainedModIface -> ImpDeclSpec -> IE GhcPs
    
    2533 2533
       -> IsSubordinateError
    
    2534 2534
       -> [AvailInfo]
    
    2535 2535
       -> TcRn (NonEmpty ImportLookupReason)
    

  • compiler/GHC/Rename/Utils.hs
    ... ... @@ -534,7 +534,7 @@ warnIfDeclDeprecated gre@(GRE { gre_imp = iss })
    534 534
         definedMod = moduleName $ assertPpr (isExternalName name) (ppr name) (nameModule name)
    
    535 535
         doc = text "The name" <+> quotes (ppr occ) <+> text "is mentioned explicitly"
    
    536 536
     
    
    537
    -lookupImpDeclDeprec :: ModIface -> GlobalRdrElt -> Maybe (WarningTxt GhcRn)
    
    537
    +lookupImpDeclDeprec :: RetainedModIface -> GlobalRdrElt -> Maybe (WarningTxt GhcRn)
    
    538 538
     lookupImpDeclDeprec iface gre
    
    539 539
       -- Bleat if the thing, or its parent, is warn'd
    
    540 540
       = mi_decl_warn_fn iface (greOccName gre) `mplus`
    

  • compiler/GHC/Runtime/Loader.hs
    ... ... @@ -190,7 +190,7 @@ checkExternalInterpreter hsc_env = case interpInstance <$> hsc_interp hsc_env of
    190 190
         -> throwIO (InstallationError "Plugins require -fno-external-interpreter")
    
    191 191
       _ -> pure ()
    
    192 192
     
    
    193
    -loadPlugin' :: OccName -> Name -> HscEnv -> ModuleName -> IO (a, ModIface, [LinkableUsage], PkgsLoaded)
    
    193
    +loadPlugin' :: OccName -> Name -> HscEnv -> ModuleName -> IO (a, RetainedModIface, [LinkableUsage], PkgsLoaded)
    
    194 194
     loadPlugin' occ_name plugin_name hsc_env mod_name
    
    195 195
       = do { let plugin_rdr_name = mkRdrQual mod_name occ_name
    
    196 196
                  dflags = hsc_dflags hsc_env
    
    ... ... @@ -341,7 +341,7 @@ lessUnsafeCoerce logger context what = do
    341 341
     -- Need the module as well to record information in the interface file
    
    342 342
     lookupRdrNameInModuleForPlugins :: HasDebugCallStack
    
    343 343
                                     => HscEnv -> ModuleName -> RdrName
    
    344
    -                                -> IO (Maybe (Name, ModIface))
    
    344
    +                                -> IO (Maybe (Name, RetainedModIface))
    
    345 345
     lookupRdrNameInModuleForPlugins hsc_env mod_name rdr_name = do
    
    346 346
         let dflags     = hsc_dflags hsc_env
    
    347 347
         -- First find the unit the module resides in by searching exposed units and home modules
    

  • compiler/GHC/Tc/Errors/Ppr.hs
    ... ... @@ -6400,7 +6400,7 @@ pprImportLookup :: ImportLookupReason -> SDoc
    6400 6400
     pprImportLookup = \case
    
    6401 6401
       ImportLookupBad k iface decl_spec ie _exts ->
    
    6402 6402
         let
    
    6403
    -      pprImpDeclSpec :: ModIface -> ImpDeclSpec -> SDoc
    
    6403
    +      pprImpDeclSpec :: RetainedModIface -> ImpDeclSpec -> SDoc
    
    6404 6404
           pprImpDeclSpec iface decl_spec =
    
    6405 6405
             quotes (ppr (moduleName $ is_mod decl_spec)) <+> case mi_boot iface of
    
    6406 6406
                 IsBoot  -> text "(hi-boot interface)"
    

  • compiler/GHC/Tc/Errors/Types.hs
    ... ... @@ -216,7 +216,7 @@ import GHC.Types.DefaultEnv (ClassDefaults)
    216 216
     
    
    217 217
     import GHC.Unit.Types (Module, ModuleName)
    
    218 218
     import GHC.Unit.State (UnitState)
    
    219
    -import GHC.Unit.Module.ModIface (ModIface)
    
    219
    +import GHC.Unit.Module.ModIface (RetainedModIface)
    
    220 220
     
    
    221 221
     import GHC.Utils.Outputable
    
    222 222
     
    
    ... ... @@ -6650,7 +6650,7 @@ data ImportLookupReason where
    6650 6650
           T9006, T11071, T9905fail2, T5385, T10668
    
    6651 6651
       -}
    
    6652 6652
       ImportLookupBad :: BadImportKind
    
    6653
    -                  -> ModIface
    
    6653
    +                  -> RetainedModIface
    
    6654 6654
                       -> ImpDeclSpec
    
    6655 6655
                       -> IE GhcPs
    
    6656 6656
                       -> ImportLookupExtensions
    

  • compiler/GHC/Tc/Gen/Splice.hs
    ... ... @@ -1693,7 +1693,7 @@ lookupArgDoc i nm = do
    1693 1693
             _ -> pure Nothing
    
    1694 1694
     
    
    1695 1695
     -- | Returns the module a Name belongs to, if it is isn't local.
    
    1696
    -getExternalModIface :: Name -> TcM (Maybe ModIface)
    
    1696
    +getExternalModIface :: Name -> TcM (Maybe RetainedModIface)
    
    1697 1697
     getExternalModIface nm = do
    
    1698 1698
       isLocal <- nameIsLocalOrFrom <$> getModule <*> pure nm
    
    1699 1699
       if isLocal
    

  • compiler/GHC/Tc/Instance/Family.hs
    ... ... @@ -308,7 +308,7 @@ checkFamInstConsistency directlyImpMods
    308 308
                      ifc <- modIface mod
    
    309 309
                      deps <- dep_finsts . mi_deps <$> modIface mod
    
    310 310
                      pure $
    
    311
    -                   if mi_finsts ifc
    
    311
    +                   if mi_abi_finsts (mi_abi_hashes ifc)
    
    312 312
                           then mod:deps
    
    313 313
                           else deps
    
    314 314
     
    

  • compiler/GHC/Tc/Module.hs
    ... ... @@ -2968,7 +2968,7 @@ externaliseAndTidyId this_mod id
    2968 2968
     -- a package module with an interface on disk.  If neither of these is
    
    2969 2969
     -- true, then the result will be an error indicating the interface
    
    2970 2970
     -- could not be found.
    
    2971
    -getModuleInterface :: HscEnv -> Module -> IO (Messages TcRnMessage, Maybe ModIface)
    
    2971
    +getModuleInterface :: HscEnv -> Module -> IO (Messages TcRnMessage, Maybe RetainedModIface)
    
    2972 2972
     getModuleInterface hsc_env mod
    
    2973 2973
       = runTcInteractive NoTcMPlugins hsc_env $
    
    2974 2974
         loadModuleInterface (text "getModuleInterface") mod
    

  • compiler/GHC/Unit/External.hs
    ... ... @@ -49,7 +49,7 @@ type PackageAnnEnv = AnnEnv
    49 49
     type PackageCompleteMatches  = CompleteMatches
    
    50 50
     
    
    51 51
     -- | Helps us find information about modules in the imported packages
    
    52
    -type PackageIfaceTable = ModuleEnv ModIface
    
    52
    +type PackageIfaceTable = ModuleEnv RetainedModIface
    
    53 53
             -- Domain = modules in the imported packages
    
    54 54
     
    
    55 55
     -- | Constructs an empty PackageIfaceTable
    

  • compiler/GHC/Unit/Module/ModIface.hs
    ... ... @@ -2,6 +2,7 @@
    2 2
     {-# LANGUAGE UndecidableInstances #-}
    
    3 3
     {-# LANGUAGE PatternSynonyms #-}
    
    4 4
     {-# LANGUAGE DeriveAnyClass #-}
    
    5
    +{-# LANGUAGE RecordWildCards #-}
    
    5 6
     
    
    6 7
     module GHC.Unit.Module.ModIface
    
    7 8
        ( ModIface
    
    ... ... @@ -68,19 +69,35 @@ module GHC.Unit.Module.ModIface
    68 69
        , set_mi_fix_fn
    
    69 70
        , set_mi_hash_fn
    
    70 71
        , completePartialModIface
    
    71
    -   , IfaceBinHandle(..)
    
    72
    +   , retainedModIface
    
    73
    +   , IfaceBinHandle
    
    72 74
        , PartialModIface
    
    75
    +   , RetainedModIface
    
    73 76
        , IfaceAbiHashes (..)
    
    74 77
        , IfaceSelfRecomp (..)
    
    75
    -   , IfaceCache (..)
    
    78
    +   , IfaceCache_ (..)
    
    76 79
        , IfaceSimplifiedCore (..)
    
    77 80
        , withSelfRecomp
    
    78
    -   , IfaceDeclExts
    
    79
    -   , IfaceAbiHashesExts
    
    81
    +   , IfaceHashData
    
    82
    +   , IfaceSelfRecompData
    
    83
    +   , IfaceSimplifiedCoreData
    
    84
    +   , IfaceExtFieldsData
    
    85
    +   , IfaceAnnotationsData
    
    86
    +   , IfaceDeclsData
    
    87
    +   , IfaceDefaultsData
    
    88
    +   , IfaceClsInstsData
    
    89
    +   , IfaceFamInstsData
    
    90
    +   , IfaceRulesData
    
    91
    +   , IfaceCompleteMatchesData
    
    92
    +   , IfaceAbiHashesData
    
    80 93
        , IfaceExport
    
    81 94
        , IfacePublic_(..)
    
    82 95
        , IfacePublic
    
    83 96
        , PartialIfacePublic
    
    97
    +   , RetainedIfacePublic
    
    98
    +   , IfaceCache
    
    99
    +   , PartialIfaceCache
    
    100
    +   , RetainedIfaceCache
    
    84 101
        , IfaceModInfo(..)
    
    85 102
        , WhetherHasOrphans
    
    86 103
        , WhetherHasFamInst
    
    ... ... @@ -106,7 +123,9 @@ module GHC.Unit.Module.ModIface
    106 123
        , mi_orphan_hash
    
    107 124
        , renameFreeHoles
    
    108 125
        , emptyPartialModIface
    
    126
    +   , emptyModIface
    
    109 127
        , emptyFullModIface
    
    128
    +   , emptyRetainedModIface
    
    110 129
        , mkIfaceHashCache
    
    111 130
        , emptyIfaceHashCache
    
    112 131
        , forceModIface
    
    ... ... @@ -147,16 +166,18 @@ import GHC.Utils.Binary
    147 166
     
    
    148 167
     import Control.DeepSeq
    
    149 168
     import Control.Exception
    
    169
    +import Data.Void (Void)
    
    150 170
     
    
    151 171
     
    
    152 172
     {- Note [Interface file stages]
    
    153 173
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    154 174
     
    
    155
    -Interface files have two possible stages.
    
    175
    +Interface files have three possible stages.
    
    156 176
     
    
    157 177
     * A partial stage built from the result of the core pipeline.
    
    158
    -* A fully instantiated form. Which also includes fingerprints and
    
    178
    +* A fully instantiated form, which also includes fingerprints and
    
    159 179
       potentially information provided by backends.
    
    180
    +* A form for retention in the EPS.
    
    160 181
     
    
    161 182
     We can build a full interface file two ways:
    
    162 183
     * Directly from a partial one:
    
    ... ... @@ -167,9 +188,15 @@ We can build a full interface file two ways:
    167 188
     
    
    168 189
     type PartialModIface = ModIface_ 'ModIfaceCore
    
    169 190
     type ModIface = ModIface_ 'ModIfaceFinal
    
    191
    +type RetainedModIface = ModIface_ 'ModIfaceRetained
    
    170 192
     
    
    171 193
     type PartialIfacePublic = IfacePublic_ 'ModIfaceCore
    
    172 194
     type IfacePublic = IfacePublic_ 'ModIfaceFinal
    
    195
    +type RetainedIfacePublic = IfacePublic_ 'ModIfaceRetained
    
    196
    +
    
    197
    +type PartialIfaceCache = IfaceCache_ 'ModIfaceCore
    
    198
    +type IfaceCache = IfaceCache_ 'ModIfaceFinal
    
    199
    +type RetainedIfaceCache = IfaceCache_ 'ModIfaceRetained
    
    173 200
     
    
    174 201
     -- | Extends a PartialModIface with hashes of the ABI.
    
    175 202
     --
    
    ... ... @@ -196,14 +223,14 @@ data IfaceAbiHashes = IfaceAbiHashes
    196 223
         -- NOT transitive
    
    197 224
       }
    
    198 225
     
    
    199
    -data IfaceCache = IfaceCache
    
    200
    -  { mi_cache_decl_warn_fn :: !(OccName -> Maybe (WarningTxt GhcRn))
    
    226
    +data IfaceCache_ phase = IfaceCache
    
    227
    +  { mi_cache_decl_warn_fn :: !(IfaceDeclWarningCacheData phase)
    
    201 228
         -- ^ Cached lookup for 'mi_warns' for declaration deprecations
    
    202
    -  , mi_cache_export_warn_fn :: !(Name -> Maybe (WarningTxt GhcRn))
    
    229
    +  , mi_cache_export_warn_fn :: !(IfaceExportWarningCacheData phase)
    
    203 230
         -- ^ Cached lookup for 'mi_warns' for export deprecations
    
    204
    -  , mi_cache_fix_fn :: !(OccName -> Maybe Fixity)
    
    231
    +  , mi_cache_fix_fn :: !(IfaceFixityCacheData phase)
    
    205 232
         -- ^ Cached lookup for 'mi_fixities'
    
    206
    -  , mi_cache_hash_fn :: !(OccName -> Maybe (OccName, Fingerprint))
    
    233
    +  , mi_cache_hash_fn :: !(IfaceHashCacheData phase)
    
    207 234
         -- ^ Cached lookup for 'mi_decls'. The @Nothing@ in 'mi_hash_fn' means that
    
    208 235
         -- the thing isn't in decls. It's useful to know that when seeing if we are
    
    209 236
         -- up to date wrt. the old interface. The 'OccName' is the parent of the
    
    ... ... @@ -212,34 +239,103 @@ data IfaceCache = IfaceCache
    212 239
     
    
    213 240
     data ModIfacePhase
    
    214 241
       = ModIfaceCore
    
    215
    -  -- ^ Partial interface built based on output of core pipeline.
    
    242
    +    -- ^ Partial interface built from the output of the core pipeline
    
    216 243
       | ModIfaceFinal
    
    217
    -
    
    218
    --- | Selects a IfaceDecl representation.
    
    219
    --- For fully instantiated interfaces we also maintain
    
    220
    --- a fingerprint, which is used for recompilation checks.
    
    221
    -type family IfaceDeclExts (phase :: ModIfacePhase) = decl | decl -> phase where
    
    222
    -  IfaceDeclExts 'ModIfaceCore = IfaceDecl
    
    223
    -  IfaceDeclExts 'ModIfaceFinal = (Fingerprint, IfaceDecl)
    
    224
    -
    
    225
    -type family IfaceAbiHashesExts (phase :: ModIfacePhase) = bk | bk -> phase where
    
    226
    -  IfaceAbiHashesExts 'ModIfaceCore = ()
    
    227
    -  IfaceAbiHashesExts 'ModIfaceFinal = IfaceAbiHashes
    
    244
    +    -- ^ Complete interface
    
    245
    +  | ModIfaceRetained
    
    246
    +    -- ^ Interface shrunk to the parts that may be retained
    
    228 247
     
    
    229 248
     -- | In-memory byte array representation of a 'ModIface'.
    
    230 249
     --
    
    231 250
     -- See Note [Sharing of ModIface] for why we need this.
    
    232
    -data IfaceBinHandle (phase :: ModIfacePhase) where
    
    233
    -  -- | A partial 'ModIface' cannot be serialised to disk.
    
    234
    -  PartialIfaceBinHandle :: IfaceBinHandle 'ModIfaceCore
    
    235
    -  -- | Optional 'FullBinData' that can be serialised to disk directly.
    
    236
    -  --
    
    237
    -  -- See Note [Private fields in ModIface] for when this fields needs to be cleared
    
    238
    -  -- (e.g., set to 'Nothing').
    
    239
    -  FullIfaceBinHandle :: !(Strict.Maybe FullBinData) -> IfaceBinHandle 'ModIfaceFinal
    
    240
    -
    
    241
    -
    
    242
    -withSelfRecomp :: ModIface_ phase -> r -> (IfaceSelfRecomp -> r) -> r
    
    251
    +type family IfaceBinHandle (phase :: ModIfacePhase) where
    
    252
    +  IfaceBinHandle 'ModIfaceCore     = Void
    
    253
    +  IfaceBinHandle 'ModIfaceFinal    = FullBinData
    
    254
    +  IfaceBinHandle 'ModIfaceRetained = Void
    
    255
    +
    
    256
    +type family IfaceHashData (phase :: ModIfacePhase) where
    
    257
    +  IfaceHashData 'ModIfaceCore     = ()
    
    258
    +  IfaceHashData 'ModIfaceFinal    = Fingerprint
    
    259
    +  IfaceHashData 'ModIfaceRetained = ()
    
    260
    +
    
    261
    +type family IfaceSelfRecompData (phase :: ModIfacePhase) where
    
    262
    +  IfaceSelfRecompData 'ModIfaceCore     = Maybe IfaceSelfRecomp
    
    263
    +  IfaceSelfRecompData 'ModIfaceFinal    = Maybe IfaceSelfRecomp
    
    264
    +  IfaceSelfRecompData 'ModIfaceRetained = ()
    
    265
    +
    
    266
    +type family IfaceSimplifiedCoreData (phase :: ModIfacePhase) where
    
    267
    +  IfaceSimplifiedCoreData 'ModIfaceCore     = Maybe IfaceSimplifiedCore
    
    268
    +  IfaceSimplifiedCoreData 'ModIfaceFinal    = Maybe IfaceSimplifiedCore
    
    269
    +  IfaceSimplifiedCoreData 'ModIfaceRetained = ()
    
    270
    +
    
    271
    +type family IfaceExtFieldsData (phase :: ModIfacePhase) where
    
    272
    +  IfaceExtFieldsData 'ModIfaceCore     = ExtensibleFields
    
    273
    +  IfaceExtFieldsData 'ModIfaceFinal    = ExtensibleFields
    
    274
    +  IfaceExtFieldsData 'ModIfaceRetained = ()
    
    275
    +
    
    276
    +type family IfaceAnnotationsData (phase :: ModIfacePhase) where
    
    277
    +  IfaceAnnotationsData 'ModIfaceCore     = [IfaceAnnotation]
    
    278
    +  IfaceAnnotationsData 'ModIfaceFinal    = [IfaceAnnotation]
    
    279
    +  IfaceAnnotationsData 'ModIfaceRetained = ()
    
    280
    +
    
    281
    +-- | The fingerprint in the 'ModIfaceFinal' case is used for recompilation
    
    282
    +--   checks.
    
    283
    +type family IfaceDeclsData (phase :: ModIfacePhase) where
    
    284
    +  IfaceDeclsData 'ModIfaceCore     = [IfaceDecl]
    
    285
    +  IfaceDeclsData 'ModIfaceFinal    = [(Fingerprint, IfaceDecl)]
    
    286
    +  IfaceDeclsData 'ModIfaceRetained = ()
    
    287
    +
    
    288
    +type family IfaceDefaultsData (phase :: ModIfacePhase) where
    
    289
    +  IfaceDefaultsData 'ModIfaceCore     = [IfaceDefault]
    
    290
    +  IfaceDefaultsData 'ModIfaceFinal    = [IfaceDefault]
    
    291
    +  IfaceDefaultsData 'ModIfaceRetained = ()
    
    292
    +
    
    293
    +type family IfaceClsInstsData (phase :: ModIfacePhase) where
    
    294
    +  IfaceClsInstsData 'ModIfaceCore     = [IfaceClsInst]
    
    295
    +  IfaceClsInstsData 'ModIfaceFinal    = [IfaceClsInst]
    
    296
    +  IfaceClsInstsData 'ModIfaceRetained = ()
    
    297
    +
    
    298
    +type family IfaceFamInstsData (phase :: ModIfacePhase) where
    
    299
    +  IfaceFamInstsData 'ModIfaceCore     = [IfaceFamInst]
    
    300
    +  IfaceFamInstsData 'ModIfaceFinal    = [IfaceFamInst]
    
    301
    +  IfaceFamInstsData 'ModIfaceRetained = ()
    
    302
    +
    
    303
    +type family IfaceRulesData (phase :: ModIfacePhase) where
    
    304
    +  IfaceRulesData 'ModIfaceCore     = [IfaceRule]
    
    305
    +  IfaceRulesData 'ModIfaceFinal    = [IfaceRule]
    
    306
    +  IfaceRulesData 'ModIfaceRetained = ()
    
    307
    +
    
    308
    +type family IfaceCompleteMatchesData (phase :: ModIfacePhase) where
    
    309
    +  IfaceCompleteMatchesData 'ModIfaceCore     = [IfaceCompleteMatch]
    
    310
    +  IfaceCompleteMatchesData 'ModIfaceFinal    = [IfaceCompleteMatch]
    
    311
    +  IfaceCompleteMatchesData 'ModIfaceRetained = ()
    
    312
    +
    
    313
    +type family IfaceAbiHashesData (phase :: ModIfacePhase) where
    
    314
    +  IfaceAbiHashesData 'ModIfaceCore     = ()
    
    315
    +  IfaceAbiHashesData 'ModIfaceFinal    = IfaceAbiHashes
    
    316
    +  IfaceAbiHashesData 'ModIfaceRetained = IfaceAbiHashes
    
    317
    +
    
    318
    +type family IfaceDeclWarningCacheData (phase :: ModIfacePhase) where
    
    319
    +  IfaceDeclWarningCacheData 'ModIfaceCore     = ()
    
    320
    +  IfaceDeclWarningCacheData 'ModIfaceFinal    = ()
    
    321
    +  IfaceDeclWarningCacheData 'ModIfaceRetained = OccName -> Maybe (WarningTxt GhcRn)
    
    322
    +
    
    323
    +type family IfaceExportWarningCacheData (phase :: ModIfacePhase) where
    
    324
    +  IfaceExportWarningCacheData 'ModIfaceCore     = ()
    
    325
    +  IfaceExportWarningCacheData 'ModIfaceFinal    = ()
    
    326
    +  IfaceExportWarningCacheData 'ModIfaceRetained = Name -> Maybe (WarningTxt GhcRn)
    
    327
    +
    
    328
    +type family IfaceFixityCacheData (phase :: ModIfacePhase) where
    
    329
    +  IfaceFixityCacheData 'ModIfaceCore     = ()
    
    330
    +  IfaceFixityCacheData 'ModIfaceFinal    = OccName -> Maybe Fixity
    
    331
    +  IfaceFixityCacheData 'ModIfaceRetained = OccName -> Maybe Fixity
    
    332
    +
    
    333
    +type family IfaceHashCacheData (phase :: ModIfacePhase) where
    
    334
    +  IfaceHashCacheData 'ModIfaceCore     = ()
    
    335
    +  IfaceHashCacheData 'ModIfaceFinal    = ()
    
    336
    +  IfaceHashCacheData 'ModIfaceRetained = OccName -> Maybe (OccName, Fingerprint)
    
    337
    +
    
    338
    +withSelfRecomp :: ModIface -> r -> (IfaceSelfRecomp -> r) -> r
    
    243 339
     withSelfRecomp iface nk jk =
    
    244 340
       case mi_self_recomp_info iface of
    
    245 341
         Nothing -> nk
    
    ... ... @@ -258,12 +354,23 @@ withSelfRecomp iface nk jk =
    258 354
     -- fields.
    
    259 355
     data ModIface_ (phase :: ModIfacePhase)
    
    260 356
       = PrivateModIface {
    
    261
    -        mi_hi_bytes_ :: !(IfaceBinHandle phase),
    
    262
    -                -- ^ A serialised in-memory buffer of this 'ModIface'.
    
    263
    -                -- If this handle is given, we can avoid serialising the 'ModIface'
    
    264
    -                -- when writing this 'ModIface' to disk, and write this buffer to disk instead.
    
    265
    -                -- See Note [Sharing of ModIface].
    
    266
    -        mi_iface_hash_  :: Fingerprint, -- A hash of the whole interface
    
    357
    +        mi_hi_bytes_ :: !(Strict.Maybe (IfaceBinHandle phase)),
    
    358
    +                -- ^ Optionally an in-memory buffer that contains the
    
    359
    +                --   serialization of this 'ModIface'. If such a buffer is
    
    360
    +                --   present, we can avoid serialising the 'ModIface' when
    
    361
    +                --   writing it to disk and write this buffer instead. See
    
    362
    +                --   Note [Sharing of ModIface] and
    
    363
    +                --   Note [Private fields in ModIface].
    
    364
    +                --
    
    365
    +                --   Only in the 'ModIfaceFinal' phase, there can be a buffer
    
    366
    +                --   with the serialization. Both @IfaceBinHandle 'ModIfaceCore@
    
    367
    +                --   and @IfaceBinHandle 'ModIfaceRetained@ are defined to be
    
    368
    +                --   'Void', so that the 'mi_hi_bytes' field gets the type
    
    369
    +                --   @Strict.Maybe Void@. This type is isomorphic to '()', even
    
    370
    +                --   when taking partially defined values into account, because
    
    371
    +                --   @Strict.Just undefined@ is @undefined@ and so @Nothing@ and
    
    372
    +                --   @undefined@ are the only inhabitants of that type.
    
    373
    +        mi_iface_hash_  :: IfaceHashData phase, -- A hash of the whole interface
    
    267 374
     
    
    268 375
             mi_mod_info_     :: IfaceModInfo,
    
    269 376
                     -- ^ Meta information about the module the interface file is for
    
    ... ... @@ -279,11 +386,11 @@ data ModIface_ (phase :: ModIfacePhase)
    279 386
                     -- importing this module. The main, original part of an interface.
    
    280 387
     
    
    281 388
     
    
    282
    -        mi_self_recomp_ :: Maybe IfaceSelfRecomp,
    
    389
    +        mi_self_recomp_ :: IfaceSelfRecompData phase,
    
    283 390
                     -- ^ Information needed for checking self-recompilation.
    
    284 391
                     -- See Note [Self recompilation information in interface files]
    
    285 392
     
    
    286
    -        mi_simplified_core_ :: Maybe IfaceSimplifiedCore,
    
    393
    +        mi_simplified_core_ :: IfaceSimplifiedCoreData phase,
    
    287 394
                     -- ^ The part of the interface written when `-fwrite-if-simplified-core` is enabled.
    
    288 395
                     -- These parts are used to restart bytecode generation.
    
    289 396
     
    
    ... ... @@ -301,7 +408,7 @@ data ModIface_ (phase :: ModIfacePhase)
    301 408
                     -- defined by the user).  Used for GHCi and for inspecting
    
    302 409
                     -- the contents of modules via the GHC API only.
    
    303 410
     
    
    304
    -        mi_ext_fields_ :: ExtensibleFields
    
    411
    +        mi_ext_fields_ :: IfaceExtFieldsData phase
    
    305 412
                     -- ^ Additional optional fields, where the Map key represents
    
    306 413
                     -- the field name, resulting in a (size, serialized data) pair.
    
    307 414
                     -- Because the data is intended to be serialized through the
    
    ... ... @@ -334,12 +441,12 @@ data IfacePublic_ phase = IfacePublic {
    334 441
                     -- ^ Warnings
    
    335 442
                     -- NOT STRICT!  we read this field lazily from the interface file
    
    336 443
     
    
    337
    -        mi_anns_     :: [IfaceAnnotation],
    
    444
    +        mi_anns_     :: IfaceAnnotationsData phase,
    
    338 445
                     -- ^ Annotations
    
    339 446
                     -- NOT STRICT!  we read this field lazily from the interface file
    
    340 447
     
    
    341 448
     
    
    342
    -        mi_decls_    :: [IfaceDeclExts phase],
    
    449
    +        mi_decls_    :: IfaceDeclsData phase,
    
    343 450
                     -- ^ Type, class and variable declarations
    
    344 451
                     -- The hash of an Id changes if its fixity or deprecations change
    
    345 452
                     --      (as well as its type of course)
    
    ... ... @@ -347,14 +454,14 @@ data IfacePublic_ phase = IfacePublic {
    347 454
                     -- the hash of the parent class/tycon changes
    
    348 455
     
    
    349 456
     
    
    350
    -        mi_defaults_ :: [IfaceDefault],
    
    457
    +        mi_defaults_ :: IfaceDefaultsData phase,
    
    351 458
                     -- ^ default declarations exported by the module
    
    352 459
     
    
    353 460
     
    
    354 461
                     -- Instance declarations and rules
    
    355
    -        mi_insts_       :: [IfaceClsInst],     -- ^ Sorted class instance
    
    356
    -        mi_fam_insts_   :: [IfaceFamInst],  -- ^ Sorted family instances
    
    357
    -        mi_rules_       :: [IfaceRule],     -- ^ Sorted rules
    
    462
    +        mi_insts_       :: IfaceClsInstsData phase, -- ^ Sorted class instance
    
    463
    +        mi_fam_insts_   :: IfaceFamInstsData phase, -- ^ Sorted family instances
    
    464
    +        mi_rules_       :: IfaceRulesData phase,    -- ^ Sorted rules
    
    358 465
     
    
    359 466
     
    
    360 467
             mi_trust_     :: IfaceTrustInfo,
    
    ... ... @@ -367,20 +474,20 @@ data IfacePublic_ phase = IfacePublic {
    367 474
                     -- itself) but imports some trustworthy modules from its own
    
    368 475
                     -- package (which does require its own package be trusted).
    
    369 476
                     -- See Note [Trust Own Package] in GHC.Rename.Names
    
    370
    -        mi_complete_matches_ :: [IfaceCompleteMatch],
    
    477
    +        mi_complete_matches_ :: IfaceCompleteMatchesData phase,
    
    371 478
                     -- ^ {-# COMPLETE #-} declarations
    
    372 479
     
    
    373
    -        mi_caches_ :: IfaceCache,
    
    480
    +        mi_caches_ :: IfaceCache_ phase,
    
    374 481
                     -- ^ Cached lookups of some parts of mi_public
    
    375 482
     
    
    376
    -        mi_abi_hashes_ :: (IfaceAbiHashesExts phase)
    
    483
    +        mi_abi_hashes_ :: IfaceAbiHashesData phase
    
    377 484
                     -- ^ Either `()` or `IfaceAbiHashes` for
    
    378 485
                     -- a fully instantiated interface.
    
    379 486
                     -- These fields are hashes of different parts of the public interface.
    
    380 487
     }
    
    381 488
     
    
    382 489
     mkIfacePublic :: [IfaceExport]
    
    383
    -                  -> [IfaceDeclExts 'ModIfaceFinal]
    
    490
    +                  -> [(Fingerprint, IfaceDecl)]
    
    384 491
                       -> [(OccName, Fixity)]
    
    385 492
                       -> IfaceWarnings
    
    386 493
                       -> [IfaceAnnotation]
    
    ... ... @@ -407,10 +514,10 @@ mkIfacePublic exports decls fixities warns anns defaults insts fam_insts rules t
    407 514
       mi_trust_pkg_ = trust_pkg,
    
    408 515
       mi_complete_matches_ = complete_matches,
    
    409 516
       mi_caches_ = IfaceCache {
    
    410
    -    mi_cache_decl_warn_fn = mkIfaceDeclWarnCache $ fromIfaceWarnings warns,
    
    411
    -    mi_cache_export_warn_fn = mkIfaceExportWarnCache $ fromIfaceWarnings warns,
    
    517
    +    mi_cache_decl_warn_fn = (),
    
    518
    +    mi_cache_export_warn_fn = (),
    
    412 519
         mi_cache_fix_fn = mkIfaceFixCache fixities,
    
    413
    -    mi_cache_hash_fn = mkIfaceHashCache decls
    
    520
    +    mi_cache_hash_fn = ()
    
    414 521
       },
    
    415 522
       mi_abi_hashes_ = abi_hashes
    
    416 523
     }
    
    ... ... @@ -501,22 +608,22 @@ That's why in GHC.Driver.Main.hscMaybeWriteIface there is the call to
    501 608
     forceModIface.
    
    502 609
     -}
    
    503 610
     
    
    504
    -mi_flag_hash :: ModIface_ phase -> Maybe (FingerprintWithValue IfaceDynFlags)
    
    611
    +mi_flag_hash :: ModIface -> Maybe (FingerprintWithValue IfaceDynFlags)
    
    505 612
     mi_flag_hash = fmap mi_sr_flag_hash . mi_self_recomp_
    
    506 613
     
    
    507
    -mi_opt_hash :: ModIface_ phase -> Maybe Fingerprint
    
    614
    +mi_opt_hash :: ModIface -> Maybe Fingerprint
    
    508 615
     mi_opt_hash = fmap mi_sr_opt_hash . mi_self_recomp_
    
    509 616
     
    
    510
    -mi_hpc_hash :: ModIface_ phase -> Maybe Fingerprint
    
    617
    +mi_hpc_hash :: ModIface -> Maybe Fingerprint
    
    511 618
     mi_hpc_hash = fmap mi_sr_hpc_hash . mi_self_recomp_
    
    512 619
     
    
    513
    -mi_src_hash :: ModIface_ phase -> Maybe Fingerprint
    
    620
    +mi_src_hash :: ModIface -> Maybe Fingerprint
    
    514 621
     mi_src_hash = fmap mi_sr_src_hash . mi_self_recomp_
    
    515 622
     
    
    516
    -mi_usages :: ModIface_ phase -> Maybe [Usage]
    
    623
    +mi_usages :: ModIface -> Maybe [Usage]
    
    517 624
     mi_usages = fmap mi_sr_usages . mi_self_recomp_
    
    518 625
     
    
    519
    -mi_plugin_hash :: ModIface_ phase -> Maybe Fingerprint
    
    626
    +mi_plugin_hash :: ModIface -> Maybe Fingerprint
    
    520 627
     mi_plugin_hash = fmap mi_sr_plugin_hash . mi_self_recomp_
    
    521 628
     
    
    522 629
     -- | Accessor for the module hash of the ABI from a ModIface.
    
    ... ... @@ -547,7 +654,7 @@ mi_orphan_hash iface = mi_abi_orphan_hash (mi_abi_hashes iface)
    547 654
     
    
    548 655
     -- | Old-style accessor for whether or not the ModIface came from an hs-boot
    
    549 656
     -- file.
    
    550
    -mi_boot :: ModIface -> IsBootInterface
    
    657
    +mi_boot :: ModIface_ phase -> IsBootInterface
    
    551 658
     mi_boot iface = if mi_hsc_src iface == HsBootFile
    
    552 659
         then IsBoot
    
    553 660
         else NotBoot
    
    ... ... @@ -557,7 +664,7 @@ mi_mnwib iface = GWIB (moduleName $ mi_module iface) (mi_boot iface)
    557 664
     
    
    558 665
     -- | Lookups up a (possibly cached) fixity from a 'ModIface'. If one cannot be
    
    559 666
     -- found, 'defaultFixity' is returned instead.
    
    560
    -mi_fix :: ModIface -> OccName -> Fixity
    
    667
    +mi_fix :: RetainedModIface -> OccName -> Fixity
    
    561 668
     mi_fix iface name = mi_fix_fn iface name `orElse` defaultFixity
    
    562 669
     
    
    563 670
     -- | The semantic module for this interface; e.g., if it's a interface
    
    ... ... @@ -573,7 +680,7 @@ mi_semantic_module iface = mi_mod_info_semantic_module (mi_mod_info iface)
    573 680
     
    
    574 681
     -- | The "precise" free holes, e.g., the signatures that this
    
    575 682
     -- 'ModIface' depends on.
    
    576
    -mi_free_holes :: ModIface -> UniqDSet ModuleName
    
    683
    +mi_free_holes :: ModIface_ phase -> UniqDSet ModuleName
    
    577 684
     mi_free_holes iface =
    
    578 685
       case getModuleInstantiation (mi_module iface) of
    
    579 686
         (_, Just indef)
    
    ... ... @@ -654,7 +761,7 @@ instance Binary ModIface where
    654 761
                      -- We can't populate this field here, as we are
    
    655 762
                      -- missing the 'mi_ext_fields_' field, which is
    
    656 763
                      -- handled in 'getIfaceWithExtFields'.
    
    657
    -                 mi_hi_bytes_    = FullIfaceBinHandle Strict.Nothing
    
    764
    +                 mi_hi_bytes_    = Strict.Nothing
    
    658 765
                      })
    
    659 766
     
    
    660 767
     instance Binary IfaceModInfo where
    
    ... ... @@ -767,70 +874,109 @@ instance Binary IfaceSimplifiedCore where
    767 874
     emptyPartialModIface :: Module -> PartialModIface
    
    768 875
     emptyPartialModIface mod
    
    769 876
       = PrivateModIface
    
    770
    -      { mi_mod_info_    = emptyIfaceModInfo mod,
    
    771
    -        mi_iface_hash_  = fingerprint0,
    
    772
    -        mi_hi_bytes_    = PartialIfaceBinHandle,
    
    773
    -        mi_deps_        = noDependencies,
    
    774
    -        mi_public_      = emptyPublicModIface (),
    
    775
    -        mi_simplified_core_ = Nothing,
    
    776
    -        mi_top_env_     = IfaceTopEnv emptyDetOrdAvails [] ,
    
    777
    -        mi_docs_        = Nothing,
    
    778
    -        mi_self_recomp_ = Nothing,
    
    779
    -        mi_ext_fields_ = emptyExtensibleFields
    
    877
    +    {
    
    878
    +      mi_hi_bytes_        = Strict.Nothing,
    
    879
    +      mi_iface_hash_      = (),
    
    880
    +      mi_mod_info_        = emptyIfaceModInfo mod,
    
    881
    +      mi_deps_            = noDependencies,
    
    882
    +      mi_public_          = emptyPartialIfacePublic,
    
    883
    +      mi_self_recomp_     = Nothing,
    
    884
    +      mi_simplified_core_ = Nothing,
    
    885
    +      mi_docs_            = Nothing,
    
    886
    +      mi_top_env_         = IfaceTopEnv emptyDetOrdAvails [],
    
    887
    +      mi_ext_fields_      = emptyExtensibleFields
    
    888
    +    }
    
    889
    +  where
    
    780 890
     
    
    891
    +  emptyIfaceModInfo :: Module -> IfaceModInfo
    
    892
    +  emptyIfaceModInfo mod
    
    893
    +    = IfaceModInfo
    
    894
    +      {
    
    895
    +        mi_mod_info_module  = mod,
    
    896
    +        mi_mod_info_sig_of  = Nothing,
    
    897
    +        mi_mod_info_hsc_src = HsSrcFile
    
    781 898
           }
    
    782 899
     
    
    783
    -emptyIfaceModInfo :: Module -> IfaceModInfo
    
    784
    -emptyIfaceModInfo mod = IfaceModInfo
    
    785
    -  { mi_mod_info_module = mod
    
    786
    -  , mi_mod_info_sig_of = Nothing
    
    787
    -  , mi_mod_info_hsc_src = HsSrcFile
    
    788
    -  }
    
    789
    -
    
    900
    +  emptyPartialIfacePublic :: PartialIfacePublic
    
    901
    +  emptyPartialIfacePublic
    
    902
    +    = IfacePublic
    
    903
    +      {
    
    904
    +        mi_exports_          = [],
    
    905
    +        mi_fixities_         = [],
    
    906
    +        mi_warns_            = IfWarnSome [] [],
    
    907
    +        mi_anns_             = [],
    
    908
    +        mi_decls_            = [],
    
    909
    +        mi_defaults_         = [],
    
    910
    +        mi_insts_            = [],
    
    911
    +        mi_fam_insts_        = [],
    
    912
    +        mi_rules_            = [],
    
    913
    +        mi_trust_            = noIfaceTrustInfo,
    
    914
    +        mi_trust_pkg_        = False,
    
    915
    +        mi_complete_matches_ = [],
    
    916
    +        mi_caches_           = emptyPartialIfaceCache,
    
    917
    +        mi_abi_hashes_       = ()
    
    918
    +      }
    
    919
    +    where
    
    920
    +
    
    921
    +    emptyPartialIfaceCache :: PartialIfaceCache
    
    922
    +    emptyPartialIfaceCache
    
    923
    +      = IfaceCache
    
    924
    +        {
    
    925
    +          mi_cache_decl_warn_fn   = (),
    
    926
    +          mi_cache_export_warn_fn = (),
    
    927
    +          mi_cache_fix_fn         = (),
    
    928
    +          mi_cache_hash_fn        = ()
    
    929
    +        }
    
    790 930
     
    
    791
    -emptyPublicModIface :: IfaceAbiHashesExts phase -> IfacePublic_ phase
    
    792
    -emptyPublicModIface abi_hashes = IfacePublic
    
    793
    -  { mi_exports_ = []
    
    794
    -  , mi_decls_ = []
    
    795
    -  , mi_fixities_ = []
    
    796
    -  , mi_warns_ = IfWarnSome [] []
    
    797
    -  , mi_anns_ = []
    
    798
    -  , mi_defaults_ = []
    
    799
    -  , mi_insts_ = []
    
    800
    -  , mi_fam_insts_ = []
    
    801
    -  , mi_rules_ = []
    
    802
    -  , mi_abi_hashes_ = abi_hashes
    
    803
    -  , mi_trust_ = noIfaceTrustInfo
    
    804
    -  , mi_trust_pkg_ = False
    
    805
    -  , mi_caches_ = emptyModIfaceCache
    
    806
    -  , mi_complete_matches_ = []
    
    807
    -  }
    
    931
    +emptyModIface :: Module -> ModIface
    
    932
    +emptyModIface mod
    
    933
    +  | PrivateModIface {..} <- emptyPartialModIface mod
    
    934
    +  = PrivateModIface
    
    935
    +    {
    
    936
    +      mi_hi_bytes_   = Strict.Nothing,
    
    937
    +      mi_iface_hash_ = fingerprint0,
    
    938
    +      mi_public_     = convertIfacePublic mi_public_,
    
    939
    +      ..
    
    940
    +    }
    
    941
    +  where
    
    808 942
     
    
    809
    -emptyModIfaceCache :: IfaceCache
    
    810
    -emptyModIfaceCache = IfaceCache {
    
    811
    -  mi_cache_decl_warn_fn = emptyIfaceWarnCache,
    
    812
    -  mi_cache_export_warn_fn = emptyIfaceWarnCache,
    
    813
    -  mi_cache_fix_fn = emptyIfaceFixCache,
    
    814
    -  mi_cache_hash_fn = emptyIfaceHashCache
    
    815
    -}
    
    943
    +  convertIfacePublic :: PartialIfacePublic -> IfacePublic
    
    944
    +  convertIfacePublic IfacePublic {..}
    
    945
    +    = IfacePublic
    
    946
    +      {
    
    947
    +        mi_decls_      = [],
    
    948
    +        mi_caches_     = convertIfaceCache mi_caches_,
    
    949
    +        mi_abi_hashes_ = emptyIfaceAbiHashes,
    
    950
    +        ..
    
    951
    +      }
    
    952
    +    where
    
    953
    +
    
    954
    +    convertIfaceCache :: PartialIfaceCache -> IfaceCache
    
    955
    +    convertIfaceCache IfaceCache {..}
    
    956
    +      = IfaceCache
    
    957
    +        {
    
    958
    +          mi_cache_fix_fn = emptyIfaceFixCache,
    
    959
    +          ..
    
    960
    +        }
    
    816 961
     
    
    817
    -emptyIfaceBackend :: IfaceAbiHashes
    
    818
    -emptyIfaceBackend = IfaceAbiHashes
    
    819
    -        { mi_abi_mod_hash = fingerprint0,
    
    820
    -          mi_abi_orphan = False,
    
    821
    -          mi_abi_finsts = False,
    
    962
    +    emptyIfaceAbiHashes :: IfaceAbiHashes
    
    963
    +    emptyIfaceAbiHashes
    
    964
    +      = IfaceAbiHashes
    
    965
    +        {
    
    966
    +          mi_abi_mod_hash           = fingerprint0,
    
    967
    +          mi_abi_orphan             = False,
    
    968
    +          mi_abi_finsts             = False,
    
    822 969
               mi_abi_export_avails_hash = fingerprint0,
    
    823
    -          mi_abi_orphan_like_hash = fingerprint0,
    
    824
    -          mi_abi_orphan_hash = fingerprint0
    
    970
    +          mi_abi_orphan_like_hash   = fingerprint0,
    
    971
    +          mi_abi_orphan_hash        = fingerprint0
    
    825 972
             }
    
    826 973
     
    
    974
    +{-# DEPRECATED emptyFullModIface "Use the equivalent emptyModIface instead." #-}
    
    827 975
     emptyFullModIface :: Module -> ModIface
    
    828
    -emptyFullModIface mod =
    
    829
    -    (emptyPartialModIface mod)
    
    830
    -      { mi_public_ = emptyPublicModIface emptyIfaceBackend
    
    831
    -      , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing
    
    832
    -      }
    
    976
    +emptyFullModIface = emptyModIface
    
    833 977
     
    
    978
    +emptyRetainedModIface :: Module -> RetainedModIface
    
    979
    +emptyRetainedModIface = retainedModIface . emptyModIface
    
    834 980
     
    
    835 981
     -- | Constructs cache for the 'mi_hash_fn' field of a 'ModIface'
    
    836 982
     mkIfaceHashCache :: [(Fingerprint,IfaceDecl)]
    
    ... ... @@ -848,11 +994,21 @@ emptyIfaceHashCache _occ = Nothing
    848 994
     
    
    849 995
     -- ModIface is completely forced since it will live in memory for a long time.
    
    850 996
     -- If forcing it uses a lot of memory, then store less things in ModIface.
    
    851
    -instance ( NFData (IfaceAbiHashesExts (phase :: ModIfacePhase))
    
    852
    -         , NFData (IfaceDeclExts (phase :: ModIfacePhase))
    
    997
    +instance ( NFData (IfaceHashData phase)
    
    998
    +         , NFData (IfaceSelfRecompData phase)
    
    999
    +         , NFData (IfaceSimplifiedCoreData phase)
    
    1000
    +         , NFData (IfaceExtFieldsData phase)
    
    1001
    +         , NFData (IfaceAnnotationsData phase)
    
    1002
    +         , NFData (IfaceDeclsData phase)
    
    1003
    +         , NFData (IfaceDefaultsData phase)
    
    1004
    +         , NFData (IfaceClsInstsData phase)
    
    1005
    +         , NFData (IfaceFamInstsData phase)
    
    1006
    +         , NFData (IfaceRulesData phase)
    
    1007
    +         , NFData (IfaceCompleteMatchesData phase)
    
    1008
    +         , NFData (IfaceAbiHashesData phase)
    
    853 1009
              ) => NFData (ModIface_ phase) where
    
    854 1010
       rnf (PrivateModIface a1 a2 a3 a4 a5 a6 a7 a8 a9 a10)
    
    855
    -    = (a1 :: IfaceBinHandle phase)
    
    1011
    +    = a1
    
    856 1012
         `seq` rnf a2
    
    857 1013
         `seq` rnf a3
    
    858 1014
         `seq` rnf a4
    
    ... ... @@ -882,7 +1038,15 @@ instance NFData IfaceAbiHashes where
    882 1038
         `seq` rnf a5
    
    883 1039
         `seq` rnf a6
    
    884 1040
     
    
    885
    -instance (NFData (IfaceAbiHashesExts phase), NFData (IfaceDeclExts phase)) => NFData (IfacePublic_ phase) where
    
    1041
    +instance ( NFData (IfaceAnnotationsData phase)
    
    1042
    +         , NFData (IfaceDeclsData phase)
    
    1043
    +         , NFData (IfaceDefaultsData phase)
    
    1044
    +         , NFData (IfaceClsInstsData phase)
    
    1045
    +         , NFData (IfaceFamInstsData phase)
    
    1046
    +         , NFData (IfaceRulesData phase)
    
    1047
    +         , NFData (IfaceCompleteMatchesData phase)
    
    1048
    +         , NFData (IfaceAbiHashesData phase)
    
    1049
    +         ) => NFData (IfacePublic_ phase) where
    
    886 1050
       rnf (IfacePublic a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14)
    
    887 1051
         =  rnf a1
    
    888 1052
         `seq` rnf a2
    
    ... ... @@ -899,7 +1063,7 @@ instance (NFData (IfaceAbiHashesExts phase), NFData (IfaceDeclExts phase)) => NF
    899 1063
         `seq` rnf a13
    
    900 1064
         `seq` rnf a14
    
    901 1065
     
    
    902
    -instance NFData IfaceCache where
    
    1066
    +instance NFData (IfaceCache_ phase) where
    
    903 1067
       rnf = rwhnf
    
    904 1068
     
    
    905 1069
     forceModIface :: ModIface -> IO ()
    
    ... ... @@ -955,10 +1119,9 @@ completePartialModIface :: PartialModIface
    955 1119
     completePartialModIface partial iface_hash decls extra_decls final_exts cache = partial
    
    956 1120
       { mi_public_ = completePublicModIface decls final_exts cache (mi_public_ partial)
    
    957 1121
       , mi_simplified_core_ = extra_decls
    
    958
    -  , mi_hi_bytes_ = FullIfaceBinHandle Strict.Nothing
    
    1122
    +  , mi_hi_bytes_ = Strict.Nothing
    
    959 1123
       , mi_iface_hash_ = iface_hash
    
    960 1124
       }
    
    961
    -  where
    
    962 1125
     
    
    963 1126
     -- | Given a 'PartialIfacePublic', turn it into an 'IfacePublic' by completing
    
    964 1127
     -- missing fields.
    
    ... ... @@ -973,13 +1136,57 @@ completePublicModIface decls abi_hashes cache partial = partial
    973 1136
       , mi_caches_ = cache
    
    974 1137
       }
    
    975 1138
     
    
    1139
    +retainedModIface :: ModIface -> RetainedModIface
    
    1140
    +retainedModIface PrivateModIface {..}
    
    1141
    +  = PrivateModIface
    
    1142
    +    {
    
    1143
    +      mi_hi_bytes_        = Strict.Nothing,
    
    1144
    +      mi_iface_hash_      = (),
    
    1145
    +      mi_public_          = retainedIfacePublic mi_public_,
    
    1146
    +      mi_self_recomp_     = (),
    
    1147
    +      mi_simplified_core_ = (),
    
    1148
    +      mi_ext_fields_      = (),
    
    1149
    +      ..
    
    1150
    +    }
    
    1151
    +  where
    
    1152
    +
    
    1153
    +  retainedIfacePublic :: IfacePublic -> RetainedIfacePublic
    
    1154
    +  retainedIfacePublic IfacePublic {..}
    
    1155
    +    = IfacePublic
    
    1156
    +      {
    
    1157
    +        mi_anns_             = (),
    
    1158
    +        mi_decls_            = (),
    
    1159
    +        mi_defaults_         = (),
    
    1160
    +        mi_insts_            = (),
    
    1161
    +        mi_fam_insts_        = (),
    
    1162
    +        mi_rules_            = (),
    
    1163
    +        mi_complete_matches_ = (),
    
    1164
    +        mi_caches_           = retainedIfaceCache mi_caches_,
    
    1165
    +        ..
    
    1166
    +      }
    
    1167
    +    where
    
    1168
    +
    
    1169
    +    retainedIfaceCache :: IfaceCache -> RetainedIfaceCache
    
    1170
    +    retainedIfaceCache IfaceCache {..}
    
    1171
    +      = IfaceCache
    
    1172
    +        {
    
    1173
    +          mi_cache_decl_warn_fn   = mkIfaceDeclWarnCache bare_warnings,
    
    1174
    +          mi_cache_export_warn_fn = mkIfaceExportWarnCache bare_warnings,
    
    1175
    +          mi_cache_hash_fn        = mkIfaceHashCache mi_decls_,
    
    1176
    +          ..
    
    1177
    +        }
    
    1178
    +      where
    
    1179
    +
    
    1180
    +      bare_warnings :: Warnings GhcRn
    
    1181
    +      bare_warnings = fromIfaceWarnings mi_warns_
    
    1182
    +
    
    976 1183
     set_mi_mod_info :: IfaceModInfo -> ModIface_ phase -> ModIface_ phase
    
    977 1184
     set_mi_mod_info val iface = clear_mi_hi_bytes $ iface { mi_mod_info_ = val }
    
    978 1185
     
    
    979
    -set_mi_self_recomp :: Maybe IfaceSelfRecomp-> ModIface_ phase -> ModIface_ phase
    
    1186
    +set_mi_self_recomp :: IfaceSelfRecompData phase -> ModIface_ phase -> ModIface_ phase
    
    980 1187
     set_mi_self_recomp val iface = clear_mi_hi_bytes $ iface { mi_self_recomp_ = val }
    
    981 1188
     
    
    982
    -set_mi_hi_bytes :: IfaceBinHandle phase -> ModIface_ phase -> ModIface_ phase
    
    1189
    +set_mi_hi_bytes :: Strict.Maybe (IfaceBinHandle phase) -> ModIface_ phase -> ModIface_ phase
    
    983 1190
     set_mi_hi_bytes val iface = iface { mi_hi_bytes_ = val }
    
    984 1191
     
    
    985 1192
     set_mi_deps :: Dependencies -> ModIface_ phase -> ModIface_ phase
    
    ... ... @@ -988,7 +1195,7 @@ set_mi_deps val iface = clear_mi_hi_bytes $ iface { mi_deps_ = val }
    988 1195
     set_mi_public :: (IfacePublic_ phase -> IfacePublic_ phase) -> ModIface_ phase -> ModIface_ phase
    
    989 1196
     set_mi_public f iface = clear_mi_hi_bytes $ iface { mi_public_ = f (mi_public_ iface) }
    
    990 1197
     
    
    991
    -set_mi_simplified_core :: Maybe IfaceSimplifiedCore -> ModIface_ phase -> ModIface_ phase
    
    1198
    +set_mi_simplified_core :: IfaceSimplifiedCoreData phase -> ModIface_ phase -> ModIface_ phase
    
    992 1199
     set_mi_simplified_core val iface = clear_mi_hi_bytes $ iface { mi_simplified_core_ = val }
    
    993 1200
     
    
    994 1201
     set_mi_top_env :: IfaceTopEnv -> ModIface_ phase -> ModIface_ phase
    
    ... ... @@ -997,7 +1204,7 @@ set_mi_top_env val iface = clear_mi_hi_bytes $ iface { mi_top_env_ = val }
    997 1204
     set_mi_docs :: Maybe Docs -> ModIface_ phase -> ModIface_ phase
    
    998 1205
     set_mi_docs val iface = clear_mi_hi_bytes $  iface { mi_docs_ = val }
    
    999 1206
     
    
    1000
    -set_mi_ext_fields :: ExtensibleFields -> ModIface_ phase -> ModIface_ phase
    
    1207
    +set_mi_ext_fields :: IfaceExtFieldsData phase -> ModIface_ phase -> ModIface_ phase
    
    1001 1208
     set_mi_ext_fields val iface = clear_mi_hi_bytes $ iface { mi_ext_fields_ = val }
    
    1002 1209
     
    
    1003 1210
     {- Settings for mi_public interface fields -}
    
    ... ... @@ -1011,22 +1218,22 @@ set_mi_fixities val = set_mi_public (\iface -> iface { mi_fixities_ = val })
    1011 1218
     set_mi_warns :: IfaceWarnings -> ModIface_ phase -> ModIface_ phase
    
    1012 1219
     set_mi_warns val = set_mi_public (\iface -> iface { mi_warns_ = val })
    
    1013 1220
     
    
    1014
    -set_mi_anns :: [IfaceAnnotation] -> ModIface_ phase -> ModIface_ phase
    
    1221
    +set_mi_anns :: IfaceAnnotationsData phase -> ModIface_ phase -> ModIface_ phase
    
    1015 1222
     set_mi_anns val = set_mi_public (\iface -> iface { mi_anns_ = val })
    
    1016 1223
     
    
    1017
    -set_mi_insts :: [IfaceClsInst] -> ModIface_ phase -> ModIface_ phase
    
    1224
    +set_mi_insts :: IfaceClsInstsData phase -> ModIface_ phase -> ModIface_ phase
    
    1018 1225
     set_mi_insts val = set_mi_public (\iface -> iface { mi_insts_ = val })
    
    1019 1226
     
    
    1020
    -set_mi_fam_insts :: [IfaceFamInst] -> ModIface_ phase -> ModIface_ phase
    
    1227
    +set_mi_fam_insts :: IfaceFamInstsData phase -> ModIface_ phase -> ModIface_ phase
    
    1021 1228
     set_mi_fam_insts val = set_mi_public (\iface -> iface { mi_fam_insts_ = val })
    
    1022 1229
     
    
    1023
    -set_mi_rules :: [IfaceRule] -> ModIface_ phase -> ModIface_ phase
    
    1230
    +set_mi_rules :: IfaceRulesData phase -> ModIface_ phase -> ModIface_ phase
    
    1024 1231
     set_mi_rules val = set_mi_public (\iface -> iface { mi_rules_ = val })
    
    1025 1232
     
    
    1026
    -set_mi_decls :: [IfaceDeclExts phase] -> ModIface_ phase -> ModIface_ phase
    
    1233
    +set_mi_decls :: IfaceDeclsData phase -> ModIface_ phase -> ModIface_ phase
    
    1027 1234
     set_mi_decls val = set_mi_public (\iface -> iface { mi_decls_ = val })
    
    1028 1235
     
    
    1029
    -set_mi_defaults :: [IfaceDefault] -> ModIface_ phase -> ModIface_ phase
    
    1236
    +set_mi_defaults :: IfaceDefaultsData phase -> ModIface_ phase -> ModIface_ phase
    
    1030 1237
     set_mi_defaults val = set_mi_public (\iface -> iface { mi_defaults_ = val })
    
    1031 1238
     
    
    1032 1239
     set_mi_trust :: IfaceTrustInfo -> ModIface_ phase -> ModIface_ phase
    
    ... ... @@ -1035,27 +1242,27 @@ set_mi_trust val = set_mi_public (\iface -> iface { mi_trust_ = val })
    1035 1242
     set_mi_trust_pkg :: Bool -> ModIface_ phase -> ModIface_ phase
    
    1036 1243
     set_mi_trust_pkg val = set_mi_public (\iface -> iface { mi_trust_pkg_ = val })
    
    1037 1244
     
    
    1038
    -set_mi_complete_matches :: [IfaceCompleteMatch] -> ModIface_ phase -> ModIface_ phase
    
    1245
    +set_mi_complete_matches :: IfaceCompleteMatchesData phase -> ModIface_ phase -> ModIface_ phase
    
    1039 1246
     set_mi_complete_matches val = set_mi_public (\iface -> iface { mi_complete_matches_ = val })
    
    1040 1247
     
    
    1041
    -set_mi_abi_hashes :: IfaceAbiHashesExts phase -> ModIface_ phase -> ModIface_ phase
    
    1248
    +set_mi_abi_hashes :: IfaceAbiHashesData phase -> ModIface_ phase -> ModIface_ phase
    
    1042 1249
     set_mi_abi_hashes val = set_mi_public (\iface -> iface { mi_abi_hashes_ = val })
    
    1043 1250
     
    
    1044 1251
     {- Setters for mi_caches interface fields -}
    
    1045 1252
     
    
    1046
    -set_mi_decl_warn_fn :: (OccName -> Maybe (WarningTxt GhcRn)) -> ModIface_ phase -> ModIface_ phase
    
    1253
    +set_mi_decl_warn_fn :: IfaceDeclWarningCacheData phase -> ModIface_ phase -> ModIface_ phase
    
    1047 1254
     set_mi_decl_warn_fn val = set_mi_public (\iface -> iface { mi_caches_ = (mi_caches_ iface) { mi_cache_decl_warn_fn = val } })
    
    1048 1255
     
    
    1049
    -set_mi_export_warn_fn :: (Name -> Maybe (WarningTxt GhcRn)) -> ModIface_ phase -> ModIface_ phase
    
    1256
    +set_mi_export_warn_fn :: IfaceExportWarningCacheData phase -> ModIface_ phase -> ModIface_ phase
    
    1050 1257
     set_mi_export_warn_fn val = set_mi_public (\iface -> iface { mi_caches_ = (mi_caches_ iface) { mi_cache_export_warn_fn = val } })
    
    1051 1258
     
    
    1052
    -set_mi_fix_fn :: (OccName -> Maybe Fixity) -> ModIface_ phase -> ModIface_ phase
    
    1259
    +set_mi_fix_fn :: IfaceFixityCacheData phase -> ModIface_ phase -> ModIface_ phase
    
    1053 1260
     set_mi_fix_fn val = set_mi_public (\iface -> iface { mi_caches_ = (mi_caches_ iface) { mi_cache_fix_fn = val } })
    
    1054 1261
     
    
    1055
    -set_mi_hash_fn :: (OccName -> Maybe (OccName, Fingerprint)) -> ModIface_ phase -> ModIface_ phase
    
    1262
    +set_mi_hash_fn :: IfaceHashCacheData phase -> ModIface_ phase -> ModIface_ phase
    
    1056 1263
     set_mi_hash_fn val = set_mi_public (\iface -> iface { mi_caches_ = (mi_caches_ iface) { mi_cache_hash_fn = val } })
    
    1057 1264
     
    
    1058
    -set_mi_caches :: IfaceCache -> ModIface_ phase -> ModIface_ phase
    
    1265
    +set_mi_caches :: IfaceCache_ phase -> ModIface_ phase -> ModIface_ phase
    
    1059 1266
     set_mi_caches val = set_mi_public (\iface -> iface { mi_caches_ = val })
    
    1060 1267
     
    
    1061 1268
     {-
    
    ... ... @@ -1082,11 +1289,7 @@ set_mi_mod_info_field f iface = clear_mi_hi_bytes $ iface { mi_mod_info_ = f (mi
    1082 1289
     
    
    1083 1290
     -- | Invalidate any byte array buffer we might have.
    
    1084 1291
     clear_mi_hi_bytes :: ModIface_ phase -> ModIface_ phase
    
    1085
    -clear_mi_hi_bytes iface = iface
    
    1086
    -  { mi_hi_bytes_ = case mi_hi_bytes iface of
    
    1087
    -      PartialIfaceBinHandle -> PartialIfaceBinHandle
    
    1088
    -      FullIfaceBinHandle _ -> FullIfaceBinHandle Strict.Nothing
    
    1089
    -  }
    
    1292
    +clear_mi_hi_bytes iface = iface { mi_hi_bytes_ = Strict.Nothing }
    
    1090 1293
     
    
    1091 1294
     -- ----------------------------------------------------------------------------
    
    1092 1295
     -- 'ModIface' pattern synonyms to keep breakage low.
    
    ... ... @@ -1177,33 +1380,33 @@ pattern ModIface ::
    1177 1380
       -> Module
    
    1178 1381
       -> Maybe Module
    
    1179 1382
       -> HscSource
    
    1180
    -  -> Fingerprint
    
    1383
    +  -> IfaceHashData phase
    
    1181 1384
       -> Dependencies
    
    1182 1385
       -> IfacePublic_ phase
    
    1183 1386
       -> [IfaceExport]
    
    1184 1387
       -> [(OccName, Fixity)]
    
    1185 1388
       -> IfaceWarnings
    
    1186
    -  -> [IfaceAnnotation]
    
    1187
    -  -> [IfaceDeclExts phase]
    
    1188
    -  -> Maybe IfaceSimplifiedCore
    
    1189
    -  -> [IfaceDefault]
    
    1389
    +  -> IfaceAnnotationsData phase
    
    1390
    +  -> IfaceDeclsData phase
    
    1391
    +  -> IfaceSimplifiedCoreData phase
    
    1392
    +  -> IfaceDefaultsData phase
    
    1190 1393
       -> IfaceTopEnv
    
    1191
    -  -> [IfaceClsInst]
    
    1192
    -  -> [IfaceFamInst]
    
    1193
    -  -> [IfaceRule]
    
    1394
    +  -> IfaceClsInstsData phase
    
    1395
    +  -> IfaceFamInstsData phase
    
    1396
    +  -> IfaceRulesData phase
    
    1194 1397
       -> IfaceTrustInfo
    
    1195 1398
       -> Bool
    
    1196
    -  -> [IfaceCompleteMatch]
    
    1399
    +  -> IfaceCompleteMatchesData phase
    
    1197 1400
       -> Maybe Docs
    
    1198
    -  -> IfaceAbiHashesExts phase
    
    1199
    -  -> ExtensibleFields
    
    1200
    -  -> IfaceBinHandle phase
    
    1201
    -  -> Maybe IfaceSelfRecomp
    
    1202
    -  -> (OccName -> Maybe Fixity)
    
    1203
    -  -> (OccName -> Maybe (OccName, Fingerprint))
    
    1204
    -  -> (OccName -> Maybe (WarningTxt GhcRn))
    
    1205
    -  -> (Name -> Maybe (WarningTxt GhcRn)) ->
    
    1206
    -  ModIface_ phase
    
    1401
    +  -> IfaceAbiHashesData phase
    
    1402
    +  -> IfaceExtFieldsData phase
    
    1403
    +  -> Strict.Maybe (IfaceBinHandle phase)
    
    1404
    +  -> IfaceSelfRecompData phase
    
    1405
    +  -> IfaceFixityCacheData phase
    
    1406
    +  -> IfaceHashCacheData phase
    
    1407
    +  -> IfaceDeclWarningCacheData phase
    
    1408
    +  -> IfaceExportWarningCacheData phase
    
    1409
    +  -> ModIface_ phase
    
    1207 1410
     pattern ModIface
    
    1208 1411
       { mi_mod_info
    
    1209 1412
       , mi_module
    

  • ghc/Main.hs
    ... ... @@ -515,7 +515,7 @@ abiHash strs = do
    515 515
       put_ bh hiVersion
    
    516 516
         -- package hashes change when the compiler version changes (for now)
    
    517 517
         -- see #5328
    
    518
    -  mapM_ (put_ bh . mi_mod_hash) ifaces
    
    518
    +  mapM_ (put_ bh . mi_abi_mod_hash . mi_abi_hashes) ifaces
    
    519 519
       f <- fingerprintBinMem bh
    
    520 520
     
    
    521 521
       putStrLn (showPpr dflags f)
    

  • utils/count-deps/Main.hs
    ... ... @@ -79,5 +79,5 @@ calcDeps modName libdir =
    79 79
         mkModule :: String -> ModuleName -> Module
    
    80 80
         mkModule ghcUnitId = Module (stringToUnit ghcUnitId)
    
    81 81
     
    
    82
    -    modDeps :: ModIface -> [ModuleName]
    
    82
    +    modDeps :: ModIface_ phase -> [ModuleName]
    
    83 83
         modDeps mi = map (gwib_mod . (\(_, _, mn) -> mn)) $ Set.toList $ dep_direct_mods (mi_deps mi)