diff --git a/ChangeLog b/ChangeLog index dd344d8..92910f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ UNRELEASED v5.1.0.0 * Make `loadSymbolDb` polimorphic in the return types's monad. * Add `hoistGhcModT` to Language.Haskell.GhcMod.Internal +UNRELEASED v5.0.1.3 + * Fix `check` command for modules using `-XPatternSynonyms` + 2014-08-29 v5.0.1.2 * Merge #345, Try fixing duplicate errors * Merge #344, elisp: Use advice to check syntax on save-buffer 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"] diff --git a/test/data/pattern-synonyms/A.hs b/test/data/pattern-synonyms/A.hs new file mode 100644 index 0000000..75affb6 --- /dev/null +++ b/test/data/pattern-synonyms/A.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE PatternSynonyms #-} +module A where + +data SomeType a b = SomeType (a,b) + +pattern MyPat x y <- SomeType (x,y) diff --git a/test/data/pattern-synonyms/B.hs b/test/data/pattern-synonyms/B.hs new file mode 100644 index 0000000..d8fc44a --- /dev/null +++ b/test/data/pattern-synonyms/B.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE PatternSynonyms #-} +module B where +import A + +foo :: SomeType Int Char -> String +foo x = case x of + MyPat a b -> show a ++ " " ++ [b] diff --git a/test/data/pattern-synonyms/Setup.hs b/test/data/pattern-synonyms/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/test/data/pattern-synonyms/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/test/data/pattern-synonyms/pattern-synonyms.cabal b/test/data/pattern-synonyms/pattern-synonyms.cabal new file mode 100644 index 0000000..a9b0489 --- /dev/null +++ b/test/data/pattern-synonyms/pattern-synonyms.cabal @@ -0,0 +1,24 @@ +-- Initial pattern-synonyms.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/ + +name: pattern-synonyms +version: 0.1.0.0 +-- synopsis: +-- description: +-- license: +license-file: LICENSE +author: Daniel Gröber +maintainer: dxld@darkboxed.org +-- copyright: +-- category: +build-type: Simple +-- extra-source-files: +cabal-version: >=1.10 + +library + exposed-modules: A, B + -- other-modules: + other-extensions: PatternSynonyms + build-depends: base >=4.7 && <4.8 + -- hs-source-dirs: + default-language: Haskell2010 \ No newline at end of file