packages feed

ghc-lib-parser-ex 8.10.0.16 → 8.10.0.17

raw patch · 21 files changed

+192/−89 lines, 21 filesdep ~uniplatePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: uniplate

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,19 @@ # Changelog for ghc-lib-parser-ex +## 8.10.0.17 released 2020-12-20+- Update to ghc-8.10.3.++## 0.20201101 released 2020-11-01+- Update to `ghc-lib-0.20201101`++## 0.20201001 released 2020-10-01+- Update to `ghc-lib-0.20201001`+- `GHCLIB_API_811` -> `GHCLIB_API_HEAD`+- Add support for `GHCLIB_API_900`++## 0.20200901 released 2020-09-01+- Update to `ghc-lib-0.20200901`+ ## 8.10.0.16 released 2020-08-08 - Update to ghc-8.10.2. 
README.md view
@@ -27,7 +27,7 @@ ``` Run `stack runhaskell --package extra --package optparse-applicative CI.hs -- --help` for more options. -To run [`hlint`](https://github.com/ndmitchell/hlint) on this repository, `hlint --cpp-include cbits --cpp-define GHCLIB_API_XXX .` (where `XXX` at this time is one of `808`, `810` or `811`).+To run [`hlint`](https://github.com/ndmitchell/hlint) on this repository, `hlint --cpp-include cbits --cpp-define GHCLIB_API_XXX .` (where `XXX` at this time is one of `808`, `810` or `900`).  ## Releasing `ghc-lib-parser-ex` (notes for maintainers) 
cbits/ghclib_api.h view
@@ -6,23 +6,27 @@ #if !defined(GHCLIB_API_H) #  define GHCLIB_API_H -#  if !defined(GHCLIB_API_811) && !defined(GHCLIB_API_810) && !defined(GHCLIB_API_808)+#  if !defined (GHCLIB_API_HEAD) && !defined (GHCLIB_API_900) && !defined (GHCLIB_API_810) && !defined (GHCLIB_API_808) #    if defined(MIN_VERSION_ghc_lib_parser)-#       if !MIN_VERSION_ghc_lib_parser(1,  0,  0)-#         define GHCLIB_API_811-#       elif MIN_VERSION_ghc_lib_parser(8, 10, 0)+#       if !MIN_VERSION_ghc_lib_parser( 1,  0,  0)+#         define GHCLIB_API_HEAD+#       elif MIN_VERSION_ghc_lib_parser(9,  0,  0)+#         define GHCLIB_API_900+#       elif MIN_VERSION_ghc_lib_parser(8, 10,  0) #         define GHCLIB_API_810-#       elif MIN_VERSION_ghc_lib_parser(8,  8, 0)+#       elif MIN_VERSION_ghc_lib_parser(8,  8,  0) #         define GHCLIB_API_808 #       else #         error Unsupported GHC API version #      endif #    else #      if __GLASGOW_HASKELL__   == 811-#        define GHCLIB_API_811+#        define GHCLIB_API_HEAD+#      elif __GLASGOW_HASKELL__ == 900+#        define GHCLIB_API_900 #      elif __GLASGOW_HASKELL__ == 810 #        define GHCLIB_API_810-#      elif __GLASGOW_HASKELL__  == 808+#      elif __GLASGOW_HASKELL__ == 808 #        define GHCLIB_API_808 #      else #        error Unsupported GHC API version
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.18 name:           ghc-lib-parser-ex-version:        8.10.0.16+version:        8.10.0.17 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@@ -105,6 +105,7 @@     , directory >= 1.3.3     , filepath >= 1.4.2     , extra >=1.6+    , uniplate >= 1.6.12     , ghc-lib-parser-ex   if flag(auto) && impl(ghc >= 8.10.0) && impl(ghc < 8.11.0)     build-depends:
src/Language/Haskell/GhclibParserEx/Dump.hs view
@@ -17,7 +17,7 @@  #if !defined(MIN_VERSION_ghc_lib_parser) -- Using native ghc.-#  if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#  if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_810) import GHC.Hs.Dump #  else import HsDumpAst@@ -25,7 +25,7 @@ #else -- Using ghc-lib-parser. Recent versions will include -- GHC.Hs.Dump (it got moved in from ghc-lib on 2020-02-05).-# if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+# if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs.Dump #  else -- For simplicity, just assume it's missing from 8.8 ghc-lib-parser@@ -40,7 +40,7 @@ import Name import DataCon import SrcLoc-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs #else import HsSyn
src/Language/Haskell/GhclibParserEx/Fixity.hs view
@@ -16,9 +16,14 @@   , infixr_, infixl_, infix_, fixity   ) where -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Hs+#if defined (GHCLIB_API_HEAD)+import GHC.Types.Fixity+import GHC.Types.SourceText+#else import GHC.Types.Basic+#endif import GHC.Types.Name.Reader import GHC.Types.Name import GHC.Types.SrcLoc@@ -39,7 +44,7 @@ import Data.Data hiding (Fixity) import Data.Generics.Uniplate.Data -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) noExt :: NoExtField noExt = noExtField #endif@@ -59,7 +64,7 @@ -- LPat and Pat have gone through a lot of churn. See -- https://gitlab.haskell.org/ghc/ghc/merge_requests/1925 for details. patFix :: [(String, Fixity)] -> LPat GhcPs -> LPat GhcPs-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) patFix fixities (L loc (ConPat _ op (InfixCon pat1 pat2))) =   L loc (mkConOpPat (getFixities fixities) op (findFixity' (getFixities fixities) op) pat1 pat2) #elif defined (GHCLIB_API_810)@@ -76,26 +81,26 @@   -> Located RdrName -> Fixity   -> LPat GhcPs -> LPat GhcPs   -> Pat GhcPs-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) mkConOpPat fs op2 fix2 p1@(L loc (ConPat _ op1 (InfixCon p11 p12))) p2 #elif defined (GHCLIB_API_810) mkConOpPat fs op2 fix2 p1@(L loc (ConPatIn op1 (InfixCon p11 p12))) p2 #else mkConOpPat fs op2 fix2 p1@(dL->L loc (ConPatIn op1 (InfixCon p11 p12))) p2 #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)   | nofix_error = ConPat noExtField op2 (InfixCon p1 p2) #else   | nofix_error = ConPatIn op2 (InfixCon p1 p2) #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)   | associate_right = ConPat noExtField op1 (InfixCon p11 (L loc (mkConOpPat fs op2 fix2 p12 p2))) #elif defined (GHCLIB_API_810)   | associate_right = ConPatIn op1 (InfixCon p11 (L loc (mkConOpPat fs op2 fix2 p12 p2))) #else   | associate_right = ConPatIn op1 (InfixCon p11 (cL loc (mkConOpPat fs op2 fix2 p12 p2))) #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)   | otherwise = ConPat noExtField op2 (InfixCon p1 p2) #else   | otherwise = ConPatIn op2 (InfixCon p1 p2)@@ -103,7 +108,7 @@   where     fix1 = findFixity' fs op1     (nofix_error, associate_right) = compareFixity fix1 fix2-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) mkConOpPat _ op _ p1 p2 = ConPat noExtField op (InfixCon p1 p2) #else mkConOpPat _ op _ p1 p2 = ConPatIn op (InfixCon p1 p2)@@ -208,12 +213,12 @@ fixity :: FixityDirection -> Int -> [String] -> [(String, Fixity)] fixity a p = map (,Fixity (SourceText "") p a) -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) fixitiesFromModule :: Located HsModule -> [(String, Fixity)] #else fixitiesFromModule :: Located (HsModule GhcPs) -> [(String, Fixity)] #endif-#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) fixitiesFromModule (L _ (HsModule _ _ _ _ decls _ _)) = concatMap f decls #else fixitiesFromModule (L _ (HsModule _ _ _ decls _ _)) = concatMap f decls
src/Language/Haskell/GhclibParserEx/GHC/Driver/Flags.hs view
@@ -3,7 +3,7 @@ #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Driver.Flags () where -#if !defined(GHCLIB_API_811)+#if !defined (GHCLIB_API_HEAD) && !defined (GHCLIB_API_900) import DynFlags #endif 
src/Language/Haskell/GhclibParserEx/GHC/Driver/Session.hs view
@@ -14,15 +14,19 @@     , parsePragmasIntoDynFlags   ) where -#if defined(GHCLIB_API_808) || defined(GHCLIB_API_810)+#if defined (GHCLIB_API_808) || defined (GHCLIB_API_810) import qualified GHC.LanguageExtensions as LangExt #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Utils.Panic import GHC.Parser.Header import GHC.Data.StringBuffer import GHC.Driver.Session+#if defined (GHCLIB_API_HEAD)+import GHC.Types.SourceError+#else import GHC.Driver.Types+#endif #else import Panic import HeaderInfo
src/Language/Haskell/GhclibParserEx/GHC/Hs.hs view
@@ -9,11 +9,11 @@  ) where -#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Hs import GHC.Unit.Module import GHC.Types.SrcLoc-#elif defined(GHCLIB_API_810)+#elif defined (GHCLIB_API_810) import GHC.Hs import Module import SrcLoc@@ -23,7 +23,7 @@ import SrcLoc #endif -#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) modName :: Located HsModule -> String #else modName :: Located (HsModule GhcPs) -> String
src/Language/Haskell/GhclibParserEx/GHC/Hs/Binds.hs view
@@ -7,7 +7,7 @@   ) where -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs.Binds import GHC.Hs.Extension #else
src/Language/Haskell/GhclibParserEx/GHC/Hs/Decls.hs view
@@ -7,12 +7,12 @@     isNewType, isForD, isDerivD, isClsDefSig   ) where -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs #else import HsSyn #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Types.SrcLoc #else import SrcLoc
src/Language/Haskell/GhclibParserEx/GHC/Hs/Expr.hs view
@@ -16,12 +16,15 @@   fromChar   ) where -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs #else import HsSyn #endif-#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)+#if defined (GHCLIB_API_HEAD)+import GHC.Types.SourceText+#endif import GHC.Types.SrcLoc import GHC.Types.Name.Reader import GHC.Types.Name@@ -75,9 +78,12 @@   _ -> False isLCase = \case (L _ HsLamCase{}) -> True; _ -> False +#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_901)+isStrictMatch :: HsMatchContext GhcPs -> Bool+#else isStrictMatch :: HsMatchContext RdrName -> Bool-isStrictMatch FunRhs{mc_strictness=SrcStrict} = True-isStrictMatch _ = False+#endif+isStrictMatch = \case FunRhs{mc_strictness=SrcStrict} -> True; _ -> False  -- Field is punned e.g. '{foo}'. isFieldPun :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool@@ -98,10 +104,11 @@ isParComp :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool isParComp = \case ParStmt{} -> True; _ -> False -isMDo :: HsStmtContext Name -> Bool-#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)+isMDo :: HsStmtContext GhcRn -> Bool isMDo = \case MDoExpr _ -> True; _ -> False #else+isMDo :: HsStmtContext Name -> Bool isMDo = \case MDoExpr -> True; _ -> False #endif @@ -138,7 +145,7 @@ -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'. isFieldWildcard :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool isFieldWildcard = \case-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)   (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_" #elif defined (GHCLIB_API_810)   (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ _))}) -> True@@ -165,7 +172,7 @@ varToStr _ = ""  strToVar :: String -> LHsExpr GhcPs-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) strToVar x = noLoc $ HsVar noExtField (noLoc $ mkRdrUnqual (mkVarOcc x)) #else strToVar x = noLoc $ HsVar noExt (noLoc $ mkRdrUnqual (mkVarOcc x))
src/Language/Haskell/GhclibParserEx/GHC/Hs/ExtendInstances.hs view
@@ -18,8 +18,11 @@ -- representations rather than the terms themselves, leads to -- identical results. -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Utils.Outputable+#  if !defined(GHCLIB_API_900)+import GHC.Driver.Ppr+#  endif #else import Outputable #endif@@ -39,7 +42,11 @@ -- string representations. toStr :: Data a => HsExtendInstances a -> String toStr (HsExtendInstances e) =+#if defined(GHCLIB_API_HEAD)+  showPprUnsafe $ showAstData BlankSrcSpan e+#else   showSDocUnsafe $ showAstData BlankSrcSpan e+#endif  instance Data a => Eq (HsExtendInstances a) where (==) a b = toStr a == toStr b instance Data a => Ord (HsExtendInstances a) where compare = compare `on` toStr@@ -52,4 +59,9 @@  -- Use 'ppr' for 'Show'. instance Outputable a => Show (HsExtendInstances a) where-  show (HsExtendInstances e) =  showSDocUnsafe $ ppr e+  show (HsExtendInstances e) =+#if defined(GHCLIB_API_HEAD)+    showPprUnsafe $ ppr e+#else+    showSDocUnsafe $ ppr e+#endif
src/Language/Haskell/GhclibParserEx/GHC/Hs/ImpExp.hs view
@@ -14,7 +14,7 @@   ) where -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Hs.ImpExp import GHC.Types.Name.Reader #elif defined (GHCLIB_API_810)@@ -29,7 +29,7 @@ isPatSynIE IEPattern{} = True isPatSynIE _ = False -#if defined(MIN_VERSION_ghc_lib_parser)+#if defined (MIN_VERSION_ghc_lib_parser) #  if !MIN_VERSION_ghc_lib_parser(1,  0,  0) || MIN_VERSION_ghc_lib_parser(8, 10, 0) isImportQualifiedPost :: ImportDeclQualifiedStyle -> Bool isImportQualifiedPost QualifiedPost = True
src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs view
@@ -11,12 +11,12 @@   , isPFieldWildcard, isPWildcard, isPFieldPun, isPatTypeSig, isPBangPat, isPViewPat  ) where -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs #else import HsSyn #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Types.SrcLoc import GHC.Builtin.Types import GHC.Types.Name.Reader@@ -31,7 +31,7 @@ #endif  patToStr :: LPat GhcPs -> String-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "True" = "True" patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "False" = "False" patToStr (L _ (ConPat _ (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "[]" = "[]"@@ -51,41 +51,41 @@ strToPat :: String -> LPat GhcPs strToPat z   | z == "True"  =-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810)   noLoc $ #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)     ConPat noExtField (noLoc true_RDR) (PrefixCon []) #else     ConPatIn (noLoc true_RDR) (PrefixCon []) #endif   | z == "False" =-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810)   noLoc $ #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)     ConPat noExtField (noLoc false_RDR) (PrefixCon []) #else     ConPatIn (noLoc false_RDR) (PrefixCon []) #endif   | z == "[]"    =-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810)   noLoc $ #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)     ConPat noExtField (noLoc $ nameRdrName nilDataConName) (PrefixCon []) #else     ConPatIn (noLoc $ nameRdrName nilDataConName) (PrefixCon []) #endif   | otherwise =-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810)       noLoc $ VarPat noExtField (noLoc $ mkVarUnqual (fsLit z)) #else       VarPat noExt (noLoc $ mkVarUnqual (fsLit z)) #endif  fromPChar :: LPat GhcPs -> Maybe Char-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) fromPChar (L _ (LitPat _ (HsChar _ x))) = Just x #else fromPChar (dL -> L _ (LitPat _ (HsChar _ x))) = Just x@@ -99,7 +99,7 @@  -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'. isPFieldWildcard :: LHsRecField GhcPs (LPat GhcPs) -> Bool-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || 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@@ -110,7 +110,7 @@ #endif  isPWildcard :: LPat GhcPs -> Bool-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) isPWildcard (L _ (WildPat _)) = True #else isPWildcard (dL -> L _ (WildPat _)) = True@@ -118,7 +118,7 @@ isPWildcard _ = False  isPFieldPun :: LHsRecField GhcPs (LPat GhcPs) -> Bool-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) isPFieldPun (L _ HsRecField {hsRecPun=True}) = True #else isPFieldPun (dL -> L _ HsRecField {hsRecPun=True}) = True@@ -126,7 +126,7 @@ isPFieldPun _ = False  isPatTypeSig, isPBangPat, isPViewPat :: LPat GhcPs -> Bool-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) isPatTypeSig (L _ SigPat{}) = True; isPatTypeSig _ = False isPBangPat (L _ BangPat{}) = True; isPBangPat _ = False isPViewPat (L _ ViewPat{}) = True; isPViewPat _ = False
src/Language/Haskell/GhclibParserEx/GHC/Hs/Types.hs view
@@ -8,12 +8,12 @@   , isTyQuasiQuote, isUnboxedTuple   ) where -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs #else import HsSyn #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Types.SrcLoc #else import SrcLoc
src/Language/Haskell/GhclibParserEx/GHC/Parser.hs view
@@ -22,12 +22,15 @@   )   where -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs #else import HsSyn #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD)+import GHC.Driver.Config+#endif+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Parser.PostProcess import GHC.Driver.Session import GHC.Data.StringBuffer@@ -60,16 +63,20 @@   where     location = mkRealSrcLoc (mkFastString "<string>") 1 1     buffer = stringToStringBuffer str-    parseState = mkPState flags buffer location--#if defined (GHCLIB_API_811)+    parseState =+#if defined (GHCLIB_API_HEAD)+      initParserState (initParserOpts flags) buffer location+#else+      mkPState flags buffer location+#endif+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) parseModule :: String -> DynFlags -> ParseResult (Located HsModule) #else parseModule :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs)) #endif parseModule = parse Parser.parseModule -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) parseSignature :: String -> DynFlags -> ParseResult (Located HsModule) #else parseSignature :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))@@ -89,9 +96,14 @@ parseDeclaration = parse Parser.parseDeclaration  parseExpression :: String -> DynFlags -> ParseResult (LHsExpr GhcPs)-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) parseExpression s flags =   case parse Parser.parseExpression s flags of+    POk s e -> unP (runPV . unECP $ e) s+    PFailed ps -> PFailed ps+#elif defined (GHCLIB_API_810) || defined (GHCLIB_API_900)+parseExpression s flags =+  case parse Parser.parseExpression s flags of     POk s e -> unP (runECP_P e) s     PFailed ps -> PFailed ps #else@@ -113,14 +125,14 @@ parseType :: String -> DynFlags -> ParseResult (LHsType GhcPs) parseType = parse Parser.parseType -#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) parseHeader :: String -> DynFlags -> ParseResult (Located HsModule) #else parseHeader :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs)) #endif parseHeader = parse Parser.parseHeader -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) parseFile :: String           -> DynFlags           -> String@@ -136,4 +148,9 @@   where     location = mkRealSrcLoc (mkFastString filename) 1 1     buffer = stringToStringBuffer str-    parseState = mkPState flags buffer location+    parseState =+#if defined (GHCLIB_API_HEAD)+      initParserState (initParserOpts flags) buffer location+#else+      mkPState flags buffer location+#endif
src/Language/Haskell/GhclibParserEx/GHC/Settings/Config.hs view
@@ -11,7 +11,7 @@   ) where -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Settings.Config import GHC.Driver.Session import GHC.Utils.Fingerprint@@ -32,7 +32,7 @@  fakeSettings :: Settings fakeSettings = Settings-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)|| defined (GHCLIB_API_810)   { sGhcNameVersion=ghcNameVersion   , sFileSettings=fileSettings   , sTargetPlatform=platform@@ -49,7 +49,7 @@   } #endif   where-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)|| defined (GHCLIB_API_810)     toolSettings = ToolSettings {       toolSettings_opt_P_fingerprint=fingerprint0       }@@ -62,7 +62,7 @@ #endif     platform =       Platform{-#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)     -- It doesn't matter what values we write here as these fields are     -- not referenced for our purposes. However the fields are strict     -- so we must say something.@@ -73,13 +73,15 @@       , platformIsCrossCompiling=False       , platformLeadingUnderscore=False       , platformTablesNextToCode=False+#  if !defined (GHCLIB_API_900)       , platformConstants=platformConstants+#  endif       , #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD)         platformWordSize=PW8       , platformArchOS=ArchOS {archOS_arch=ArchUnknown, archOS_OS=OSUnknown}-#elif defined (GHCLIB_API_810)+#elif defined (GHCLIB_API_810) || defined (GHCLIB_API_900)         platformWordSize=PW8       , platformMini=PlatformMini {platformMini_arch=ArchUnknown, platformMini_os=OSUnknown} #else@@ -91,7 +93,7 @@     platformConstants =       PlatformConstants{pc_DYNAMIC_BY_DEFAULT=False,pc_WORD_SIZE=8} -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900)|| defined (GHCLIB_API_810) fakeLlvmConfig :: LlvmConfig fakeLlvmConfig = LlvmConfig [] [] #else
src/Language/Haskell/GhclibParserEx/GHC/Types/Name/Reader.hs view
@@ -9,7 +9,7 @@  ) where -#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Types.SrcLoc import GHC.Types.Name import GHC.Types.Name.Reader
src/Language/Haskell/GhclibParserEx/GHC/Utils/Outputable.hs view
@@ -8,11 +8,19 @@ ) where -#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Utils.Outputable+#if !defined (GHCLIB_API_900)+import GHC.Driver.Ppr+#endif #else import Outputable #endif  unsafePrettyPrint :: Outputable a => a -> String-unsafePrettyPrint = showSDocUnsafe . ppr+unsafePrettyPrint =+#if defined (GHCLIB_API_HEAD)+  showPprUnsafe . ppr+#else+  showSDocUnsafe . ppr+#endif
test/Test.hs view
@@ -16,6 +16,7 @@ import Control.Monad import Data.List.Extra import Data.Maybe+import Data.Generics.Uniplate.Data  import Language.Haskell.GhclibParserEx.Dump import Language.Haskell.GhclibParserEx.Fixity@@ -38,16 +39,20 @@ import Language.Haskell.GhclibParserEx.GHC.Driver.Session import Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader -#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810) import GHC.Hs #else import HsSyn #endif-#if defined (GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) import GHC.Types.SrcLoc import GHC.Driver.Session import GHC.Parser.Lexer import GHC.Utils.Outputable+#  if !defined (GHCLIB_API_900)+import GHC.Driver.Ppr+import GHC.Parser.Errors.Ppr+#  endif import GHC.Utils.Error import GHC.Types.Name.Reader import GHC.Types.Name.Occurrence@@ -65,6 +70,11 @@ import Bag #endif +#if defined (GHCLIB_API_HEAD)+showSDocUnsafe :: SDoc -> String+showSDocUnsafe = showPprUnsafe+#endif+ main :: IO () main = do   setEnv "TASTY_NUM_THREADS" "1"@@ -91,11 +101,23 @@ chkParseResult :: (DynFlags -> WarningMessages -> String) -> DynFlags -> ParseResult a -> IO () chkParseResult report flags = \case     POk s _ -> do+#if defined (GHCLIB_API_HEAD)+      let (wrns, errs) = getMessages s+#else       let (wrns, errs) = getMessages s flags+#endif       when (not (null errs) || not (null wrns)) $+#if defined (GHCLIB_API_HEAD)+        assertFailure (report flags (fmap pprWarning wrns) ++ report flags (fmap pprError errs))+#else         assertFailure (report flags wrns ++ report flags errs)-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#endif+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_HEAD)+    PFailed s -> assertFailure (report flags $ fmap pprError (snd (getMessages s)))+#else     PFailed s -> assertFailure (report flags $ snd (getMessages s flags))+#endif #else     PFailed _ loc err -> assertFailure (report flags $ unitBag $ mkPlainErrMsg flags loc err) #endif@@ -154,10 +176,10 @@         Right flags -> chkParseResult report flags $ parseFile foo flags s   ]   where-    flags = unsafeGlobalDynFlags+    flags = defaultDynFlags fakeSettings fakeLlvmConfig     report flags msgs = concat [ showSDoc flags msg | msg <- pprErrMsgBagWithLoc msgs ] -#if defined(GHCLIB_API_811)+#if defined (GHCLIB_API_HEAD) || defined (GHCLIB_API_900) moduleTest :: String -> DynFlags -> (Located HsModule -> IO ()) -> IO () #else moduleTest :: String -> DynFlags -> (Located (HsModule GhcPs) -> IO ()) -> IO ()@@ -238,7 +260,7 @@   , testCase "isVar" $ test "foo" $ assert' . isVar   , testCase "isVar" $ test "3" $ assert' . not. isVar   , testCase "isPar" $ test "(foo)" $ assert' . isPar-  , testCase "isPar" $ test "foo" $ assert' . not. isPar+  , testCase "isPar" $ test "foo" $ assert' . not . isPar   , testCase "isApp" $ test "f x" $ assert' . isApp   , testCase "isApp" $ test "x" $ assert' . not . isApp   , testCase "isOpApp" $ test "l `op` r" $ assert' . isOpApp@@ -285,6 +307,7 @@   , testCase "isQuasiQuote" $ test "[expr(1 + 2)]" $ assert' . not . isQuasiQuote   , testCase "isWholeFrac" $ test "3.2e1" $ assert' . isWholeFrac . unLoc   , testCase "isWholeFrac" $ test "3.22e1" $ assert' . not . isWholeFrac . unLoc+  , testCase "isMDo" $ test "mdo { pure () }" $ assert' . any isMDo . universeBi   , testCase "strToVar" $ assert' . isVar . strToVar $ "foo"   , testCase "varToStr" $ test "[]" $ assert' . (== "[]") . varToStr   , testCase "varToStr" $ test "foo" $ assert' . (== "foo") . varToStr@@ -294,7 +317,13 @@     assert' = assertBool ""     test s = exprTest s flags     flags = foldl' xopt_set (defaultDynFlags fakeSettings fakeLlvmConfig)-              [ TemplateHaskell, TemplateHaskellQuotes, QuasiQuotes, TypeApplications, LambdaCase ]+              [ TemplateHaskell+              , TemplateHaskellQuotes+              , QuasiQuotes+              , TypeApplications+              , LambdaCase+              , RecursiveDo+              ]  patternPredicateTests :: TestTree patternPredicateTests = testGroup "Pattern predicate tests"@@ -338,7 +367,7 @@         Left msg -> assertFailure msg         Right flags -> chkParseResult report flags $ parseFile foo flags s #if defined (MIN_VERSION_ghc_lib_parser)-#  if  !MIN_VERSION_ghc_lib_parser(1,  0,  0) || MIN_VERSION_ghc_lib_parser(8, 10, 0)+#  if !MIN_VERSION_ghc_lib_parser(1,  0,  0) || MIN_VERSION_ghc_lib_parser(8, 10, 0)   , testCase "ImportQualifiedPost" $ do       case parseImport "import Foo qualified" (flags `xopt_set` ImportQualifiedPost) of         POk _ (L _ decl) -> assertBool "expected postpositive" (isImportQualifiedPost . ideclQualified $ decl)@@ -352,7 +381,7 @@ #endif   ]   where-    flags = unsafeGlobalDynFlags+    flags = defaultDynFlags fakeSettings fakeLlvmConfig     report flags msgs = concat [ showSDoc flags msg | msg <- pprErrMsgBagWithLoc msgs ]  nameTests :: TestTree