From: Matthijs Kooijman Date: Thu, 9 Apr 2009 14:01:39 +0000 (+0200) Subject: Add a runTcM utility function. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=c27e735e016fb925a2514f1c0f11d925ed4bd320;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add a runTcM utility function. --- diff --git a/GhcTools.hs b/GhcTools.hs index dcfab0f..9c5038c 100644 --- a/GhcTools.hs +++ b/GhcTools.hs @@ -6,6 +6,10 @@ import qualified System.IO.Unsafe import qualified GHC import qualified GHC.Paths import qualified DynFlags +import qualified TcRnMonad +import qualified MonadUtils +import qualified HscTypes +import qualified PrelNames -- Change a DynFlag from within the Ghc monad. Strangely enough there seems to -- be no standard function to do exactly this. @@ -29,3 +33,12 @@ unsafeRunGhc m = dflags <- GHC.getSessionDynFlags GHC.setSessionDynFlags dflags m + +runTcM :: TcRnMonad.TcM a -> IO a +runTcM thing_inside = do + GHC.runGhc (Just GHC.Paths.libdir) $ do + dflags <- GHC.getSessionDynFlags + GHC.setSessionDynFlags dflags + env <- GHC.getSession + HscTypes.ioMsgMaybe . MonadUtils.liftIO . TcRnMonad.initTcPrintErrors env PrelNames.iNTERACTIVE $ do + thing_inside