diff --git a/Debug.hs b/Debug.hs index b7280f6..2f28235 100644 --- a/Debug.hs +++ b/Debug.hs @@ -25,8 +25,7 @@ debug opt cradle ver fileName = do [fast] <- withGHC fileName $ do void $ initializeFlagsWithCradle opt cradle gopts True setTargetFile fileName - slow <- needsTemplateHaskell <$> depanal [] False - return [not slow] + pure . canCheckFast <$> depanal [] False return [ "GHC version: " ++ ver , "Current directory: " ++ currentDir diff --git a/GHCApi.hs b/GHCApi.hs index 35d2529..da87ef7 100644 --- a/GHCApi.hs +++ b/GHCApi.hs @@ -7,6 +7,7 @@ module GHCApi ( , getDynamicFlags , setSlowDynFlags , checkSlowAndSet + , canCheckFast ) where import CabalApi @@ -128,8 +129,8 @@ setSlowDynFlags = (flip setFastOrNot Slow <$> getSessionDynFlags) -- So, this is necessary redundancy. checkSlowAndSet :: Ghc () checkSlowAndSet = do - slow <- needsTemplateHaskell <$> depanal [] False - when slow setSlowDynFlags + fast <- canCheckFast <$> depanal [] False + unless fast setSlowDynFlags ---------------------------------------------------------------- @@ -150,3 +151,9 @@ setTargetFile file = do getDynamicFlags :: IO DynFlags getDynamicFlags = runGhc (Just libdir) getSessionDynFlags + +canCheckFast :: ModuleGraph -> Bool +canCheckFast = not . any (hasTHorQQ . ms_hspp_opts) + where + hasTHorQQ :: DynFlags -> Bool + hasTHorQQ dflags = any (\opt -> xopt opt dflags) [Opt_TemplateHaskell, Opt_QuasiQuotes]