packages feed

ghc-lib-parser-ex 8.8.6.0 → 8.8.6.1

raw patch · 23 files changed

+818/−308 lines, 23 filesdep ~ghcdep ~ghc-lib-parserPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: ghc, ghc-lib-parser

API changes (from Hackage documentation)

- Language.Haskell.GhclibParserEx.Config: fakeLlvmConfig :: (LlvmTargets, LlvmPasses)
- Language.Haskell.GhclibParserEx.Config: fakeSettings :: Settings
- Language.Haskell.GhclibParserEx.Dump: instance GHC.Classes.Eq Language.Haskell.GhclibParserEx.Dump.BlankSrcSpan
- Language.Haskell.GhclibParserEx.Dump: instance GHC.Show.Show Language.Haskell.GhclibParserEx.Dump.BlankSrcSpan
- Language.Haskell.GhclibParserEx.Outputable: unsafePrettyPrint :: Outputable a => a -> String
- Language.Haskell.GhclibParserEx.Parse: parse :: P a -> String -> DynFlags -> ParseResult a
- Language.Haskell.GhclibParserEx.Parse: parseBackpack :: String -> DynFlags -> ParseResult [LHsUnit PackageName]
- Language.Haskell.GhclibParserEx.Parse: parseDeclaration :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)
- Language.Haskell.GhclibParserEx.Parse: parseExpression :: String -> DynFlags -> ParseResult (LHsExpr GhcPs)
- Language.Haskell.GhclibParserEx.Parse: parseFile :: String -> DynFlags -> String -> ParseResult (Located (HsModule GhcPs))
- Language.Haskell.GhclibParserEx.Parse: parseHeader :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))
- Language.Haskell.GhclibParserEx.Parse: parseIdentifier :: String -> DynFlags -> ParseResult (Located RdrName)
- Language.Haskell.GhclibParserEx.Parse: parseImport :: String -> DynFlags -> ParseResult (LImportDecl GhcPs)
- Language.Haskell.GhclibParserEx.Parse: parseModule :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))
- Language.Haskell.GhclibParserEx.Parse: parsePattern :: String -> DynFlags -> ParseResult (LPat GhcPs)
- Language.Haskell.GhclibParserEx.Parse: parseSignature :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))
- Language.Haskell.GhclibParserEx.Parse: parseStatement :: String -> DynFlags -> ParseResult (LStmt GhcPs (LHsExpr GhcPs))
- Language.Haskell.GhclibParserEx.Parse: parseStmt :: String -> DynFlags -> ParseResult (Maybe (LStmt GhcPs (LHsExpr GhcPs)))
- Language.Haskell.GhclibParserEx.Parse: parseType :: String -> DynFlags -> ParseResult (LHsType GhcPs)
- Language.Haskell.GhclibParserEx.Parse: parseTypeSignature :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)
+ Language.Haskell.GhclibParserEx.Fixity: fixitiesFromModule :: Located (HsModule GhcPs) -> [(String, Fixity)]
+ Language.Haskell.GhclibParserEx.GHC.Hs: modName :: Located (HsModule GhcPs) -> String
+ Language.Haskell.GhclibParserEx.GHC.Hs.Binds: isPatSynBind :: HsBind GhcPs -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isFieldPunUpdate :: HsRecField' (AmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isMultiIf :: HsExpr GhcPs -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isProc :: HsExpr GhcPs -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isStrictMatch :: HsMatchContext RdrName -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isTransStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isWholeFrac :: HsExpr GhcPs -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp: isImportQualifiedPost :: ImportDeclQualifiedStyle -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp: isPatSynIE :: IEWrappedName RdrName -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Parser: parse :: P a -> String -> DynFlags -> ParseResult a
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseBackpack :: String -> DynFlags -> ParseResult [LHsUnit PackageName]
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseDeclaration :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseExpression :: String -> DynFlags -> ParseResult (LHsExpr GhcPs)
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseFile :: String -> DynFlags -> String -> ParseResult (Located (HsModule GhcPs))
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseHeader :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseIdentifier :: String -> DynFlags -> ParseResult (Located RdrName)
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseImport :: String -> DynFlags -> ParseResult (LImportDecl GhcPs)
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseModule :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))
+ Language.Haskell.GhclibParserEx.GHC.Parser: parsePattern :: String -> DynFlags -> ParseResult (LPat GhcPs)
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseSignature :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseStatement :: String -> DynFlags -> ParseResult (LStmt GhcPs (LHsExpr GhcPs))
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseStmt :: String -> DynFlags -> ParseResult (Maybe (LStmt GhcPs (LHsExpr GhcPs)))
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseType :: String -> DynFlags -> ParseResult (LHsType GhcPs)
+ Language.Haskell.GhclibParserEx.GHC.Parser: parseTypeSignature :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)
+ Language.Haskell.GhclibParserEx.GHC.Settings.Config: fakeLlvmConfig :: LlvmConfig
+ Language.Haskell.GhclibParserEx.GHC.Settings.Config: fakeSettings :: Settings
+ Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader: fromQual :: Located RdrName -> Maybe OccName
+ Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader: isSpecial :: Located RdrName -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader: isSymbolRdrName :: RdrName -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader: occNameStr :: RdrName -> String
+ Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader: rdrNameStr :: Located RdrName -> String
+ Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader: unqual :: Located RdrName -> Located RdrName
+ Language.Haskell.GhclibParserEx.GHC.Utils.Outputable: unsafePrettyPrint :: Outputable a => a -> String
- Language.Haskell.GhclibParserEx.GHC.Hs.Pat: hasPFieldsDotDot :: HsRecFields GhcPs (Pat GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Pat: hasPFieldsDotDot :: HsRecFields GhcPs (LPat GhcPs) -> Bool
- Language.Haskell.GhclibParserEx.GHC.Hs.Pat: isPFieldPun :: LHsRecField GhcPs (Pat GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Pat: isPFieldPun :: LHsRecField GhcPs (LPat GhcPs) -> Bool
- Language.Haskell.GhclibParserEx.GHC.Hs.Pat: isPFieldWildcard :: LHsRecField GhcPs (Pat GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Pat: isPFieldWildcard :: LHsRecField GhcPs (LPat GhcPs) -> Bool
- Language.Haskell.GhclibParserEx.GHC.Hs.Pat: strToPat :: String -> Pat GhcPs
+ Language.Haskell.GhclibParserEx.GHC.Hs.Pat: strToPat :: String -> LPat GhcPs

Files

ChangeLog.md view
@@ -1,5 +1,76 @@ # Changelog for ghc-lib-parser-ex +## 8.8.6.1 released 2020-07-16++## 0.20200704 released 2020-07-04+- New function `isImportQualifiedPost`++## 8.10.0.15 released 2020-07-04+- New function `isImportQualifiedPost`++## 8.10.0.14 released 2020-06-10+- New function `isSymbolRdrName`+- New module+  - `Language.Haskell.GhclibParserEx.GHC.Settings.Config` to replace `Language.Haskell.GhclibParserEx.Config` (which remains for now but deprecated and will be removed in a future release)++## 0.20200601 released 2020-06-01++## 8.10.0.13 released 2020-05-31+- Sync `extra` with HLint++## 8.10.0.12 released 2020-05-31+- New module `Language.Haskell.GhclibParserEx.GHC.Hs`++## 8.10.0.11 released 2020-05-18+- Upgrade to `ghc-lib-parser-8.10.1.20200523`++## 8.10.0.10 released 2020-05-18+- Upgrade to `ghc-lib-parser-8.10.1.20200518`++## 8.10.0.9 released 2020-05-16+- New modules+  - `Language.Haskell.GhclibParserEx.GHC.Hs.Binds`+  - `Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp`++## 8.10.0.8 released 2020-05-14+- New module `Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader`++## 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++## 8.10.0.5 released 2020-05-02+- New modules+  - `Language.Haskell.GhclibParserEx.GHC.Parser`, `Language.Haskell.GhcLibParserEx.GHC.Utils.Outputable` to replace `Language.Haskell.GhclibParserEx.Parse` and `Language.Haskell.GhclibParserEx.Outputable` (which remain for now but deprecated and will be removed in a future release)++## 0.20200501 released 2020-05-01++## 8.10.0.4 released 2020-04-04+- Add expression predicates `isWholeFrac`, `isFieldPunUpdate`, `isStrictMatch`, `isMultiIf`, `isProc`, `isTransStmt`;+- Add pattern predicate `isPFieldPun`.++## 8.10.0.3 released 2020-04-03+- `strToPat` now returns an `LPat GhcPs`+- `parseExpression` now returns an `ParseResult (LHsExpr GhcPs)` (>= ghc-8.10)++## 0.20200401 released 2020-04-01++## 8.10.0.2 released 2020-03-30+- Rework cabal flags; allow full configurability with a good default:+  - Have two flags `auto` and `no-ghc-lib`. Default behavior exactly as `hlint` linking `ghc-lib-parser-8.10.*` if not on `ghc-8.10.*` and `ghc-8.10.*` otherwise.++## 8.10.0.1 released 2020-03-28+- Unless the Cabal flag `ghc-lib` is `true` link native ghc-libs (without regard for the compiler version)+- Change the signature of `hasPFieldsDotDot`+  - This has no impact on 8.8 parse trees but matters when it comes to >= 8.10+- Change the signature of `isPFieldWildcard`+  - This has no impact on 8.8 parse trees but matters when it comes to >= 8.10++## 8.10.0.0 released 2020-03-24+- First release of the ghc-8.10 series+ ## 8.8.6.0 released 2020-03-22 - `Language.Haskell.GhclibParserEx.DynFlags` is now `Language.Haskell.GhclibParserEx.GHC.Driver.Session` 
README.md view
@@ -8,7 +8,9 @@  Package `ghc-lib-parser-ex` is on [Hackage](https://hackage.haskell.org/package/ghc-lib-parser-ex) e.g. `cabal install ghc-lib-parser-ex`. Like `ghc-lib-parser`, there are two release streams within the `ghc-lib-parser-ex` name. -Version numbers are of the form α.β.γ.δ where α.β corresponds to a GHC series and γ.δ are the major and minor parts of the `ghc-lib-ex-parser` package release. Examples:+### Versioning policy++Package `ghc-lib-parser-ex` does **not** conform to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). Version numbers are of the form α.β.γ.δ where α.β corresponds to a GHC series and γ.δ are the major and minor parts of the `ghc-lib-ex-parser` package release. Examples: * Version 8.10.1.3 is compatible with any `ghc-lib-parser-8.10.*` (or `ghc-8.10.*`) package; * Version 0.20190204.2.0 is compatible with [`ghc-lib-parser-0.20190204`](http://hackage.haskell.org/package/ghc-lib-0.20190204). 
cbits/ghclib_api.h view
@@ -11,7 +11,7 @@ #       if !MIN_VERSION_ghc_lib_parser(1,  0,  0) #         define GHCLIB_API_811 #       elif MIN_VERSION_ghc_lib_parser(8, 10, 0)-#         define GHCLIBAPI_810+#         define GHCLIB_API_810 #       elif MIN_VERSION_ghc_lib_parser(8,  8, 0) #         define GHCLIB_API_808 #       else
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.18 name:           ghc-lib-parser-ex-version:        8.8.6.0+version:        8.8.6.1 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@@ -22,23 +22,36 @@   type: git   location: https://github.com/shayne-fletcher/ghc-lib-parser-ex -flag ghc-lib+flag auto+  default: True+  manual: True+  description: Use default configuration++flag no-ghc-lib   default: False   manual: True-  description: Force dependency on ghc-lib-parser even if GHC API in the ghc package is supported+  description: Force dependency on native ghc-libs  library   exposed-modules:-      Language.Haskell.GhclibParserEx.Config       Language.Haskell.GhclibParserEx.Dump       Language.Haskell.GhclibParserEx.Fixity+      Language.Haskell.GhclibParserEx.GHC.Settings.Config       Language.Haskell.GhclibParserEx.GHC.Driver.Flags       Language.Haskell.GhclibParserEx.GHC.Driver.Session+      Language.Haskell.GhclibParserEx.GHC.Hs       Language.Haskell.GhclibParserEx.GHC.Hs.Expr       Language.Haskell.GhclibParserEx.GHC.Hs.Pat       Language.Haskell.GhclibParserEx.GHC.Hs.Types       Language.Haskell.GhclibParserEx.GHC.Hs.Decls+      Language.Haskell.GhclibParserEx.GHC.Hs.Binds+      Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp       Language.Haskell.GhclibParserEx.GHC.Hs.ExtendInstances+      Language.Haskell.GhclibParserEx.GHC.Parser+      Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader+      Language.Haskell.GhclibParserEx.GHC.Utils.Outputable+      -- Deprecated and will be removed in a future release.+      Language.Haskell.GhclibParserEx.Config       Language.Haskell.GhclibParserEx.Parse       Language.Haskell.GhclibParserEx.Outputable   other-modules:@@ -50,14 +63,24 @@       uniplate >= 1.5,       bytestring >= 0.10.8.2,       containers >= 0.5.8.1-  if !flag(ghc-lib) && impl(ghc >= 8.8.0) && impl(ghc < 8.9.0)-      build-depends:-        ghc == 8.8.*,-        ghc-boot-th,-        ghc-boot+  if flag(auto) && impl(ghc >= 8.10.0) && impl(ghc < 8.11.0)+    build-depends:+      ghc == 8.10.*,+      ghc-boot-th,+      ghc-boot   else+    if flag(auto)       build-depends:-        ghc-lib-parser+        ghc-lib-parser == 8.10.*+    else+      if flag(no-ghc-lib)+        build-depends:+          ghc,+          ghc-boot-th,+          ghc-boot+      else+        build-depends:+          ghc-lib-parser   include-dirs:       cbits   install-includes:@@ -83,11 +106,22 @@     , filepath >= 1.4.2     , extra >=1.6     , ghc-lib-parser-ex-  if !flag(ghc-lib) && impl(ghc >= 8.8.0) && impl(ghc < 8.9.0)-      build-depends:-        ghc == 8.8.*,-        ghc-boot-th+  if flag(auto) && impl(ghc >= 8.10.0) && impl(ghc < 8.11.0)+    build-depends:+      ghc == 8.10.*,+      ghc-boot-th,+      ghc-boot   else+    if flag(auto)       build-depends:-        ghc-lib-parser+        ghc-lib-parser == 8.10.*+    else+      if flag(no-ghc-lib)+        build-depends:+          ghc,+          ghc-boot-th,+          ghc-boot+      else+        build-depends:+          ghc-lib-parser   default-language: Haskell2010
src/Language/Haskell/GhclibParserEx/Config.hs view
@@ -1,79 +1,9 @@ -- Copyright (c) 2020, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# OPTIONS_GHC -Wno-missing-fields #-}-{-# LANGUAGE CPP #-}-#include "ghclib_api.h"--module Language.Haskell.GhclibParserEx.Config(-    fakeSettings-  , fakeLlvmConfig+module Language.Haskell.GhclibParserEx.Config+  {-# DEPRECATED "Use Language.Haskell.GhclibParserEx.GHC.Settings.Config instead" #-} (+  module Language.Haskell.GhclibParserEx.GHC.Settings.Config   )   where--import Config-#if defined (GHCLIB_API_811)-import GHC.Driver.Session-#else-import DynFlags-#endif-import Fingerprint--#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-import GHC.Platform-import ToolSettings-#else-import Platform-#endif--fakeSettings :: Settings-fakeSettings = Settings-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-  { sGhcNameVersion=ghcNameVersion-  , sFileSettings=fileSettings-  , sTargetPlatform=platform-  , sPlatformMisc=platformMisc-  , sPlatformConstants=platformConstants-  , sToolSettings=toolSettings-  }-#else-  { sTargetPlatform=platform-  , sPlatformConstants=platformConstants-  , sProjectVersion=cProjectVersion-  , sProgramName="ghc"-  , sOpt_P_fingerprint=fingerprint0-  }-#endif-  where-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-    toolSettings = ToolSettings {-      toolSettings_opt_P_fingerprint=fingerprint0-      }-    fileSettings = FileSettings {}-    platformMisc = PlatformMisc {}-    ghcNameVersion =-      GhcNameVersion{ghcNameVersion_programName="ghc"-                    ,ghcNameVersion_projectVersion=cProjectVersion-                    }-#endif-    platform =-      Platform{-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-        platformWordSize = PW8-      , platformMini = PlatformMini {platformMini_arch=ArchUnknown, platformMini_os=OSUnknown}-#else-        platformWordSize=8-      , platformOS=OSUnknown-#endif-      , platformUnregisterised=True-      }-    platformConstants =-      PlatformConstants{pc_DYNAMIC_BY_DEFAULT=False,pc_WORD_SIZE=8}--#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-fakeLlvmConfig :: LlvmConfig-fakeLlvmConfig = LlvmConfig [] []-#else-fakeLlvmConfig :: (LlvmTargets, LlvmPasses)-fakeLlvmConfig = ([], [])-#endif+import Language.Haskell.GhclibParserEx.GHC.Settings.Config
src/Language/Haskell/GhclibParserEx/Fixity.hs view
@@ -11,19 +11,30 @@  module Language.Haskell.GhclibParserEx.Fixity(     applyFixities+  , fixitiesFromModule   , preludeFixities, baseFixities   , infixr_, infixl_, infix_, fixity   ) where -import BasicTypes-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_811) import GHC.Hs+import GHC.Types.Basic+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Types.SrcLoc+#elif defined (GHCLIB_API_810)+import GHC.Hs+import BasicTypes+import RdrName+import OccName+import SrcLoc #else import HsSyn-#endif+import BasicTypes import RdrName import OccName import SrcLoc+#endif import Data.Maybe import Data.Data hiding (Fixity) import Data.Generics.Uniplate.Data@@ -48,7 +59,10 @@ -- 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) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_811)+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) patFix fixities (L loc (ConPatIn op (InfixCon pat1 pat2))) =   L loc (mkConOpPat (getFixities fixities) op (findFixity' (getFixities fixities) op) pat1 pat2) #else@@ -62,22 +76,38 @@   -> Located RdrName -> Fixity   -> LPat GhcPs -> LPat GhcPs   -> Pat GhcPs-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_811)+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)+  | nofix_error = ConPat noExtField op2 (InfixCon p1 p2)+#else   | nofix_error = ConPatIn op2 (InfixCon p1 p2)-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#endif+#if defined (GHCLIB_API_811)+  | 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)+  | otherwise = ConPat noExtField op2 (InfixCon p1 p2)+#else   | otherwise = ConPatIn op2 (InfixCon p1 p2)+#endif   where     fix1 = findFixity' fs op1     (nofix_error, associate_right) = compareFixity fix1 fix2+#if defined (GHCLIB_API_811)+mkConOpPat _ op _ p1 p2 = ConPat noExtField op (InfixCon p1 p2)+#else mkConOpPat _ op _ p1 p2 = ConPatIn op (InfixCon p1 p2)+#endif  mkOpApp ::   [(String, Fixity)]@@ -177,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 _ = []
src/Language/Haskell/GhclibParserEx/GHC/Driver/Flags.hs view
@@ -3,14 +3,14 @@ #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Driver.Flags () where -#if defined(GHCLIB_API_811)-import GHC.Driver.Session-#else+#if !defined(GHCLIB_API_811) import DynFlags #endif --- Oprhan instance until--- https://gitlab.haskell.org/ghc/ghc/merge_requests/2905 lands.+-- This instance landed in+-- https://gitlab.haskell.org/ghc/ghc/merge_requests/2905.+#if defined(GHCLIB_API_808) || defined(GHCLIB_API_810) instance Bounded Language where   minBound = Haskell98   maxBound = Haskell2010+#endif
src/Language/Haskell/GhclibParserEx/GHC/Driver/Session.hs view
@@ -4,38 +4,42 @@ {-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} #include "ghclib_api.h"- module Language.Haskell.GhclibParserEx.GHC.Driver.Session(       readExtension     , extensionImplications-    -- Copied from DynFlags (see-    -- https://gitlab.haskell.org/ghc/ghc/merge_requests/2654).+-- Landed in https://gitlab.haskell.org/ghc/ghc/merge_requests/2654.+#if defined (GHCLIB_API_808) || defined (GHCLIB_API_810)     , TurnOnFlag, turnOn, turnOff, impliedGFlags, impliedOffGFlags, impliedXFlags-    --+#endif     , parsePragmasIntoDynFlags   ) where +#if defined(GHCLIB_API_808) || defined(GHCLIB_API_810) import qualified GHC.LanguageExtensions as LangExt-import Panic-import HeaderInfo-import StringBuffer-#if defined(GHCLIB_API_811)+#endif+#if defined (GHCLIB_API_811)+import GHC.Utils.Panic+import GHC.Parser.Header+import GHC.Data.StringBuffer import GHC.Driver.Session import GHC.Driver.Types #else+import Panic+import HeaderInfo+import StringBuffer import DynFlags import HscTypes #endif import GHC.LanguageExtensions.Type import Data.List import Data.Maybe-import Data.Function import qualified Data.Map as Map---- Oprhan instance until--- https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 lands.+-- Landed in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707.+#if defined (GHCLIB_API_808) || defined (GHCLIB_API_810)+import Data.Function -- For `compareOn`. instance Ord Extension where   compare = compare `on` fromEnum+#endif  -- | Parse a GHC extension. readExtension :: String -> Maybe Extension@@ -51,7 +55,10 @@       [(show a, ([c | b], [c | not b]))         | (a, flag, c) <- impliedXFlags, let b = flag == turnOn] --- Copied from 'ghc/compiler/main/DynFlags.hs'.+-- Landed in+-- https://gitlab.haskell.org/ghc/ghc/merge_requests/2654. Copied from+-- 'ghc/compiler/main/DynFlags.hs'.+#if defined(GHCLIB_API_808) || defined(GHCLIB_API_810)  type TurnOnFlag = Bool   -- True  <=> we are turning the flag on                          -- False <=> we are turning the flag off@@ -104,7 +111,7 @@     , (LangExt.TypeInType,       turnOn, LangExt.PolyKinds)     , (LangExt.TypeInType,       turnOn, LangExt.KindSignatures) -#if defined(GHCLIB_API_811) || defined(GHCLIB_API_810)+#if defined(GHCLIB_API_810)     -- Standalone kind signatures are a replacement for CUSKs.     , (LangExt.StandaloneKindSignatures, turnOff, LangExt.CUSKs) #endif@@ -138,8 +145,7 @@     , (LangExt.TemplateHaskell, turnOn, LangExt.TemplateHaskellQuotes)     , (LangExt.Strict, turnOn, LangExt.StrictData)   ]----+#endif  parsePragmasIntoDynFlags :: DynFlags                          -> ([Extension], [Extension])@@ -149,10 +155,12 @@ parsePragmasIntoDynFlags flags (enable, disable) file str =   catchErrors $ do     let opts = getOptions flags (stringToStringBuffer str) file-    (flags, _, _) <- parseDynamicFilePragma flags opts+    -- Important : apply enables, disables *before* parsing dynamic+    -- file pragmas.     let flags' =  foldl' xopt_set flags enable     let flags'' = foldl' xopt_unset flags' disable-    return $ Right (flags'' `gopt_set` Opt_KeepRawTokenStream)+    (flags, _, _) <- parseDynamicFilePragma flags'' opts+    return $ Right (flags `gopt_set` Opt_KeepRawTokenStream)   where     catchErrors :: IO (Either String DynFlags) -> IO (Either String DynFlags)     catchErrors act = handleGhcException reportErr
+ src/Language/Haskell/GhclibParserEx/GHC/Hs.hs view
@@ -0,0 +1,32 @@+-- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.++{-# LANGUAGE CPP #-}+#include "ghclib_api.h"++module Language.Haskell.GhclibParserEx.GHC.Hs(+   modName+ )+where++#if defined(GHCLIB_API_811)+import GHC.Hs+import GHC.Unit.Module+import GHC.Types.SrcLoc+#elif defined(GHCLIB_API_810)+import GHC.Hs+import Module+import SrcLoc+#else+import HsSyn+import Module+import SrcLoc+#endif++#if defined(GHCLIB_API_811)+modName :: Located HsModule -> String+#else+modName :: Located (HsModule GhcPs) -> String+#endif+modName (L _ HsModule {hsmodName=Nothing}) = "Main"+modName (L _ HsModule {hsmodName=Just (L _ n)}) = moduleNameString n
+ src/Language/Haskell/GhclibParserEx/GHC/Hs/Binds.hs view
@@ -0,0 +1,20 @@+-- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.+{-# LANGUAGE CPP #-}+#include "ghclib_api.h"+module Language.Haskell.GhclibParserEx.GHC.Hs.Binds(+  isPatSynBind+  )+where++#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+import GHC.Hs.Binds+import GHC.Hs.Extension+#else+import HsBinds+import HsExtension+#endif++isPatSynBind :: HsBind GhcPs -> Bool+isPatSynBind PatSynBind{} = True+isPatSynBind _ = False
src/Language/Haskell/GhclibParserEx/GHC/Hs/Decls.hs view
@@ -12,7 +12,11 @@ #else import HsSyn #endif+#if defined (GHCLIB_API_811)+import GHC.Types.SrcLoc+#else import SrcLoc+#endif  isNewType :: NewOrData -> Bool isNewType NewType = True
src/Language/Haskell/GhclibParserEx/GHC/Hs/Expr.hs view
@@ -5,13 +5,12 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} #include "ghclib_api.h"- module Language.Haskell.GhclibParserEx.GHC.Hs.Expr(   isTag, isDol, isDot, isReturn, isSection, isRecConstr, isRecUpdate,   isVar, isPar, isApp, isOpApp, isAnyApp, isLexeme, isLambda, isQuasiQuote,   isDotApp, isTypeApp, isWHNF, isLCase,-  isFieldPun, isRecStmt, isParComp, isMDo, isTupleSection, isString, isPrimLiteral,-  isSpliceDecl, isFieldWildcard, isUnboxed,+  isFieldPun, isFieldPunUpdate, isRecStmt, isParComp, isMDo, isTupleSection, isString, isPrimLiteral,+  isSpliceDecl, isFieldWildcard, isUnboxed, isWholeFrac, isStrictMatch, isMultiIf, isProc, isTransStmt,   hasFieldsDotDot,   varToStr, strToVar,   fromChar@@ -22,12 +21,21 @@ #else import HsSyn #endif+#if defined(GHCLIB_API_811)+import GHC.Types.SrcLoc+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Types.Basic+import GHC.Builtin.Types+#else import SrcLoc import RdrName import OccName import Name import BasicTypes import TysWiredIn+#endif+import Data.Ratio  -- 'True' if the provided expression is a variable with name 'tag'. isTag :: String -> LHsExpr GhcPs -> Bool@@ -67,10 +75,19 @@   _ -> False isLCase = \case (L _ HsLamCase{}) -> True; _ -> False +isStrictMatch :: HsMatchContext RdrName -> Bool+isStrictMatch FunRhs{mc_strictness=SrcStrict} = True+isStrictMatch _ = False+ -- Field is punned e.g. '{foo}'. isFieldPun :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool isFieldPun = \case (L _ HsRecField {hsRecPun=True}) -> True; _ -> False +-- Field puns in updates have a different type to field puns in+-- constructions.+isFieldPunUpdate :: HsRecField' (AmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool+isFieldPunUpdate = \case HsRecField {hsRecPun=True} -> True; _ -> False+ -- Contains a '..' as in 'Foo{..}' hasFieldsDotDot :: HsRecFields GhcPs (LHsExpr GhcPs) -> Bool hasFieldsDotDot = \case HsRecFields {rec_dotdot=Just _} -> True; _ -> False@@ -82,7 +99,11 @@ isParComp = \case ParStmt{} -> True; _ -> False  isMDo :: HsStmtContext Name -> Bool+#if defined(GHCLIB_API_811)+isMDo = \case MDoExpr _ -> True; _ -> False+#else isMDo = \case MDoExpr -> True; _ -> False+#endif  isTupleSection :: HsTupArg GhcPs -> Bool isTupleSection = \case Missing{} -> True; _ -> False@@ -105,11 +126,22 @@ isSpliceDecl :: HsExpr GhcPs -> Bool isSpliceDecl = \case HsSpliceE{} -> True; _ -> False +isMultiIf :: HsExpr GhcPs -> Bool+isMultiIf = \case HsMultiIf{} -> True; _ -> False++isProc :: HsExpr GhcPs -> Bool+isProc = \case HsProc{} -> True; _ -> False++isTransStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool+isTransStmt = \case TransStmt{} -> True; _ -> False+ -- 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) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_811)   (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@@ -118,6 +150,11 @@  isUnboxed :: Boxity -> Bool isUnboxed = \case Unboxed -> True; _ -> False++isWholeFrac :: HsExpr GhcPs -> Bool+isWholeFrac (HsLit _ (HsRat _ (FL _ _ v) _)) = denominator v == 1+isWholeFrac (HsOverLit _ (OverLit _ (HsFractional (FL _ _ v)) _)) = denominator v == 1+isWholeFrac _ = False  varToStr :: LHsExpr GhcPs -> String varToStr (L _ (HsVar _ (L _ n)))
src/Language/Haskell/GhclibParserEx/GHC/Hs/ExtendInstances.hs view
@@ -2,6 +2,8 @@ -- SPDX-License-Identifier: BSD-3-Clause.  {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP #-}+#include "ghclib_api.h"  module Language.Haskell.GhclibParserEx.GHC.Hs.ExtendInstances (     HsExtendInstances(..), extendInstances, astEq, astListEq)@@ -16,10 +18,13 @@ -- representations rather than the terms themselves, leads to -- identical results. +#if defined (GHCLIB_API_811)+import GHC.Utils.Outputable+#else import Outputable+#endif import Data.Data import Data.Function- import Language.Haskell.GhclibParserEx.Dump  newtype HsExtendInstances a =@@ -34,7 +39,7 @@ -- string representations. toStr :: Data a => HsExtendInstances a -> String toStr (HsExtendInstances e) =-  Outputable.showSDocUnsafe $ showAstData BlankSrcSpan e+  showSDocUnsafe $ showAstData BlankSrcSpan e  instance Data a => Eq (HsExtendInstances a) where (==) a b = toStr a == toStr b instance Data a => Ord (HsExtendInstances a) where compare = compare `on` toStr@@ -47,4 +52,4 @@  -- Use 'ppr' for 'Show'. instance Outputable a => Show (HsExtendInstances a) where-  show (HsExtendInstances e) =  Outputable.showSDocUnsafe $ Outputable.ppr e+  show (HsExtendInstances e) =  showSDocUnsafe $ ppr e
+ src/Language/Haskell/GhclibParserEx/GHC/Hs/ImpExp.hs view
@@ -0,0 +1,42 @@+-- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.+{-# LANGUAGE CPP #-}+#include "ghclib_api.h"+module Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp(+    isPatSynIE+#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+#  endif+#elif  __GLASGOW_HASKELL__ >= 810+ , isImportQualifiedPost+#endif+  )+where++#if defined (GHCLIB_API_811)+import GHC.Hs.ImpExp+import GHC.Types.Name.Reader+#elif defined (GHCLIB_API_810)+import GHC.Hs.ImpExp+import RdrName+#else+import HsImpExp+import RdrName+#endif++isPatSynIE :: IEWrappedName RdrName -> Bool+isPatSynIE IEPattern{} = True+isPatSynIE _ = False++#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+isImportQualifiedPost _  = False+#  endif+#elif __GLASGOW_HASKELL__ >= 810+isImportQualifiedPost :: ImportDeclQualifiedStyle -> Bool+isImportQualifiedPost QualifiedPost = True+isImportQualifiedPost _  = False+#endif
src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs view
@@ -16,14 +16,27 @@ #else import HsSyn #endif+#if defined (GHCLIB_API_811)+import GHC.Types.SrcLoc+import GHC.Builtin.Types+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Data.FastString+#else import SrcLoc import TysWiredIn import RdrName import OccName import FastString+#endif  patToStr :: LPat GhcPs -> String-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+#if defined (GHCLIB_API_811)+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) == "[]" = "[]"+patToStr _ = ""+#elif defined (GHCLIB_API_810) patToStr (L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "True" = "True" patToStr (L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "False" = "False" patToStr (L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "[]" = "[]"@@ -35,14 +48,38 @@ patToStr _ = "" #endif -strToPat :: String -> Pat GhcPs+strToPat :: String -> LPat GhcPs strToPat z-  | z == "True"  = ConPatIn (noLoc true_RDR) (PrefixCon [])-  | z == "False" = ConPatIn (noLoc false_RDR) (PrefixCon [])-  | z == "[]"    = ConPatIn (noLoc $ nameRdrName nilDataConName) (PrefixCon [])+  | z == "True"  =+#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+  noLoc $+#endif+#if defined (GHCLIB_API_811)+    ConPat noExtField (noLoc true_RDR) (PrefixCon [])+#else+    ConPatIn (noLoc true_RDR) (PrefixCon [])+#endif+  | z == "False" =+#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+  noLoc $+#endif+#if defined (GHCLIB_API_811)+    ConPat noExtField (noLoc false_RDR) (PrefixCon [])+#else+    ConPatIn (noLoc false_RDR) (PrefixCon [])+#endif+  | z == "[]"    =+#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+  noLoc $+#endif+#if defined (GHCLIB_API_811)+    ConPat noExtField (noLoc $ nameRdrName nilDataConName) (PrefixCon [])+#else+    ConPatIn (noLoc $ nameRdrName nilDataConName) (PrefixCon [])+#endif   | otherwise = #if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-      VarPat noExtField (noLoc $ mkVarUnqual (fsLit z))+      noLoc $ VarPat noExtField (noLoc $ mkVarUnqual (fsLit z)) #else       VarPat noExt (noLoc $ mkVarUnqual (fsLit z)) #endif@@ -56,18 +93,18 @@ fromPChar _ = Nothing  -- Contains a '..' as in 'Foo{..}'-hasPFieldsDotDot :: HsRecFields GhcPs (Pat GhcPs) -> Bool+hasPFieldsDotDot :: HsRecFields GhcPs (LPat GhcPs) -> Bool hasPFieldsDotDot HsRecFields {rec_dotdot=Just _} = True hasPFieldsDotDot _ = False  -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.-isPFieldWildcard :: LHsRecField GhcPs (Pat GhcPs) -> Bool+isPFieldWildcard :: LHsRecField GhcPs (LPat GhcPs) -> Bool #if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-isPFieldWildcard (L _ HsRecField {hsRecFieldArg=WildPat _}) = True+isPFieldWildcard (L _ HsRecField {hsRecFieldArg=L _ WildPat {}}) = True isPFieldWildcard (L _ HsRecField {hsRecPun=True}) = True isPFieldWildcard (L _ HsRecField {}) = False #else-isPFieldWildcard (dL -> L _ HsRecField {hsRecFieldArg=WildPat _}) = True+isPFieldWildcard (dL -> L _ HsRecField {hsRecFieldArg=LL _ WildPat {}}) = True isPFieldWildcard (dL -> L _ HsRecField {hsRecPun=True}) = True isPFieldWildcard (dL -> L _ HsRecField {}) = False #endif@@ -80,7 +117,7 @@ #endif isPWildcard _ = False -isPFieldPun :: LHsRecField GhcPs (Pat GhcPs) -> Bool+isPFieldPun :: LHsRecField GhcPs (LPat GhcPs) -> Bool #if defined (GHCLIB_API_811) || defined (GHCLIB_API_810) isPFieldPun (L _ HsRecField {hsRecPun=True}) = True #else
src/Language/Haskell/GhclibParserEx/GHC/Hs/Types.hs view
@@ -13,7 +13,11 @@ #else import HsSyn #endif+#if defined (GHCLIB_API_811)+import GHC.Types.SrcLoc+#else import SrcLoc+#endif  fromTyParen :: LHsType GhcPs -> LHsType GhcPs fromTyParen (L _ (HsParTy _ x)) = x
+ src/Language/Haskell/GhclibParserEx/GHC/Parser.hs view
@@ -0,0 +1,139 @@+-- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.++{-# LANGUAGE CPP #-}+#include "ghclib_api.h"+module Language.Haskell.GhclibParserEx.GHC.Parser(+    parseFile+  , parseModule+  , parseSignature+  , parseImport+  , parseStatement+  , parseBackpack+  , parseDeclaration+  , parseExpression+  , parsePattern+  , parseTypeSignature+  , parseStmt+  , parseIdentifier+  , parseType+  , parseHeader+  , parse+  )+  where++#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+import GHC.Hs+#else+import HsSyn+#endif+#if defined (GHCLIB_API_811)+import GHC.Parser.PostProcess+import GHC.Driver.Session+import GHC.Data.StringBuffer+import GHC.Parser.Lexer+import qualified GHC.Parser.Lexer as Lexer+import qualified GHC.Parser as Parser+import GHC.Data.FastString+import GHC.Types.SrcLoc+import GHC.Driver.Backpack.Syntax+import GHC.Unit.Info+import GHC.Types.Name.Reader+#else+import DynFlags+import StringBuffer+import Lexer+import qualified Parser+import FastString+import SrcLoc+import BkpSyn+import PackageConfig+import RdrName+#endif+#if defined (GHCLIB_API_810)+import RdrHsSyn+#endif++parse :: P a -> String -> DynFlags -> ParseResult a+parse p str flags =+  Lexer.unP p parseState+  where+    location = mkRealSrcLoc (mkFastString "<string>") 1 1+    buffer = stringToStringBuffer str+    parseState = mkPState flags buffer location++#if defined (GHCLIB_API_811)+parseModule :: String -> DynFlags -> ParseResult (Located HsModule)+#else+parseModule :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))+#endif+parseModule = parse Parser.parseModule++#if defined (GHCLIB_API_811)+parseSignature :: String -> DynFlags -> ParseResult (Located HsModule)+#else+parseSignature :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))+#endif+parseSignature = parse Parser.parseSignature++parseImport :: String -> DynFlags -> ParseResult (LImportDecl GhcPs)+parseImport = parse Parser.parseImport++parseStatement :: String -> DynFlags -> ParseResult (LStmt GhcPs (LHsExpr GhcPs))+parseStatement = parse Parser.parseStatement++parseBackpack :: String -> DynFlags -> ParseResult [LHsUnit PackageName]+parseBackpack = parse Parser.parseBackpack++parseDeclaration :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)+parseDeclaration = parse Parser.parseDeclaration++parseExpression :: String -> DynFlags -> ParseResult (LHsExpr GhcPs)+#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+parseExpression s flags =+  case parse Parser.parseExpression s flags of+    POk s e -> unP (runECP_P e) s+    PFailed ps -> PFailed ps+#else+parseExpression = parse Parser.parseExpression+#endif++parsePattern :: String -> DynFlags -> ParseResult (LPat GhcPs)+parsePattern = parse Parser.parsePattern++parseTypeSignature :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)+parseTypeSignature = parse Parser.parseTypeSignature++parseStmt :: String -> DynFlags -> ParseResult (Maybe (LStmt GhcPs (LHsExpr GhcPs)))+parseStmt = parse Parser.parseStmt++parseIdentifier :: String -> DynFlags -> ParseResult (Located RdrName)+parseIdentifier = parse Parser.parseIdentifier++parseType :: String -> DynFlags -> ParseResult (LHsType GhcPs)+parseType = parse Parser.parseType++#if defined(GHCLIB_API_811)+parseHeader :: String -> DynFlags -> ParseResult (Located HsModule)+#else+parseHeader :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))+#endif+parseHeader = parse Parser.parseHeader++#if defined (GHCLIB_API_811)+parseFile :: String+          -> DynFlags+          -> String+          -> ParseResult (Located HsModule)+#else+parseFile :: String+          -> DynFlags+          -> String+          -> ParseResult (Located (HsModule GhcPs))+#endif+parseFile filename flags str =+  unP Parser.parseModule parseState+  where+    location = mkRealSrcLoc (mkFastString filename) 1 1+    buffer = stringToStringBuffer str+    parseState = mkPState flags buffer location
+ src/Language/Haskell/GhclibParserEx/GHC/Settings/Config.hs view
@@ -0,0 +1,96 @@+-- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.++{-# OPTIONS_GHC -Wno-missing-fields #-}+{-# LANGUAGE CPP #-}+#include "ghclib_api.h"++module Language.Haskell.GhclibParserEx.GHC.Settings.Config(+    fakeSettings+  , fakeLlvmConfig+  )+where++#if defined (GHCLIB_API_811)+import GHC.Settings.Config+import GHC.Driver.Session+import GHC.Utils.Fingerprint+import GHC.Platform+import GHC.Settings+#elif defined (GHCLIB_API_810)+import Config+import DynFlags+import Fingerprint+import GHC.Platform+import ToolSettings+#else+import Config+import DynFlags+import Fingerprint+import Platform+#endif++fakeSettings :: Settings+fakeSettings = Settings+#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+  { sGhcNameVersion=ghcNameVersion+  , sFileSettings=fileSettings+  , sTargetPlatform=platform+  , sPlatformMisc=platformMisc+  , sPlatformConstants=platformConstants+  , sToolSettings=toolSettings+  }+#else+  { sTargetPlatform=platform+  , sPlatformConstants=platformConstants+  , sProjectVersion=cProjectVersion+  , sProgramName="ghc"+  , sOpt_P_fingerprint=fingerprint0+  }+#endif+  where+#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+    toolSettings = ToolSettings {+      toolSettings_opt_P_fingerprint=fingerprint0+      }+    fileSettings = FileSettings {}+    platformMisc = PlatformMisc {}+    ghcNameVersion =+      GhcNameVersion{ghcNameVersion_programName="ghc"+                    ,ghcNameVersion_projectVersion=cProjectVersion+                    }+#endif+    platform =+      Platform{+#if defined(GHCLIB_API_811)+    -- 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.+        platformByteOrder=LittleEndian+      , platformHasGnuNonexecStack=True+      , platformHasIdentDirective=False+      , platformHasSubsectionsViaSymbols=False+      , platformIsCrossCompiling=False+      , platformLeadingUnderscore=False+      , platformTablesNextToCode=False+      ,+#endif+#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+        platformWordSize = PW8+      , platformMini = PlatformMini {platformMini_arch=ArchUnknown, platformMini_os=OSUnknown}+#else+        platformWordSize=8+      , platformOS=OSUnknown+#endif+      , platformUnregisterised=True+      }+    platformConstants =+      PlatformConstants{pc_DYNAMIC_BY_DEFAULT=False,pc_WORD_SIZE=8}++#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)+fakeLlvmConfig :: LlvmConfig+fakeLlvmConfig = LlvmConfig [] []+#else+fakeLlvmConfig :: (LlvmTargets, LlvmPasses)+fakeLlvmConfig = ([], [])+#endif
+ src/Language/Haskell/GhclibParserEx/GHC/Types/Name/Reader.hs view
@@ -0,0 +1,48 @@+-- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.++{-# LANGUAGE CPP #-}+#include "ghclib_api.h"++module Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader(+   occNameStr, rdrNameStr, isSpecial, unqual, fromQual, isSymbolRdrName+ )+where++#if defined(GHCLIB_API_811)+import GHC.Types.SrcLoc+import GHC.Types.Name+import GHC.Types.Name.Reader+#else+import SrcLoc+import RdrName+import OccName+import Name+#endif++-- 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++-- Builtin type or data constructors.+isSpecial :: Located RdrName -> Bool+isSpecial (L _ (Exact n)) = isDataConName n || isTyConName n+isSpecial _ = False++-- Coerce qualified names to unqualified (by discarding the+-- qualifier).+unqual :: Located RdrName -> Located RdrName+unqual (L loc (Qual _ n)) = L loc $ mkRdrUnqual n+unqual x = x++-- Extract the occ name from a qualified/unqualified reader name.+fromQual :: Located RdrName -> Maybe OccName+fromQual (L _ (Qual _ x)) = Just x+fromQual (L _ (Unqual x)) = Just x+fromQual _ = Nothing++-- Test if the reader name is that of an operator (be it a data+-- constructor, variable or whatever).+isSymbolRdrName :: RdrName -> Bool+isSymbolRdrName = isSymOcc . rdrNameOcc
+ src/Language/Haskell/GhclibParserEx/GHC/Utils/Outputable.hs view
@@ -0,0 +1,18 @@+-- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.++{-# LANGUAGE CPP #-}+#include "ghclib_api.h"+module Language.Haskell.GhclibParserEx.GHC.Utils.Outputable (+    unsafePrettyPrint+)+where++#if defined (GHCLIB_API_811)+import GHC.Utils.Outputable+#else+import Outputable+#endif++unsafePrettyPrint :: Outputable a => a -> String+unsafePrettyPrint = showSDocUnsafe . ppr
src/Language/Haskell/GhclibParserEx/Outputable.hs view
@@ -1,9 +1,9 @@ -- Copyright (c) 2020, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -module Language.Haskell.GhclibParserEx.Outputable (unsafePrettyPrint) where--import Outputable--unsafePrettyPrint :: (Outputable.Outputable a) => a -> String-unsafePrettyPrint = Outputable.showSDocUnsafe . Outputable.ppr+module Language.Haskell.GhclibParserEx.Outputable+  {-# DEPRECATED "Use Language.Haskell.GhclibParserEx.GHC.Utils.Outputable instead" #-} (+  module Language.Haskell.GhclibParserEx.GHC.Utils.Outputable+  )+  where+import Language.Haskell.GhclibParserEx.GHC.Utils.Outputable
src/Language/Haskell/GhclibParserEx/Parse.hs view
@@ -1,134 +1,9 @@ -- Copyright (c) 2020, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# OPTIONS_GHC -Wno-missing-fields #-}-{-# LANGUAGE CPP #-}-#include "ghclib_api.h"--module Language.Haskell.GhclibParserEx.Parse(-    parseFile-  , parseModule-  , parseSignature-  , parseImport-  , parseStatement-  , parseBackpack-  , parseDeclaration-  , parseExpression-  , parsePattern-  , parseTypeSignature-  , parseStmt-  , parseIdentifier-  , parseType-  , parseHeader-  , parse+module Language.Haskell.GhclibParserEx.Parse+  {-# DEPRECATED "Use Language.Haskell.GhclibParserEx.GHC.Parser instead" #-} (+  module Language.Haskell.GhclibParserEx.GHC.Parser   )   where--#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-import GHC.Hs-import RdrHsSyn-#else-import HsSyn-#endif-#if defined (GHCLIB_API_811)-import GHC.Driver.Session-#else-import DynFlags-#endif-import StringBuffer-import Lexer-import qualified Parser-import FastString-import SrcLoc-#if defined (GHCLIB_API_811)-import GHC.Driver.Backpack.Syntax-#else-import BkpSyn-#endif-#if defined (GHCLIB_API_811)-import UnitInfo-#else-import PackageConfig-#endif-import RdrName--parse :: P a -> String -> DynFlags -> ParseResult a-parse p str flags =-  Lexer.unP p parseState-  where-    location = mkRealSrcLoc (mkFastString "<string>") 1 1-    buffer = stringToStringBuffer str-    parseState = mkPState flags buffer location--#if defined (GHCLIB_API_811)-parseModule :: String -> DynFlags -> ParseResult (Located HsModule)-#else-parseModule :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))-#endif-parseModule = parse Parser.parseModule--#if defined (GHCLIB_API_811)-parseSignature :: String -> DynFlags -> ParseResult (Located HsModule)-#else-parseSignature :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))-#endif-parseSignature = parse Parser.parseSignature--parseImport :: String -> DynFlags -> ParseResult (LImportDecl GhcPs)-parseImport = parse Parser.parseImport--parseStatement :: String -> DynFlags -> ParseResult (LStmt GhcPs (LHsExpr GhcPs))-parseStatement = parse Parser.parseStatement--parseBackpack :: String -> DynFlags -> ParseResult [LHsUnit PackageName]-parseBackpack = parse Parser.parseBackpack--parseDeclaration :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)-parseDeclaration = parse Parser.parseDeclaration--#if defined (GHCLIB_API_811)-parseExpression :: String -> DynFlags -> ParseResult RdrHsSyn.ECP-#else-parseExpression :: String -> DynFlags -> ParseResult (LHsExpr GhcPs)-#endif-parseExpression = parse Parser.parseExpression--parsePattern :: String -> DynFlags -> ParseResult (LPat GhcPs)-parsePattern = parse Parser.parsePattern--parseTypeSignature :: String -> DynFlags -> ParseResult (LHsDecl GhcPs)-parseTypeSignature = parse Parser.parseTypeSignature--parseStmt :: String -> DynFlags -> ParseResult (Maybe (LStmt GhcPs (LHsExpr GhcPs)))-parseStmt = parse Parser.parseStmt--parseIdentifier :: String -> DynFlags -> ParseResult (Located RdrName)-parseIdentifier = parse Parser.parseIdentifier--parseType :: String -> DynFlags -> ParseResult (LHsType GhcPs)-parseType = parse Parser.parseType--#if defined(GHCLIB_API_811)-parseHeader :: String -> DynFlags -> ParseResult (Located HsModule)-#else-parseHeader :: String -> DynFlags -> ParseResult (Located (HsModule GhcPs))-#endif-parseHeader = parse Parser.parseHeader--#if defined (GHCLIB_API_811)-parseFile :: String-          -> DynFlags-          -> String-          -> ParseResult (Located HsModule)-#else-parseFile :: String-          -> DynFlags-          -> String-          -> ParseResult (Located (HsModule GhcPs))-#endif-parseFile filename flags str =-  unP Parser.parseModule parseState-  where-    location = mkRealSrcLoc (mkFastString filename) 1 1-    buffer = stringToStringBuffer str-    parseState = mkPState flags buffer location+import Language.Haskell.GhclibParserEx.GHC.Parser
test/Test.hs view
@@ -17,31 +17,49 @@ import Data.List.Extra import Data.Maybe -import Language.Haskell.GhclibParserEx.Config-import Language.Haskell.GhclibParserEx.Parse import Language.Haskell.GhclibParserEx.Dump import Language.Haskell.GhclibParserEx.Fixity+import Language.Haskell.GhclibParserEx.GHC.Settings.Config+import Language.Haskell.GhclibParserEx.GHC.Parser+import Language.Haskell.GhclibParserEx.GHC.Hs import Language.Haskell.GhclibParserEx.GHC.Hs.ExtendInstances import Language.Haskell.GhclibParserEx.GHC.Hs.Expr import Language.Haskell.GhclibParserEx.GHC.Hs.Pat+-- We only test 'isImportQualifiedPost' at this time which requires >=+-- 8.10; avoid unused import warning.+#if defined (MIN_VERSION_ghc_lib_parser)+#  if !MIN_VERSION_ghc_lib_parser(1,  0,  0) || MIN_VERSION_ghc_lib_parser(8, 10, 0)+import Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp+#  endif+#elif __GLASGOW_HASKELL__ >= 810+import Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp+#endif import Language.Haskell.GhclibParserEx.GHC.Driver.Flags() import Language.Haskell.GhclibParserEx.GHC.Driver.Session+import Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader  #if defined (GHCLIB_API_811) || defined (GHCLIB_API_810) import GHC.Hs-import RdrHsSyn #else import HsSyn #endif-import SrcLoc #if defined (GHCLIB_API_811)+import GHC.Types.SrcLoc import GHC.Driver.Session+import GHC.Parser.Lexer+import GHC.Utils.Outputable+import GHC.Utils.Error+import GHC.Types.Name.Reader+import GHC.Types.Name.Occurrence #else+import SrcLoc import DynFlags-#endif import Lexer import Outputable import ErrUtils+import RdrName+import OccName+#endif import GHC.LanguageExtensions.Type #if defined (GHCLIB_API_808) import Bag@@ -61,6 +79,7 @@   , expressionPredicateTests   , patternPredicateTests   , dynFlagsTests+  , nameTests   ]  makeFile :: FilePath -> String -> IO FilePath@@ -138,59 +157,56 @@     flags = unsafeGlobalDynFlags     report flags msgs = concat [ showSDoc flags msg | msg <- pprErrMsgBagWithLoc msgs ] +#if defined(GHCLIB_API_811)+moduleTest :: String -> DynFlags -> (Located HsModule -> IO ()) -> IO ()+#else+moduleTest :: String -> DynFlags -> (Located (HsModule GhcPs) -> IO ()) -> IO ()+#endif+moduleTest s flags test =+      case parseModule s flags of+        POk _ e -> test e+        _ -> assertFailure "parse error"+ exprTest :: String -> DynFlags -> (LHsExpr GhcPs -> IO ()) -> IO () exprTest s flags test =       case parseExpression s flags of-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-        POk s e ->-#else-        POk _ e ->-#endif-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-          case unP (runECP_P e >>= \e -> return e) s :: ParseResult (LHsExpr GhcPs) of-            POk _  e ->-#endif-              test e-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-            _ -> assertFailure "parse error"-#endif+        POk _ e -> test e         _ -> assertFailure "parse error"  patTest :: String -> DynFlags -> (LPat GhcPs -> IO ()) -> IO () patTest s flags test =       case parsePattern s flags of-#if defined (GHCLIB_API_811) || defined (GHCLIB_API_810)-        POk _ e ->-#else-        POk _ e ->-#endif-              test e+        POk _ e -> test e         _ -> assertFailure "parse error"  fixityTests :: TestTree fixityTests = testGroup "Fixity tests"-  [ testCase "Expression" $ do-      let flags = defaultDynFlags fakeSettings fakeLlvmConfig+  [ testCase "Expression" $       exprTest "1 + 2 * 3" flags         (\e ->             assertBool "parse tree not affected" $               showSDocUnsafe (showAstData BlankSrcSpan e) /=               showSDocUnsafe (showAstData BlankSrcSpan (applyFixities [] e))         )-  , testCase "Pattern" $ do-      let flags = defaultDynFlags fakeSettings fakeLlvmConfig+  , testCase "Pattern" $       case parseDeclaration "f (1 : 2 :[]) = 1" flags of         POk _ d ->           assertBool "parse tree not affected" $           showSDocUnsafe (showAstData BlankSrcSpan d) /=           showSDocUnsafe (showAstData BlankSrcSpan (applyFixities [] d))         PFailed{} -> assertFailure "parse error"+  , testCase "fixitiesFromModule" $+      case parseModule "infixl 4 <*!" flags of+        POk _ m ->+          assertBool "one fixity expected" $ not (null (fixitiesFromModule m))+        PFailed{} -> assertFailure "parse error"   ]+  where+    flags = defaultDynFlags fakeSettings fakeLlvmConfig  extendInstancesTests :: TestTree extendInstancesTests = testGroup "Extend instances tests"-  [ testCase "Eq, Ord" $ do-      let flags = defaultDynFlags fakeSettings fakeLlvmConfig+  [ testCase "Eq, Ord" $       exprTest "1 + 2 * 3" flags         (\e -> do              e' <- return $ applyFixities [] e@@ -204,6 +220,8 @@              assertBool ">=" $ e  >= e'           )   ]+  where+    flags = defaultDynFlags fakeSettings fakeLlvmConfig  expressionPredicateTests :: TestTree expressionPredicateTests = testGroup "Expression predicate tests"@@ -237,7 +255,7 @@   , testCase "isDotApp" $ test "f . g" $ assert' . isDotApp   , testCase "isDotApp" $ test "f $ g" $ assert' . not . isDotApp   , testCase "isTypeApp" $ test "f @Int" $ assert' . isTypeApp-#if defined (GHCLIB_API_808)+#if defined (GHCLIB_API_808) || defined (GHCLIB_API_810)   , testCase "isTypeApp" $ test "f @ Int" $ assert' . isTypeApp #else   , testCase "isTypeApp" $ test "f @ Int" $ assert' . not . isTypeApp@@ -265,6 +283,8 @@   , testCase "isSpliceDecl" $ test "$(a + b)" $ assert' . isSpliceDecl . unLoc   , testCase "isQuasiQuote" $ test "[expr|1 + 2|]" $ assert' . isQuasiQuote   , 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 "strToVar" $ assert' . isVar . strToVar $ "foo"   , testCase "varToStr" $ test "[]" $ assert' . (== "[]") . varToStr   , testCase "varToStr" $ test "foo" $ assert' . (== "foo") . varToStr@@ -281,9 +301,9 @@   [ testCase "patToStr" $ test "True" $ assert' . (== "True") . patToStr   , testCase "patToStr" $ test "False" $ assert' . (== "False") . patToStr   , testCase "patToStr" $ test "[]" $ assert' . (== "[]") . patToStr-  , testCase "strToPat" $ assert' . (== "True") . patToStr . noLoc . strToPat $ "True"-  , testCase "strToPat" $ assert' . (== "False") . patToStr . noLoc . strToPat $ "False"-  , testCase "strToPat" $ assert' . (== "[]") . patToStr . noLoc . strToPat $ "[]"+  , testCase "strToPat" $ assert' . (== "True") . patToStr . strToPat $ "True"+  , testCase "strToPat" $ assert' . (== "False") . patToStr . strToPat $ "False"+  , testCase "strToPat" $ assert' . (== "[]") . patToStr . strToPat $ "[]"   , testCase "fromPChar" $ test "'a'" $ assert' . (== Just 'a') . fromPChar   , testCase "fromPChar" $ test "\"a\"" $ assert' . isNothing . fromPChar   ]@@ -302,5 +322,51 @@       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+#if defined (MIN_VERSION_ghc_lib_parser)+#  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)+        PFailed _ -> assertFailure "parse error"+#  endif+#elif __GLASGOW_HASKELL__ >= 810+  , testCase "ImportQualifiedPost" $ do+      case parseImport "import Foo qualified" (flags `xopt_set` ImportQualifiedPost) of+        POk _ (L _ decl) -> assertBool "expected postpositive" (isImportQualifiedPost . ideclQualified $ decl)+        PFailed _ -> assertFailure "parse error"+#endif   ]+  where+    flags = unsafeGlobalDynFlags+    report flags msgs = concat [ showSDoc flags msg | msg <- pprErrMsgBagWithLoc msgs ]++nameTests :: TestTree+nameTests = testGroup "Name tests"+  [ testCase "modName (1)" $+      moduleTest "module Foo.Bar.Baz where" flags+        (\n -> assertBool "Unexpected name string" $ modName n == "Foo.Bar.Baz")+  , testCase "modName (2)" $+      moduleTest "f x = x * 2" flags+        (\n -> assertBool "Unexpected name string" $ modName n == "Main")+  , testCase "isSymbolRdrName (1)" $ assertBool "Expected 'True'" $ isSymbolRdrName (mkRdrUnqual (mkVarOcc "+"))+  , testCase "isSymbolRdrName (2)" $ assertBool "Expected 'False'" $ not (isSymbolRdrName (mkRdrUnqual (mkVarOcc "_foo")))+  , testCase "isSymbolRdrName (3)" $ assertBool "Expected 'False'" $ not (isSymbolRdrName (mkRdrUnqual (mkVarOcc "foo'")))+  , testCase "isSymbolRdrName (4)" $ assertBool "Expected 'True'" $ isSymbolRdrName (mkRdrUnqual (mkVarOcc ":+:"))+  ]+  where+    flags = defaultDynFlags fakeSettings fakeLlvmConfig