- st <- getGHCiState
- if not retain_context
- then do
- setGHCiState st{ remembered_ctx = Nothing }
- setContextAfterLoad session prev_context loaded_mod_summaries
- else do
- -- figure out which modules we can keep in the context, which we
- -- have to put back, and which we have to remember because they
- -- are (temporarily) unavailable. See ghci.prog009, #1873, #1360
- let (as,bs) = prev_context
- as1 = filter isHomeModule as -- package modules are kept anyway
- bs1 = filter isHomeModule bs
- (as_ok, as_bad) = partition (`elem` loaded_mods) as1
- (bs_ok, bs_bad) = partition (`elem` loaded_mods) bs1
- (rem_as, rem_bs) = fromMaybe ([],[]) (remembered_ctx st)
- (rem_as_ok, rem_as_bad) = partition (`elem` loaded_mods) rem_as
- (rem_bs_ok, rem_bs_bad) = partition (`elem` loaded_mods) rem_bs
- as' = nub (as_ok++rem_as_ok)
- bs' = nub (bs_ok++rem_bs_ok)
- rem_as' = nub (rem_as_bad ++ as_bad)
- rem_bs' = nub (rem_bs_bad ++ bs_bad)
-
- -- Put back into the context any modules that we previously had
- -- to drop because they weren't available (rem_as_ok, rem_bs_ok).
- setContextKeepingPackageModules session prev_context (as',bs')
-
- -- If compilation failed, remember any modules that we are unable
- -- to load, so that we can put them back in the context in the future.
- case ok of
- Succeeded -> setGHCiState st{ remembered_ctx = Nothing }
- Failed -> setGHCiState st{ remembered_ctx = Just (rem_as',rem_bs') }
-
-
-
-setContextAfterLoad :: Session -> ([Module],[Module]) -> [GHC.ModSummary] -> GHCi ()
-setContextAfterLoad session prev [] = do