packages feed

ghc-lib-parser-ex 8.10.0.6 → 8.10.0.7

raw patch · 4 files changed

+41/−2 lines, 4 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Language.Haskell.GhclibParserEx.Fixity: fixitiesFromModule :: Located (HsModule GhcPs) -> [(String, Fixity)]

Files

ChangeLog.md view
@@ -1,5 +1,8 @@ # Changelog for ghc-lib-parser-ex +## 8.10.0.7 released 2020-05-13+- New function `fixitiesFromModule`+ ## 8.10.0.6 released 2020-05-05 - Bugfix in `parsePragmasIntoDynFlags` that meant that default enabled/disabled extensions subsequently disabled/enabled via pragma weren't getting disabled/enabled 
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.18 name:           ghc-lib-parser-ex-version:        8.10.0.6+version:        8.10.0.7 description:    Please see the README on GitHub at <https://github.com/shayne-fletcher/ghc-lib-parser-ex#readme> homepage:       https://github.com/shayne-fletcher/ghc-lib-parser-ex#readme bug-reports:    https://github.com/shayne-fletcher/ghc-lib-parser-ex/issues
src/Language/Haskell/GhclibParserEx/Fixity.hs view
@@ -11,6 +11,7 @@  module Language.Haskell.GhclibParserEx.Fixity(     applyFixities+  , fixitiesFromModule   , preludeFixities, baseFixities   , infixr_, infixl_, infix_, fixity   ) where@@ -206,3 +207,15 @@  fixity :: FixityDirection -> Int -> [String] -> [(String, Fixity)] fixity a p = map (,Fixity (SourceText "") p a)++#if defined (GHCLIB_API_811)+fixitiesFromModule :: Located HsModule -> [(String, Fixity)]+#else+fixitiesFromModule :: Located (HsModule GhcPs) -> [(String, Fixity)]+#endif+fixitiesFromModule (L _ (HsModule _ _ _ decls _ _)) = concatMap f decls+  where+    f :: LHsDecl GhcPs -> [(String, Fixity)]+    f (L _ (SigD _ (FixSig _ (FixitySig _ ops (Fixity _ p dir))))) =+          fixity dir p (map (occNameString. rdrNameOcc . unLoc) ops)+    f _ = []
test/Test.hs view
@@ -171,6 +171,12 @@           showSDocUnsafe (showAstData BlankSrcSpan d) /=           showSDocUnsafe (showAstData BlankSrcSpan (applyFixities [] d))         PFailed{} -> assertFailure "parse error"+  , testCase "fixitiesFromModule" $ do+      let flags = defaultDynFlags fakeSettings fakeLlvmConfig+      case parseModule "infixl 4 <*!" flags of+        POk _ m ->+          assertBool "one fixity expected" $ not (null (fixitiesFromModule m))+        PFailed{} -> assertFailure "parse error"   ]  extendInstancesTests :: TestTree@@ -290,5 +296,22 @@       assertBool "no extensions disabled" (null ds)       assertBool "two extensions enabled" $ DeriveFunctor `elem` es && DeriveFoldable `elem` es   , testCase "check instance Bounded Language" $ assertBool "enumerate is null" (not (null (enumerate @Language)))-  , testCase "check instace Ord Extension" $ assertBool "minBound >= maxBound" (minBound @Extension < maxBound @Extension)+  , testCase "check instance Ord Extension" $ assertBool "minBound >= maxBound" (minBound @Extension < maxBound @Extension)+  , testCase "disable via pragma" $ withTempDir $ \tmpDir -> do+      foo <- makeFile (tmpDir </> "Foo.hs") $ unlines+        [ "{-# LANGUAGE NoStarIsType #-}"+        , "{-# LANGUAGE ExplicitNamespaces #-}"+        , "import GHC.TypeLits(KnownNat, type (+), type (*))"+        ]+      s <- readFile' foo+      -- If 'StarIsType' ends up enabled after+      -- 'parsePragmasIntoDynflags' has done its work, we'll get a+      -- parse error (see+      -- https://github.com/ndmitchell/hlint/issues/971).+      parsePragmasIntoDynFlags flags ([StarIsType], []) foo s >>= \case+        Left msg -> assertFailure msg+        Right flags -> chkParseResult report flags $ parseFile foo flags s   ]+  where+    flags = unsafeGlobalDynFlags+    report flags msgs = concat [ showSDoc flags msg | msg <- pprErrMsgBagWithLoc msgs ]