aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Haddock/GHC.hs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Haddock/GHC.hs b/src/Haddock/GHC.hs
index 66bd3b1f..ff1c58e4 100644
--- a/src/Haddock/GHC.hs
+++ b/src/Haddock/GHC.hs
@@ -30,25 +30,25 @@ import SrcLoc
-- | Start a GHC session with the -haddock flag set. Also turn off
-- compilation and linking.
-startGhc :: String -> [String] -> IO (Session, DynFlags)
-startGhc libDir flags = do
+startGhc :: String -> [String] -> (DynFlags -> Ghc a) -> IO a
+startGhc libDir flags ghcActs = do
-- TODO: handle warnings?
#if __GLASGOW_HASKELL__ >= 609
(restFlags, _) <- parseStaticFlags (map noLoc flags)
#else
restFlags <- parseStaticFlags flags
#endif
- session <- newSession (Just libDir)
- dynflags <- getSessionDynFlags session
- let dynflags' = dopt_set dynflags Opt_Haddock
- let dynflags'' = dynflags' {
- hscTarget = HscAsm,
- ghcMode = CompManager,
- ghcLink = NoLink
- }
- dynflags''' <- parseGhcFlags dynflags'' restFlags flags
- setSessionDynFlags session dynflags'''
- return (session, dynflags''')
+ runGhc (Just libDir) $ do
+ dynflags <- getSessionDynFlags
+ let dynflags' = dopt_set dynflags Opt_Haddock
+ let dynflags'' = dynflags' {
+ hscTarget = HscAsm,
+ ghcMode = CompManager,
+ ghcLink = NoLink
+ }
+ dynflags''' <- parseGhcFlags dynflags'' restFlags flags
+ setSessionDynFlags dynflags'''
+ ghcActs dynflags'''
-- | Expose the list of packages to GHC. Then initialize GHC's package state