From 615c6c4543ea5bb884c5a7b003b76f9ecd3d0f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Fri, 12 Sep 2014 03:48:22 +0200 Subject: [PATCH] Workaround for #340 --- Language/Haskell/GhcMod/Target.hs | 14 +++++++++----- test/CheckSpec.hs | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Language/Haskell/GhcMod/Target.hs b/Language/Haskell/GhcMod/Target.hs index 1744a72..51d64e4 100644 --- a/Language/Haskell/GhcMod/Target.hs +++ b/Language/Haskell/GhcMod/Target.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} module Language.Haskell.GhcMod.Target ( setTargetFiles ) where @@ -5,7 +6,7 @@ module Language.Haskell.GhcMod.Target ( import Control.Applicative ((<$>)) import Control.Monad (forM, void, (>=>)) import DynFlags (ExtensionFlag(..), xopt) -import GHC (DynFlags(..), LoadHowMuch(..)) +import GHC (LoadHowMuch(..)) import qualified GHC as G import Language.Haskell.GhcMod.DynFlags import Language.Haskell.GhcMod.Monad @@ -50,7 +51,10 @@ setTargetFiles files = do setCompilerMode Intelligent needsFallback :: G.ModuleGraph -> Bool -needsFallback = any (hasTHorQQ . G.ms_hspp_opts) - where - hasTHorQQ :: DynFlags -> Bool - hasTHorQQ dflags = any (`xopt` dflags) [Opt_TemplateHaskell, Opt_QuasiQuotes] +needsFallback = any $ \ms -> + let df = G.ms_hspp_opts ms in + Opt_TemplateHaskell `xopt` df + || Opt_QuasiQuotes `xopt` df +#if __GLASGOW_HASKELL__ >= 708 + || (Opt_PatternSynonyms `xopt` df) +#endif diff --git a/test/CheckSpec.hs b/test/CheckSpec.hs index c492701..7c704a4 100644 --- a/test/CheckSpec.hs +++ b/test/CheckSpec.hs @@ -31,6 +31,11 @@ spec = do res <- runID $ checkSyntax ["Baz.hs"] res `shouldSatisfy` ("Baz.hs:5:1:Warning:" `isPrefixOf`) + it "works with modules using PatternSynonyms" $ do + withDirectory_ "test/data/pattern-synonyms" $ do + res <- runID $ checkSyntax ["B.hs"] + res `shouldSatisfy` ("B.hs:6:9:Warning:" `isPrefixOf`) + it "works with foreign exports" $ do withDirectory_ "test/data" $ do res <- runID $ checkSyntax ["ForeignExport.hs"]