From 72679c619c20e0f4d24429506ea09bb234bcb212 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Date: Sun, 6 Jul 2014 09:45:02 +0200 Subject: [PATCH] Show more relevant bindings in typed holes --- Language/Haskell/GhcMod/Check.hs | 2 +- Language/Haskell/GhcMod/GHCApi.hs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Language/Haskell/GhcMod/Check.hs b/Language/Haskell/GhcMod/Check.hs index 48dacc3..4c2af9a 100644 --- a/Language/Haskell/GhcMod/Check.hs +++ b/Language/Haskell/GhcMod/Check.hs @@ -32,7 +32,7 @@ checkSyntax files = withErrorHandler sessionName $ do check :: [FilePath] -- ^ The target files. -> GhcMod (Either String String) check fileNames = do - withLogger setAllWaringFlags $ do + withLogger (setAllWaringFlags . setNoMaxRelevantBindings) $ do setTargetFiles fileNames ---------------------------------------------------------------- diff --git a/Language/Haskell/GhcMod/GHCApi.hs b/Language/Haskell/GhcMod/GHCApi.hs index d48b2e7..e8a7f5e 100644 --- a/Language/Haskell/GhcMod/GHCApi.hs +++ b/Language/Haskell/GhcMod/GHCApi.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ScopedTypeVariables, RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables, RecordWildCards, CPP #-} module Language.Haskell.GhcMod.GHCApi ( withGHC @@ -11,6 +11,7 @@ module Language.Haskell.GhcMod.GHCApi ( , withCmdFlags , setNoWaringFlags , setAllWaringFlags + , setNoMaxRelevantBindings ) where import Language.Haskell.GhcMod.CabalApi @@ -195,6 +196,15 @@ setNoWaringFlags df = df { warningFlags = Gap.emptyWarnFlags} setAllWaringFlags :: DynFlags -> DynFlags setAllWaringFlags df = df { warningFlags = allWarningFlags } +-- | Set 'DynFlags' equivalent to "-fno-max-relevant-bindings". +setNoMaxRelevantBindings :: DynFlags -> DynFlags +#if __GLASGOW_HASKELL__ >= 708 +setNoMaxRelevantBindings df = df { maxRelevantBinds = Nothing } +#else +setNoMaxRelevantBindings = id +#endif + + allWarningFlags :: Gap.WarnFlags allWarningFlags = unsafePerformIO $ do mlibdir <- getSystemLibDir