packages feed

ghc-lib-parser-ex 0.20210501 → 0.20210601

raw patch · 6 files changed

+88/−15 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,12 +1,14 @@ # Changelog for ghc-lib-parser-ex +## 0.20210601 released 2021-06-01+- Update to `ghc-lib-parser-0.20210601`+- Update types in `GHC.Types.Name.Reader` for ghc-9.2.1, `Located` becomes `LocatedN`+ ## 0.20210501 released 2021-05-01 - Update to `ghc-lib-0.20210501`  ## 0.20210331 released 2021-02-31 - Update to `ghc-lib-0.20210331`--## Unreleased - Upgrade to `ghc-lib-parser-9.0.1.20210324`  ## 9.0.0.4 released 2021-03-11
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.18 name:           ghc-lib-parser-ex-version:        0.20210501+version:        0.20210601 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/GHC/Hs/Expr.hs view
@@ -69,7 +69,11 @@   (L _ HsLam{}) -> True   (L _ ExplicitTuple{}) -> True   (L _ ExplicitList{}) -> True+#if defined (GHCLIB_API_HEAD)+  (L _ (HsPar _ _ x _)) -> isWHNF x+#else   (L _ (HsPar _ x)) -> isWHNF x+#endif   (L _ (ExprWithTySig _ x _)) -> isWHNF x   -- Other (unknown) constructors may have bang patterns in them, so   -- approximate.@@ -86,13 +90,22 @@ isStrictMatch = \case FunRhs{mc_strictness=SrcStrict} -> True; _ -> False  -- Field is punned e.g. '{foo}'.+#if defined (GHCLIB_API_HEAD)+isFieldPun :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool+isFieldPun = \case (L _ HsFieldBind {hfbPun=True}) -> True; _ -> False+#else isFieldPun :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool isFieldPun = \case (L _ HsRecField {hsRecPun=True}) -> True; _ -> False-+#endif -- Field puns in updates have a different type to field puns in -- constructions.+#if defined (GHCLIB_API_HEAD)+isFieldPunUpdate :: HsFieldBind (FieldOcc GhcPs) (LHsExpr GhcPs) -> Bool+isFieldPunUpdate = \case HsFieldBind {hfbPun=True} -> True; _ -> False+#else isFieldPunUpdate :: HsRecField' (AmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool isFieldPunUpdate = \case HsRecField {hsRecPun=True} -> True; _ -> False+#endif  -- Contains a '..' as in 'Foo{..}' hasFieldsDotDot :: HsRecFields GhcPs (LHsExpr GhcPs) -> Bool@@ -143,17 +156,28 @@ isTransStmt = \case TransStmt{} -> True; _ -> False  -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.+#if defined (GHCLIB_API_HEAD)+isFieldWildcard :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool+#else isFieldWildcard :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool+#endif isFieldWildcard = \case-#if defined (GHCLIB_API_HEAD) || defined(GHCLIB_API_902) || defined (GHCLIB_API_900)+#if defined (GHCLIB_API_HEAD)+  (L _ HsFieldBind {hfbRHS=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"+#elif defined(GHCLIB_API_902) || defined (GHCLIB_API_900)   (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_" #elif defined (GHCLIB_API_810)   (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ _))}) -> True #else   (L _ HsRecField {hsRecFieldArg=(L _ (EWildPat _))}) -> True #endif+#if defined (GHCLIB_API_HEAD)+  (L _ HsFieldBind {hfbPun=True}) -> True+  (L _ HsFieldBind {}) -> False+#else   (L _ HsRecField {hsRecPun=True}) -> True   (L _ HsRecField {}) -> False+#endif  isUnboxed :: Boxity -> Bool isUnboxed = \case Unboxed -> True; _ -> False
src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs view
@@ -117,8 +117,16 @@ hasPFieldsDotDot _ = False  -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.+#if defined (GHCLIB_API_HEAD)+isPFieldWildcard :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LPat GhcPs) -> Bool+#else isPFieldWildcard :: LHsRecField GhcPs (LPat GhcPs) -> Bool-#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810)+#endif+#if defined (GHCLIB_API_HEAD)+isPFieldWildcard (L _ HsFieldBind {hfbRHS=L _ WildPat {}}) = True+isPFieldWildcard (L _ HsFieldBind {hfbPun=True}) = True+isPFieldWildcard (L _ HsFieldBind {}) = False+#elif defined (GHCLIB_API_902) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) isPFieldWildcard (L _ HsRecField {hsRecFieldArg=L _ WildPat {}}) = True isPFieldWildcard (L _ HsRecField {hsRecPun=True}) = True isPFieldWildcard (L _ HsRecField {}) = False@@ -136,8 +144,14 @@ #endif isPWildcard _ = False +#if defined (GHCLIB_API_HEAD)+isPFieldPun :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LPat GhcPs) -> Bool+#else isPFieldPun :: LHsRecField GhcPs (LPat GhcPs) -> Bool-#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810)+#endif+#if defined (GHCLIB_API_HEAD)+isPFieldPun (L _ HsFieldBind {hfbPun=True}) = True+#elif defined (GHCLIB_API_902) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) isPFieldPun (L _ HsRecField {hsRecPun=True}) = True #else isPFieldPun (dL -> L _ HsRecField {hsRecPun=True}) = True
src/Language/Haskell/GhclibParserEx/GHC/Types/Name/Reader.hs view
@@ -9,6 +9,10 @@  ) where +#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902)+import GHC.Parser.Annotation+#endif+ #if defined (GHCLIB_API_HEAD) || defined(GHCLIB_API_902) || defined (GHCLIB_API_900) import GHC.Types.SrcLoc import GHC.Types.Name@@ -23,21 +27,38 @@ -- These names may not seem natural here but they work out in -- practice. The use of thse two functions is thoroughly ubiquitous. occNameStr :: RdrName -> String; occNameStr = occNameString . rdrNameOcc-rdrNameStr :: Located RdrName -> String; rdrNameStr = occNameStr . unLoc+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902)+rdrNameStr :: GHC.Parser.Annotation.LocatedN RdrName -> String+#else+rdrNameStr :: Located RdrName -> String+#endif+rdrNameStr = occNameStr . unLoc  -- Builtin type or data constructors.+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902)+isSpecial :: LocatedN RdrName -> Bool+#else isSpecial :: Located RdrName -> Bool+#endif isSpecial (L _ (Exact n)) = isDataConName n || isTyConName n isSpecial _ = False  -- Coerce qualified names to unqualified (by discarding the -- qualifier).+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902)+unqual :: LocatedN RdrName -> LocatedN RdrName+#else unqual :: Located RdrName -> Located RdrName+#endif unqual (L loc (Qual _ n)) = L loc $ mkRdrUnqual n unqual x = x  -- Extract the occ name from a qualified/unqualified reader name.+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902)+fromQual :: LocatedN RdrName -> Maybe OccName+#else fromQual :: Located RdrName -> Maybe OccName+#endif fromQual (L _ (Qual _ x)) = Just x fromQual (L _ (Unqual x)) = Just x fromQual _ = Nothing
test/Test.hs view
@@ -19,7 +19,9 @@ import Data.Generics.Uniplate.Data #if defined (GHCLIB_API_HEAD) import GHC.Data.Bag-import GHC.Parser.Errors.Types+import GHC.Driver.Errors.Types+import GHC.Types.Error hiding (getMessages)+import qualified GHC.Types.Error (getMessages) #endif  import Language.Haskell.GhclibParserEx.Dump@@ -100,7 +102,7 @@     return relPath  #if defined (GHCLIB_API_HEAD)-chkParseResult :: (DynFlags -> Bag (MsgEnvelope PsMessage)  -> String) -> DynFlags -> ParseResult a -> IO ()+chkParseResult :: (DynFlags -> Bag (MsgEnvelope GhcMessage)  -> String) -> DynFlags -> ParseResult a -> IO () #else chkParseResult :: (DynFlags -> WarningMessages -> String) -> DynFlags -> ParseResult a -> IO () #endif@@ -113,20 +115,22 @@ #endif       when (not (null errs) || not (null wrns)) $ #if defined (GHCLIB_API_HEAD)-        assertFailure (report flags (fmap (mkParserWarn flags) wrns) ++ report flags (fmap mkParserErr errs))+        assertFailure (+          report flags (GHC.Types.Error.getMessages (GhcPsMessage <$> wrns)) +++          report flags (GHC.Types.Error.getMessages (GhcPsMessage <$> errs))+        )+ #elif defined (GHCLIB_API_902)         assertFailure (report flags (fmap pprWarning wrns) ++ report flags (fmap pprError errs)) #else         assertFailure (report flags wrns ++ report flags errs) #endif-#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_902) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) #if defined (GHCLIB_API_HEAD)-    PFailed s -> assertFailure (report flags $ fmap mkParserErr (snd (getMessages s)))+    PFailed s -> assertFailure (report flags $ GHC.Types.Error.getMessages (GhcPsMessage <$> snd (getMessages s))) #elif defined (GHCLIB_API_902)     PFailed s -> assertFailure (report flags $ fmap pprError (snd (getMessages s)))-#else+#elif defined (GHCLIB_API_900) || defined (GHCLIB_API_810)     PFailed s -> assertFailure (report flags $ snd (getMessages s flags))-#endif #else     PFailed _ loc err -> assertFailure (report flags $ unitBag $ mkPlainErrMsg flags loc err) #endif@@ -285,8 +289,16 @@   , testCase "isDot" $ test "f . g" $ \case L _ (OpApp _ _ op _) -> assert' $ isDot op; _ -> assertFailure "unexpected"   , testCase "isReturn" $ test "return x" $ \case L _ (HsApp _ f _) -> assert' $ isReturn f; _ -> assertFailure "unexpected"   , testCase "isReturn" $ test "pure x" $ \case L _ (HsApp _ f _) -> assert' $ isReturn f; _ -> assertFailure "unexpected"+#if defined (GHCLIB_API_HEAD)+  , testCase "isSection" $ test "(1 +)" $ \case L _ (HsPar _ _ x _) -> assert' $ isSection x; _ -> assertFailure "unexpected"+#else   , testCase "isSection" $ test "(1 +)" $ \case L _ (HsPar _ x) -> assert' $ isSection x; _ -> assertFailure "unexpected"+#endif+#if defined (GHCLIB_API_HEAD)+  , testCase "isSection" $ test "(+ 1)" $ \case L _ (HsPar _ _ x _) -> assert' $ isSection x; _ -> assertFailure "unexpected"+#else   , testCase "isSection" $ test "(+ 1)" $ \case L _ (HsPar _ x) -> assert' $ isSection x; _ -> assertFailure "unexpected"+#endif   , testCase "isRecConstr" $ test "Foo {bar=1}" $ assert' . isRecConstr   , testCase "isRecUpdate" $ test "foo {bar=1}" $ assert' . isRecUpdate   , testCase "isVar" $ test "foo" $ assert' . isVar