diff options
author | Fendor <power.walross@gmail.com> | 2021-02-03 19:12:02 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-28 17:26:37 -0400 |
commit | 29d758631c0d9124485aafc89cddc4ec5a668653 (patch) | |
tree | 72efc6ad23ddc052cecd01b493384b8fbc74daab /ghc | |
parent | b02c8ef768df33ef4845da2f15583cf143a4d0e2 (diff) | |
download | haskell-29d758631c0d9124485aafc89cddc4ec5a668653.tar.gz |
Add UnitId to Target record
In the future, we want `HscEnv` to support multiple home units
at the same time. This means, that there will be 'Target's that do
not belong to the current 'HomeUnit'.
This is an API change without changing behaviour.
Update haddock submodule to incorporate API changes.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 24 | ||||
-rw-r--r-- | ghc/GHCi/UI/Info.hs | 4 | ||||
-rw-r--r-- | ghc/Main.hs | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index f698b5abed..a028f4e479 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1674,7 +1674,7 @@ chooseEditFile = Just file -> return file Nothing -> throwGhcException (CmdLineError "No files to edit.") - where fromTarget (GHC.Target (GHC.TargetFile f _) _ _) = Just f + where fromTarget GHC.Target { targetId = GHC.TargetFile f _ } = Just f fromTarget _ = Nothing -- when would we get a module target? @@ -1949,7 +1949,7 @@ loadModule' files = do let (filenames, phases) = unzip files exp_filenames <- mapM expandPath filenames let files' = zip exp_filenames phases - targets <- mapM (uncurry GHC.guessTarget) files' + targets <- mapM (\(file, phase) -> GHC.guessTarget file Nothing phase) files' -- NOTE: we used to do the dependency anal first, so that if it -- fails we didn't throw away the current set of modules. This would @@ -1983,17 +1983,17 @@ addModule :: GhciMonad m => [FilePath] -> m () addModule files = do revertCAFs -- always revert CAFs on load/add. files' <- mapM expandPath files - targets <- mapM (\m -> GHC.guessTarget m Nothing) files' + targets <- mapM (\m -> GHC.guessTarget m Nothing Nothing) files' targets' <- filterM checkTarget targets -- remove old targets with the same id; e.g. for :add *M - mapM_ GHC.removeTarget [ tid | Target tid _ _ <- targets' ] + mapM_ GHC.removeTarget [ tid | Target { targetId = tid } <- targets' ] mapM_ GHC.addTarget targets' _ <- doLoadAndCollectInfo False LoadAllTargets return () where checkTarget :: GHC.GhcMonad m => Target -> m Bool - checkTarget (Target (TargetModule m) _ _) = checkTargetModule m - checkTarget (Target (TargetFile f _) _ _) = liftIO $ checkTargetFile f + checkTarget Target { targetId = TargetModule m } = checkTargetModule m + checkTarget Target { targetId = TargetFile f _ } = liftIO $ checkTargetFile f checkTargetModule :: GHC.GhcMonad m => ModuleName -> m Bool checkTargetModule m = do @@ -2019,8 +2019,8 @@ addModule files = do unAddModule :: GhciMonad m => [FilePath] -> m () unAddModule files = do files' <- mapM expandPath files - targets <- mapM (\m -> GHC.guessTarget m Nothing) files' - mapM_ GHC.removeTarget [ tid | Target tid _ _ <- targets ] + targets <- mapM (\m -> GHC.guessTarget m Nothing Nothing) files' + mapM_ GHC.removeTarget [ tid | Target { targetId = tid } <- targets ] _ <- doLoadAndCollectInfo False LoadAllTargets return () @@ -2112,9 +2112,9 @@ setContextAfterLoad keep_ctxt ms = do [] -> Nothing (m:_) -> Just m - summary `matches` Target (TargetModule m) _ _ + summary `matches` Target { targetId = TargetModule m } = GHC.ms_mod_name summary == m - summary `matches` Target (TargetFile f _) _ _ + summary `matches` Target { targetId = TargetFile f _ } | Just f' <- GHC.ml_hs_file (GHC.ms_location summary) = f == f' _ `matches` _ = False @@ -3384,8 +3384,8 @@ showTargets :: GHC.GhcMonad m => m () showTargets = mapM_ showTarget =<< GHC.getTargets where showTarget :: GHC.GhcMonad m => Target -> m () - showTarget (Target (TargetFile f _) _ _) = liftIO (putStrLn f) - showTarget (Target (TargetModule m) _ _) = + showTarget Target { targetId = TargetFile f _ } = liftIO (putStrLn f) + showTarget Target { targetId = TargetModule m } = liftIO (putStrLn $ moduleNameString m) -- ----------------------------------------------------------------------------- diff --git a/ghc/GHCi/UI/Info.hs b/ghc/GHCi/UI/Info.hs index 144ebc4a78..db09243967 100644 --- a/ghc/GHCi/UI/Info.hs +++ b/ghc/GHCi/UI/Info.hs @@ -237,7 +237,7 @@ findType infos span0 string = do guessModule :: GhcMonad m => Map ModuleName ModInfo -> FilePath -> MaybeT m ModuleName guessModule infos fp = do - target <- lift $ guessTarget fp Nothing + target <- lift $ guessTarget fp Nothing Nothing case targetId target of TargetModule mn -> return mn TargetFile fp' _ -> guessModule' fp' @@ -248,7 +248,7 @@ guessModule infos fp = do Nothing -> do fp'' <- liftIO (makeRelativeToCurrentDirectory fp') - target' <- lift $ guessTarget fp'' Nothing + target' <- lift $ guessTarget fp'' Nothing Nothing case targetId target' of TargetModule mn -> return mn _ -> MaybeT . pure $ findModByFp fp'' diff --git a/ghc/Main.hs b/ghc/Main.hs index 00aeaf5028..9da5469b8a 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -676,7 +676,7 @@ doMake srcs = do ++ ldInputs dflags } _ <- GHC.setSessionDynFlags dflags' - targets <- mapM (uncurry GHC.guessTarget) hs_srcs + targets <- mapM (\(src, phase) -> GHC.guessTarget src Nothing phase) hs_srcs GHC.setTargets targets ok_flag <- GHC.load LoadAllTargets |