diff options
author | Thomas Schilling <nominolo@googlemail.com> | 2008-09-15 09:10:37 +0000 |
---|---|---|
committer | Thomas Schilling <nominolo@googlemail.com> | 2008-09-15 09:10:37 +0000 |
commit | e5f944b9ddda55f6c789cc9ee372e0f3b1b8826f (patch) | |
tree | c6a8b74436995420c3411c34766ce0717eabba18 /src/Haddock/GHC | |
parent | 6e22eb255c9ca9f6b5c56e500a37eddb50bdfc0a (diff) |
Port Haddock.GHC.Typecheck to new GHC API.
Diffstat (limited to 'src/Haddock/GHC')
-rw-r--r-- | src/Haddock/GHC/Typecheck.hs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/Haddock/GHC/Typecheck.hs b/src/Haddock/GHC/Typecheck.hs index 0df6fc29..ff636bfd 100644 --- a/src/Haddock/GHC/Typecheck.hs +++ b/src/Haddock/GHC/Typecheck.hs @@ -34,19 +34,19 @@ type FullyCheckedMod = (ParsedSource, -- TODO: make it handle cleanup -typecheckFiles :: Session -> [FilePath] -> IO [GhcModule] -typecheckFiles session files = do +typecheckFiles :: [FilePath] -> Ghc [GhcModule] +typecheckFiles files = do -- load all argument files targets <- mapM (\f -> guessTarget f Nothing) files - setTargets session targets + setTargets targets - flag <- load session LoadAllTargets + flag <- load LoadAllTargets when (failed flag) $ throwE "Failed to load all needed modules" - modgraph <- getModuleGraph session + modgraph <- getModuleGraph let mods = concatMap flattenSCC $ topSortModuleGraph False modgraph Nothing getModFile = fromJust . ml_hs_file . ms_location @@ -55,12 +55,18 @@ typecheckFiles session files = do -- typecheck the argument modules - ghcMods <- forM mods' $ \(mod, flags, file) -> do - mbMod <- checkModule session (moduleName mod) False - case mbMod of - Just (CheckedModule a (Just b) (Just c) (Just d) _) - -> return $ mkGhcModule (mod, file, (a,b,c,d)) flags - _ -> throwE ("Failed to check module: " ++ moduleString mod) + ghcMods <- forM mods' $ \(mod, flags, file) -> + handleSourceError + (\err -> do + printExceptionAndWarnings err + throwE ("Failed to check module: " ++ moduleString mod)) $ + do tc_mod <- typecheckModule =<< parseModule (moduleName mod) + let Just renamed_src = renamedSource tc_mod + return $ mkGhcModule (mod, file, (parsedSource tc_mod, + renamed_src, + typecheckedSource tc_mod, + moduleInfo tc_mod)) + flags return ghcMods |