packages feed

ghc-lib-parser-ex 9.6.0.2 → 9.8.0.0

raw patch · 18 files changed

+417/−367 lines, 18 filesdep ~ghcdep ~ghc-lib-parser

Dependency ranges changed: ghc, ghc-lib-parser

Files

ChangeLog.md view
@@ -1,14 +1,17 @@ # Changelog for ghc-lib-parser-ex -# 9.6.0.2 released+## 9.8.0.0 released+- Companion to `ghc-lib-parser-9.8.1.20231009`++## 9.6.0.2 released - New functions `isTypedSplice`, `isUntypedSpice` -# 9.6.0.1 released+## 9.6.0.1 released - Add `&` to `baseFixities` - Add support for ghc-9.8 series: `GH_9_8` - New functions `isLetStmt` and `isDo` -# 9.6.0.0 released+## 9.6.0.0 released - Add support for ghc-9.6 series: `GHC_9_6`  ## 0.20221201 released
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version:  1.18 name:           ghc-lib-parser-ex-version:        9.6.0.2+version:        9.8.0.0 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@@ -59,29 +59,30 @@       uniplate >= 1.5,       bytestring >= 0.10.8.2,       containers >= 0.5.8.1-  if flag(auto) && impl(ghc >= 9.6.0) && impl(ghc < 9.7.0)+  if flag(auto) && impl(ghc >= 9.8.0) && impl(ghc < 9.9.0)     build-depends:-      ghc == 9.6.*,+      ghc == 9.8.*,       ghc-boot-th,       ghc-boot   else     if flag(auto)       build-depends:-        ghc-lib-parser == 9.6.*+        ghc-lib-parser == 9.8.*     else       if flag(no-ghc-lib)         build-depends:-          ghc == 9.6.*,+          ghc == 9.8.*,           ghc-boot-th,           ghc-boot       else         build-depends:-          ghc-lib-parser == 9.6.*+          ghc-lib-parser == 9.8.*   include-dirs:       cbits   install-includes:       cbits/ghclib_api.h   default-language: Haskell2010+  default-extensions: CPP  test-suite ghc-lib-parser-ex-test   type: exitcode-stdio-1.0@@ -103,22 +104,22 @@     , extra >=1.6     , uniplate >= 1.6.12     , ghc-lib-parser-ex-  if flag(auto) && impl(ghc >= 9.6.0) && impl(ghc < 9.7.0)+  if flag(auto) && impl(ghc >= 9.8.0) && impl(ghc < 9.9.0)     build-depends:-      ghc == 9.6.*,+      ghc == 9.8.*,       ghc-boot-th,       ghc-boot   else     if flag(auto)       build-depends:-        ghc-lib-parser == 9.6.*+        ghc-lib-parser == 9.8.*     else       if flag(no-ghc-lib)         build-depends:-          ghc == 9.6.*,+          ghc == 9.8.*,           ghc-boot-th,           ghc-boot       else         build-depends:-          ghc-lib-parser == 9.6.*+          ghc-lib-parser == 9.8.*   default-language: Haskell2010
src/Language/Haskell/GhclibParserEx/Dump.hs view
@@ -5,7 +5,6 @@ (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 -} {- HLINT ignore -} -- Not our code.-{-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -13,26 +12,29 @@ module Language.Haskell.GhclibParserEx.Dump(     showAstData   , BlankSrcSpan(..)-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )   , BlankEpAnnotations(..) #endif ) where  #if !defined(MIN_VERSION_ghc_lib_parser)--- Using native ghc.-#  if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined(GHC_9_0) || defined (GHC_8_10)-import GHC.Hs.Dump-#  else+-- Pay attenion: This is the native GHC case.++#  if defined (GHC_8_8) import HsDumpAst+#  else+import GHC.Hs.Dump #  endif+ #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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)+-- Once again, attenion please. This is the ghc-lib-parser case.++#  if !defined (GHC_8_8) import GHC.Hs.Dump #  else--- For simplicity, just assume it's missing from 8.8 ghc-lib-parser--- builds and reproduce the implementation.+-- In the 8.8 case reproduce the implementation (the original ended up+-- in ghc-lib).+ import Prelude as X hiding ((<>))  import Data.Data hiding (Fixity)@@ -43,11 +45,7 @@ import Name import DataCon import SrcLoc-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-import GHC.Hs-#else import HsSyn-#endif import OccName hiding (occName) import Var import Module
src/Language/Haskell/GhclibParserEx/Fixity.hs view
@@ -4,44 +4,51 @@ -- Adapted from (1) https://github.com/mpickering/apply-refact.git and -- (2) https://gitlab.haskell.org/ghc/ghc ('compiler/renamer/RnTypes.hs'). -{-# LANGUAGE CPP #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TupleSections #-} #include "ghclib_api.h"- module Language.Haskell.GhclibParserEx.Fixity(     applyFixities   , fixitiesFromModule   , preludeFixities, baseFixities   , infixr_, infixl_, infix_, fixity   ) where-#if defined (GHC_9_10) || defined (GHC_9_8)-import GHC.Data.FastString-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)-import GHC.Hs-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)-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-#elif defined (GHC_8_10)-import GHC.Hs++#if defined (GHC_8_8)+import HsSyn import BasicTypes import RdrName import OccName import SrcLoc-#else-import HsSyn+#elif defined (GHC_8_10)+import GHC.Hs import BasicTypes import RdrName import OccName import SrcLoc+#elif defined  (GHC_9_0)+import GHC.Hs+import GHC.Types.Basic+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Types.SrcLoc+#elif defined (GHC_9_2) || defined (GHC_9_4) || defined (GHC_9_6)+import GHC.Hs+import GHC.Types.Fixity+import GHC.Types.SourceText+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Types.SrcLoc+#else+import GHC.Hs+import GHC.Types.Fixity+import GHC.Types.SourceText+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Types.SrcLoc+import GHC.Data.FastString #endif+ import Data.Maybe import Data.Data hiding (Fixity) import Data.Generics.Uniplate.Data@@ -66,7 +73,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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)+#if ! ( defined (GHC_8_10) || defined (GHC_8_8) ) patFix fixities (L loc (ConPat _ op (InfixCon pat1 pat2))) =   L loc (mkConOpPat (getFixities fixities) op (findFixity' (getFixities fixities) op) pat1 pat2) #elif defined (GHC_8_10)@@ -80,7 +87,7 @@  mkConOpPat ::   [(String, Fixity)]-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   -> LocatedN RdrName #else   -> Located RdrName@@ -88,21 +95,21 @@   -> Fixity   -> LPat GhcPs -> LPat GhcPs   -> Pat GhcPs-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)+#if ! ( defined (GHC_8_10) || defined (GHC_8_8) ) mkConOpPat fs op2 fix2 p1@(L loc (ConPat _ op1 (InfixCon p11 p12))) p2 #elif defined (GHC_8_10) 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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   | nofix_error = ConPat noAnn op2 (InfixCon p1 p2) #elif defined (GHC_9_0)   | nofix_error = ConPat noExtField op2 (InfixCon p1 p2) #else   | nofix_error = ConPatIn op2 (InfixCon p1 p2) #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   | associate_right = ConPat noAnn op1 (InfixCon p11 (L loc (mkConOpPat fs op2 fix2 p12 p2))) #elif defined (GHC_9_0)   | associate_right = ConPat noExtField op1 (InfixCon p11 (L loc (mkConOpPat fs op2 fix2 p12 p2)))@@ -111,7 +118,7 @@ #else   | associate_right = ConPatIn op1 (InfixCon p11 (cL loc (mkConOpPat fs op2 fix2 p12 p2))) #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   | otherwise = ConPat noAnn op2 (InfixCon p1 p2) #elif defined (GHC_9_0)   | otherwise = ConPat noExtField op2 (InfixCon p1 p2)@@ -121,7 +128,7 @@   where     fix1 = findFixity' fs op1     (nofix_error, associate_right) = compareFixity fix1 fix2-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8)) mkConOpPat _ op _ p1 p2 = ConPat noAnn op (InfixCon p1 p2) #elif defined (GHC_9_0) mkConOpPat _ op _ p1 p2 = ConPat noExtField op (InfixCon p1 p2)@@ -131,7 +138,7 @@  mkOpApp ::    [(String, Fixity)]-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))    -> SrcSpanAnnA #else    -> SrcSpan@@ -142,14 +149,14 @@    -> LHsExpr GhcPs --      (e11 `op1` e12) `op2` e2 mkOpApp fs loc e1@(L _ (OpApp x1 e11 op1 e12)) op2 fix2 e2-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   | nofix_error = L loc (OpApp noAnn e1 op2 e2) #else   | nofix_error = L loc (OpApp noExt e1 op2 e2) #endif   | associate_right = L loc (OpApp x1 e11 op1 (mkOpApp fs loc' e12 op2 fix2 e2 ))   where-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))     loc'= combineLocsA e12 e2 #else     loc'= combineLocs e12 e2@@ -158,18 +165,18 @@     (nofix_error, associate_right) = compareFixity fix1 fix2 --      (- neg_arg) `op` e2 mkOpApp fs loc e1@(L _ (NegApp _ neg_arg neg_name)) op2 fix2 e2-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   | nofix_error = L loc (OpApp noAnn e1 op2 e2) #else   | nofix_error = L loc (OpApp noExt e1 op2 e2) #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   | associate_right = L loc (NegApp noAnn (mkOpApp fs loc' neg_arg op2 fix2 e2) neg_name) #else   | associate_right = L loc (NegApp noExt (mkOpApp fs loc' neg_arg op2 fix2 e2) neg_name) #endif   where-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))     loc' = combineLocsA neg_arg e2 #else     loc' = combineLocs neg_arg e2@@ -177,7 +184,7 @@     (nofix_error, associate_right) = compareFixity negateFixity fix2 --      e1 `op` - neg_arg mkOpApp _ loc e1 op1 fix1 e2@(L _ NegApp {}) -- NegApp can occur on the right.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))   | not associate_right  = L loc (OpApp noAnn e1 op1 e2)-- We *want* right association. #else   | not associate_right  = L loc (OpApp noExt e1 op1 e2)-- We *want* right association.@@ -185,7 +192,7 @@   where     (_, associate_right) = compareFixity fix1 negateFixity  --     Default case, no rearrangment.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8)) mkOpApp _ loc e1 op _fix e2 = L loc (OpApp noAnn e1 op e2) #else mkOpApp _ loc e1 op _fix e2 = L loc (OpApp noExt e1 op e2)@@ -202,7 +209,7 @@ findFixity :: [(String, Fixity)] -> LHsExpr GhcPs -> Fixity findFixity fs r = askFix fs (getIdent r) -- Expressions. -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8)) findFixity' :: [(String, Fixity)] -> LocatedN RdrName -> Fixity #else findFixity' :: [(String, Fixity)] -> Located RdrName -> Fixity@@ -263,7 +270,7 @@ infix_  = fixity InfixN  fixity :: FixityDirection -> Int -> [String] -> [(String, Fixity)]-#if defined (GHC_9_10) || defined (GHC_9_8)+#if ! (defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) fixity a p = map (,Fixity (SourceText (fsLit "")) p a) #else fixity a p = map (,Fixity (SourceText "") p a)@@ -273,7 +280,7 @@ #else fixitiesFromModule :: Located (HsModule GhcPs) -> [(String, Fixity)] #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)+#if ! (defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8)) fixitiesFromModule (L _ (HsModule _ _ _ _ decls)) = concatMap f decls #elif defined (GHC_9_4) || defined(GHC_9_2) fixitiesFromModule (L _ (HsModule _ _ _ _ _ decls _ _)) = concatMap f decls
src/Language/Haskell/GhclibParserEx/GHC/Driver/Flags.hs view
@@ -1,18 +1,15 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Driver.Flags () where -#if ! (defined (GHC_9_10) || defined (GHC_9_8) || defined(GHC_9_6) || defined(GHC_9_4)  || defined(GHC_9_2) || defined (GHC_9_0))+#if defined (GHC_8_10) || defined (GHC_8_8) import DynFlags-#endif  -- This instance landed in -- https://gitlab.haskell.org/ghc/ghc/merge_requests/2905.-#if defined (GHC_8_8) || defined(GHC_8_10) instance Bounded Language where   minBound = Haskell98   maxBound = Haskell2010
src/Language/Haskell/GhclibParserEx/GHC/Driver/Session.hs view
@@ -1,9 +1,8 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -Wno-orphans #-} #include "ghclib_api.h"+{-# OPTIONS_GHC -Wno-orphans #-} module Language.Haskell.GhclibParserEx.GHC.Driver.Session(       readExtension     , extensionImplications@@ -14,37 +13,45 @@     , parsePragmasIntoDynFlags   ) where -#if defined (GHC_8_8) || defined (GHC_8_10)+#if defined (GHC_8_8) import qualified GHC.LanguageExtensions as LangExt-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)+import Panic+import HeaderInfo+import StringBuffer+import DynFlags+import HscTypes+#elif defined (GHC_8_10)+import qualified GHC.LanguageExtensions as LangExt+import Panic+import HeaderInfo+import StringBuffer+import DynFlags+import HscTypes+#elif defined (GHC_9_0) import GHC.Utils.Panic import GHC.Parser.Header import GHC.Data.StringBuffer import GHC.Driver.Session-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)-import GHC.Types.SourceError-#else import GHC.Driver.Types-#endif #else-import Panic-import HeaderInfo-import StringBuffer-import DynFlags-import HscTypes+import GHC.Utils.Panic+import GHC.Parser.Header+import GHC.Data.StringBuffer+import GHC.Driver.Session+import GHC.Types.SourceError #endif import GHC.LanguageExtensions.Type import Data.List import Data.Maybe import qualified Data.Map as Map+ -- Landed in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707. #if defined (GHC_8_8) || defined (GHC_8_10) import Data.Function -- For `compareOn`. instance Ord Extension where   compare = compare `on` fromEnum #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined(GHC_8_8) ) import GHC.Driver.Config.Parser #endif @@ -161,7 +168,7 @@                          -> IO (Either String DynFlags) parsePragmasIntoDynFlags flags (enable, disable) file str =   catchErrors $ do-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )     let (_, opts) =           getOptions (initParserOpts flags) (stringToStringBuffer str) file #else
src/Language/Haskell/GhclibParserEx/GHC/Hs.hs view
@@ -1,27 +1,27 @@--- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- Copyright (c) 2020-2023, 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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0)-import GHC.Hs-#  if !defined (GHC_9_10) && !defined (GHC_9_8) && !defined (GHC_9_6)-import GHC.Unit.Module-#  endif-import GHC.Types.SrcLoc+#if defined (GHC_8_8)+import HsSyn+import Module+import SrcLoc #elif defined (GHC_8_10) import GHC.Hs import Module import SrcLoc+#elif defined (GHC_9_0) || defined (GHC_9_2) || defined (GHC_9_4)+import GHC.Hs+import GHC.Unit.Module+import GHC.Types.SrcLoc #else-import HsSyn-import Module-import SrcLoc+import GHC.Hs+import GHC.Types.SrcLoc #endif  #if defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0)
src/Language/Haskell/GhclibParserEx/GHC/Hs/Binds.hs view
@@ -1,18 +1,18 @@--- Copyright (c) 2020-203, Shayne Fletcher. All rights reserved.+-- Copyright (c) 2020-2023, 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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-import GHC.Hs.Binds-import GHC.Hs.Extension-#else+#if defined (GHC_8_8) import HsBinds import HsExtension+#else+import GHC.Hs.Binds+import GHC.Hs.Extension #endif  isPatSynBind :: HsBind GhcPs -> Bool
src/Language/Haskell/GhclibParserEx/GHC/Hs/Decls.hs view
@@ -1,21 +1,20 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# LANGUAGE CPP #-} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Hs.Decls(     isNewType, isForD, isDerivD, isClsDefSig   ) where -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-import GHC.Hs-#else+#if defined(GHC_8_8) import HsSyn-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)-import GHC.Types.SrcLoc #else+import GHC.Hs+#endif+#if defined (GHC_8_10) || defined (GHC_8_8) import SrcLoc+#else+import GHC.Types.SrcLoc #endif  isNewType :: NewOrData -> Bool
src/Language/Haskell/GhclibParserEx/GHC/Hs/Expr.hs view
@@ -2,7 +2,6 @@ -- SPDX-License-Identifier: BSD-3-Clause.  {-# OPTIONS_GHC -Wno-missing-fields #-}-{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Hs.Expr(@@ -11,7 +10,7 @@   isDotApp, isTypeApp, isWHNF, isLCase,   isFieldPun, isFieldPunUpdate, isRecStmt, isLetStmt, isParComp, isMDo, isListComp, isMonadComp, isTupleSection, isString, isPrimLiteral,   isSpliceDecl,-#if !( defined(GHC_8_8) || defined(GHC_8_10) || defined (GHC_9_0) || defined (GHC_9_2) || defined(GHC_9_4) )+#if !( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )   -- ghc api >= 9.6.1   isTypedSplice, isUntypedSplice, #endif@@ -21,30 +20,46 @@   fromChar   ) where -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-import GHC.Hs-#else+#if defined (GHC_8_8) import HsSyn-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+import SrcLoc+import RdrName+import OccName+import Name+import BasicTypes+import TysWiredIn+#elif defined (GHC_8_10)+import GHC.Hs+import SrcLoc+import RdrName+import OccName+import Name+import BasicTypes+import TysWiredIn+#elif defined (GHC_9_0)+import GHC.Hs+import GHC.Types.SrcLoc+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Types.Basic+import GHC.Builtin.Types+#elif defined (GHC_9_2) || defined (GHC_9_4)+import GHC.Hs import GHC.Types.SourceText-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)-import Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader-#endif 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+import GHC.Hs+import GHC.Types.SourceText+import GHC.Types.SrcLoc+import GHC.Types.Name.Reader+import GHC.Types.Name+import GHC.Types.Basic+import GHC.Builtin.Types+import Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader #endif import Data.Ratio @@ -69,9 +84,11 @@ isDo = \case (L _ HsDo{}) -> True; _ -> False isLexeme = \case (L _ HsVar{}) -> True; (L _ HsOverLit{}) -> True; (L _ HsLit{}) -> True; _ -> False isLambda = \case (L _ HsLam{}) -> True; _ -> False-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)+#if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.6.1 isQuasiQuoteExpr = \case (L _ (HsUntypedSplice _ HsQuasiQuote{})) -> True; _ -> False #else+-- ghc api < 9.6.1 isQuasiQuoteExpr = \case (L _ (HsSpliceE _ HsQuasiQuote{})) -> True; _ -> False #endif isQuasiQuote = isQuasiQuoteExpr -- Backwards compat.@@ -83,7 +100,8 @@   (L _ HsLam{}) -> True   (L _ ExplicitTuple{}) -> True   (L _ ExplicitList{}) -> True-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1   (L _ (HsPar _ _ x _)) -> isWHNF x #else   (L _ (HsPar _ x)) -> isWHNF x@@ -94,10 +112,15 @@   (L _ (HsApp _ (L _ (HsVar _ (L _ x))) _))     | occNameString (rdrNameOcc x) `elem` ["Just", "Left", "Right"] -> True   _ -> False+#if ! ( defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+isLCase = \case (L _ (HsLam _ LamCase _)) -> True; _ -> False+#else isLCase = \case (L _ HsLamCase{}) -> True; _ -> False+#endif isOverLabel = \case (L _ HsOverLabel{}) -> True; _ -> False -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)+#if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.6.1 isQuasiQuoteSplice :: HsUntypedSplice GhcPs -> Bool #else isQuasiQuoteSplice :: HsSplice GhcPs -> Bool@@ -105,7 +128,7 @@ isQuasiQuoteSplice = \case HsQuasiQuote{} -> True; _ -> False  -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHCLIB_API_901)+#if ! ( defined (GHC_8_10) || defined (GHC_8_8) ) isStrictMatch :: HsMatchContext GhcPs -> Bool #else isStrictMatch :: HsMatchContext RdrName -> Bool@@ -113,7 +136,8 @@ isStrictMatch = \case FunRhs{mc_strictness=SrcStrict} -> True; _ -> False  -- Field is punned e.g. '{foo}'.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1 isFieldPun :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool isFieldPun = \case (L _ HsFieldBind {hfbPun=True}) -> True; _ -> False #else@@ -122,7 +146,8 @@ #endif -- Field puns in updates have a different type to field puns in -- constructions.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1 isFieldPunUpdate :: HsFieldBind (LAmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool isFieldPunUpdate = \case HsFieldBind {hfbPun=True} -> True; _ -> False #else@@ -144,14 +169,15 @@ isParComp = \case ParStmt{} -> True; _ -> False  -- TODO: Seems `HsStmtContext (HsDoRn p)` on master right now.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1 isMDo :: HsDoFlavour -> Bool isMDo = \case MDoExpr _ -> True; _ -> False isMonadComp :: HsDoFlavour -> Bool isMonadComp = \case MonadComp -> True; _ -> False isListComp :: HsDoFlavour -> Bool isListComp = \case ListComp -> True; _ -> False-#elif defined(GHC_9_2) || defined (GHC_9_0)+#elif defined (GHC_9_2) || defined (GHC_9_0) isMDo :: HsStmtContext GhcRn -> Bool isMDo = \case MDoExpr _ -> True; _ -> False isMonadComp :: HsStmtContext GhcRn -> Bool@@ -187,14 +213,16 @@  -- Since ghc-9.6.1, `HsTypedSplice` and `HsUntypedSplice` have been -- top-level constuctors of `Language.Haskell.Syntax.Expr.HsExpr p`-#if !( defined(GHC_8_8) || defined(GHC_8_10) || defined (GHC_9_0) || defined (GHC_9_2) || defined(GHC_9_4) )+#if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= ghc-9.6.1 isTypedSplice, isUntypedSplice :: HsExpr GhcPs -> Bool isTypedSplice = \case HsTypedSplice{} -> True; _ -> False isUntypedSplice = \case HsUntypedSplice{} -> True; _ -> False #endif  isSpliceDecl :: HsExpr GhcPs -> Bool-#if !( defined(GHC_8_8) || defined(GHC_8_10) || defined (GHC_9_0) || defined (GHC_9_2) || defined(GHC_9_4) )+#if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.6.1 isSpliceDecl = \case   HsTypedSplice{} -> True   HsUntypedSplice{} -> True@@ -213,25 +241,29 @@ isTransStmt = \case TransStmt{} -> True; _ -> False  -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1 isFieldWildcard :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool #else isFieldWildcard :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool #endif isFieldWildcard = \case-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)++#if ! ( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= ghc-9.6.1 -- Use `Language.Haskell.GhcLibParserEx.GHC.Types.Name.Reader`s `occNameStr` since `HsUnboundVar` now contains a `RdrName` not an `OccName`.   (L _ HsFieldBind {hfbRHS=(L _ (HsUnboundVar _ s))}) -> occNameStr s == "_" #elif defined (GHC_9_4)   (L _ HsFieldBind {hfbRHS=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_"-#elif defined(GHC_9_2) || defined (GHC_9_0)+#elif defined (GHC_9_2) || defined (GHC_9_0)   (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ s))}) -> occNameString s == "_" #elif defined (GHC_8_10)   (L _ HsRecField {hsRecFieldArg=(L _ (HsUnboundVar _ _))}) -> True #else   (L _ HsRecField {hsRecFieldArg=(L _ (EWildPat _))}) -> True #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1   (L _ HsFieldBind {hfbPun=True}) -> True   (L _ HsFieldBind {}) -> False #else@@ -244,10 +276,11 @@  isWholeFrac :: HsExpr GhcPs -> Bool -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1 isWholeFrac (HsLit _ (HsRat _ fl@FL{} _)) = denominator (rationalFromFractionalLit fl) == 1 isWholeFrac (HsOverLit _ (OverLit _ (HsFractional fl@FL {}) )) = denominator (rationalFromFractionalLit fl) == 1-#elif defined(GHC_9_2)+#elif defined (GHC_9_2) isWholeFrac (HsLit _ (HsRat _ fl@FL{} _)) = denominator (rationalFromFractionalLit fl) == 1 isWholeFrac (HsOverLit _ (OverLit _ (HsFractional fl@FL {}) _)) = denominator (rationalFromFractionalLit fl) == 1 #else@@ -265,7 +298,8 @@ varToStr _ = ""  strToVar :: String -> LHsExpr GhcPs-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! ( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.2.1 strToVar x = noLocA $ HsVar noExtField (noLocA $ mkRdrUnqual (mkVarOcc x)) #elif defined (GHC_9_0) || defined (GHC_8_10) strToVar x = noLoc $ HsVar noExtField (noLoc $ mkRdrUnqual (mkVarOcc x))
src/Language/Haskell/GhclibParserEx/GHC/Hs/ExtendInstances.hs view
@@ -2,7 +2,6 @@ -- SPDX-License-Identifier: BSD-3-Clause.  {-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE CPP #-} #include "ghclib_api.h"  module Language.Haskell.GhclibParserEx.GHC.Hs.ExtendInstances (@@ -18,7 +17,7 @@ -- representations rather than the terms themselves, leads to -- identical results. -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)+#if !( defined (GHC_8_8) || defined (GHC_8_10)) import GHC.Utils.Outputable #else import Outputable@@ -39,7 +38,7 @@ -- string representations. toStr :: Data a => HsExtendInstances a -> String toStr (HsExtendInstances e) =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)+#if !( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )   showPprUnsafe $ showAstData BlankSrcSpan BlankEpAnnotations e #else   showSDocUnsafe $ showAstData BlankSrcSpan e@@ -57,7 +56,7 @@ -- Use 'ppr' for 'Show'. instance Outputable a => Show (HsExtendInstances a) where   show (HsExtendInstances e) =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined(GHC_9_6) || defined(GHC_9_2)+#if !( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )     showPprUnsafe $ ppr e #else     showSDocUnsafe $ ppr e
src/Language/Haskell/GhclibParserEx/GHC/Hs/ImpExp.hs view
@@ -1,6 +1,6 @@ -- Copyright (c) 2020-2023 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@@ -14,24 +14,21 @@   ) where -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)-import GHC.Hs.Extension (GhcPs)-#endif--#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)-import GHC.Hs.ImpExp-#  if !defined (GHC_9_10) && !defined (GHC_9_8) && !defined (GHC_9_6)-import GHC.Types.Name.Reader-#  endif+#if defined (GHC_8_8)+import HsImpExp+import RdrName #elif defined (GHC_8_10) import GHC.Hs.ImpExp import RdrName+#elif defined (GHC_9_0) || defined (GHC_9_2) || defined (GHC_9_4)+import GHC.Hs.ImpExp+import GHC.Types.Name.Reader #else-import HsImpExp-import RdrName+import GHC.Hs.ImpExp+import GHC.Hs.Extension (GhcPs) #endif -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)+#if !( defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) isPatSynIE :: IEWrappedName GhcPs -> Bool #else isPatSynIE :: IEWrappedName RdrName -> Bool
src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs view
@@ -1,7 +1,6 @@ -- Copyright (c) 2020-203, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# LANGUAGE CPP #-} {-# LANGUAGE ViewPatterns #-} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Hs.Pat(@@ -12,103 +11,81 @@   , isSplicePat  ) where -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)+#if defined (GHC_8_8)+import HsSyn+import SrcLoc+import TysWiredIn+import RdrName+import OccName+import FastString+#elif defined (GHC_8_10) import GHC.Hs+import SrcLoc+import TysWiredIn+import RdrName+import OccName+import FastString #else-import HsSyn-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0)+import GHC.Hs 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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-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 (GHC_9_0)-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) == "[]" = "[]"+#if defined (GHC_8_8)+patToStr (dL -> L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "True" = "True"+patToStr (dL -> L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "False" = "False"+patToStr (dL -> L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "[]" = "[]" patToStr _ = "" #elif defined (GHC_8_10) 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) == "[]" = "[]" patToStr _ = ""+#elif defined (GHC_9_0)+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 _ = "" #else-patToStr (dL -> L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "True" = "True"-patToStr (dL -> L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "False" = "False"-patToStr (dL -> L _ (ConPatIn (L _ x) (PrefixCon []))) | occNameString (rdrNameOcc x) == "[]" = "[]"+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 _ = "" #endif  strToPat :: String -> LPat GhcPs strToPat z-  | z == "True"  =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-  noLocA $-#elif defined (GHC_9_0) || defined (GHC_8_10)-  noLoc $-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-    ConPat noAnn (noLocA true_RDR) (PrefixCon [] [])-#elif defined (GHC_9_0)-    ConPat noExtField (noLoc true_RDR) (PrefixCon [])-#else-    ConPatIn (noLoc true_RDR) (PrefixCon [])-#endif-  | z == "False" =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-  noLocA $-#elif defined (GHC_9_0) || defined (GHC_8_10)-  noLoc $-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-    ConPat noAnn (noLocA false_RDR) (PrefixCon [] [])-#elif defined (GHC_9_0)-    ConPat noExtField (noLoc false_RDR) (PrefixCon [])-#else-    ConPatIn (noLoc false_RDR) (PrefixCon [])-#endif-  | z == "[]"    =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-  noLocA $-#elif defined (GHC_9_0) || defined (GHC_8_10)-  noLoc $-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-    ConPat noAnn (noLocA $ nameRdrName nilDataConName) (PrefixCon [] [])+#if defined (GHC_8_8)+  | z == "True" = ConPatIn (noLoc true_RDR) (PrefixCon [])+  | z == "False" = ConPatIn (noLoc false_RDR) (PrefixCon [])+  | z == "[]" = ConPatIn (noLoc $ nameRdrName nilDataConName) (PrefixCon [])+  | otherwise = VarPat noExt (noLoc $ mkVarUnqual (fsLit z))+#elif defined (GHC_8_10)+  | z == "True" =  noLoc $ ConPatIn (noLoc true_RDR) (PrefixCon [])+  | z == "False" =  noLoc $ ConPatIn (noLoc false_RDR) (PrefixCon [])+  | z == "[]" = noLoc $ ConPatIn (noLoc $ nameRdrName nilDataConName) (PrefixCon [])+  | otherwise = noLoc $ VarPat noExtField (noLoc $ mkVarUnqual (fsLit z)) #elif defined (GHC_9_0)-    ConPat noExtField (noLoc $ nameRdrName nilDataConName) (PrefixCon [])-#else-    ConPatIn (noLoc $ nameRdrName nilDataConName) (PrefixCon [])-#endif-  | otherwise =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-      noLocA $ VarPat noExtField (noLocA $ mkVarUnqual (fsLit z))-#elif defined (GHC_9_0) || defined (GHC_8_10)-      noLoc $ VarPat noExtField (noLoc $ mkVarUnqual (fsLit z))+  | z == "True" = noLoc $ ConPat noExtField (noLoc true_RDR) (PrefixCon [])+  | z == "False" = noLoc $ ConPat noExtField (noLoc false_RDR) (PrefixCon [])+  | z == "[]" = noLoc $ ConPat noExtField (noLoc $ nameRdrName nilDataConName) (PrefixCon [])+  | otherwise = noLoc $ VarPat noExtField (noLoc $ mkVarUnqual (fsLit z)) #else-      VarPat noExt (noLoc $ mkVarUnqual (fsLit z))+  | z == "True" = noLocA $ ConPat noAnn (noLocA true_RDR) (PrefixCon [] [])+  | z == "False" = noLocA $ ConPat noAnn (noLocA false_RDR) (PrefixCon [] [])+  | z == "[]" = noLocA $ ConPat noAnn (noLocA $ nameRdrName nilDataConName) (PrefixCon [] [])+  | otherwise = noLocA $ VarPat noExtField (noLocA $ mkVarUnqual (fsLit z)) #endif  fromPChar :: LPat GhcPs -> Maybe Char-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-fromPChar (L _ (LitPat _ (HsChar _ x))) = Just x-#else+#if defined (GHC_8_8) fromPChar (dL -> L _ (LitPat _ (HsChar _ x))) = Just x+#else+fromPChar (L _ (LitPat _ (HsChar _ x))) = Just x #endif fromPChar _ = Nothing @@ -118,61 +95,66 @@ hasPFieldsDotDot _ = False  -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if !( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc >= 9.4 isPFieldWildcard :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LPat GhcPs) -> Bool #else isPFieldWildcard :: LHsRecField GhcPs (LPat GhcPs) -> Bool #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)-isPFieldWildcard (L _ HsFieldBind {hfbRHS=L _ WildPat {}}) = True-isPFieldWildcard (L _ HsFieldBind {hfbPun=True}) = True-isPFieldWildcard (L _ HsFieldBind {}) = False-#elif defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)+#if defined (GHC_8_8)+isPFieldWildcard (dL -> L _ HsRecField {hsRecFieldArg=LL _ WildPat {}}) = True+isPFieldWildcard (dL -> L _ HsRecField {hsRecPun=True}) = True+isPFieldWildcard (dL -> L _ HsRecField {}) = False+#elif defined (GHC_8_10) isPFieldWildcard (L _ HsRecField {hsRecFieldArg=L _ WildPat {}}) = True isPFieldWildcard (L _ HsRecField {hsRecPun=True}) = True isPFieldWildcard (L _ HsRecField {}) = False+#elif defined (GHC_9_0) || defined (GHC_9_2)+isPFieldWildcard (L _ HsRecField {hsRecFieldArg=L _ WildPat {}}) = True+isPFieldWildcard (L _ HsRecField {hsRecPun=True}) = True+isPFieldWildcard (L _ HsRecField {}) = False #else-isPFieldWildcard (dL -> L _ HsRecField {hsRecFieldArg=LL _ WildPat {}}) = True-isPFieldWildcard (dL -> L _ HsRecField {hsRecPun=True}) = True-isPFieldWildcard (dL -> L _ HsRecField {}) = False+isPFieldWildcard (L _ HsFieldBind {hfbRHS=L _ WildPat {}}) = True+isPFieldWildcard (L _ HsFieldBind {hfbPun=True}) = True+isPFieldWildcard (L _ HsFieldBind {}) = False #endif  isPWildcard :: LPat GhcPs -> Bool-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-isPWildcard (L _ (WildPat _)) = True-#else+#if defined (GHC_8_8) isPWildcard (dL -> L _ (WildPat _)) = True+#else+isPWildcard (L _ (WildPat _)) = True #endif isPWildcard _ = False -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if !( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) isPFieldPun :: LHsFieldBind GhcPs (LFieldOcc GhcPs) (LPat GhcPs) -> Bool #else isPFieldPun :: LHsRecField GhcPs (LPat GhcPs) -> Bool #endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)-isPFieldPun (L _ HsFieldBind {hfbPun=True}) = True-#elif defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)+#if defined (GHC_8_8)+isPFieldPun (dL -> L _ HsRecField {hsRecPun=True}) = True+#elif defined (GHC_8_10) || defined (GHC_9_0) || defined (GHC_9_2) isPFieldPun (L _ HsRecField {hsRecPun=True}) = True #else-isPFieldPun (dL -> L _ HsRecField {hsRecPun=True}) = True+isPFieldPun (L _ HsFieldBind {hfbPun=True}) = True #endif isPFieldPun _ = False  isPatTypeSig, isPBangPat, isPViewPat :: LPat GhcPs -> Bool-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-isPatTypeSig (L _ SigPat{}) = True; isPatTypeSig _ = False-isPBangPat (L _ BangPat{}) = True; isPBangPat _ = False-isPViewPat (L _ ViewPat{}) = True; isPViewPat _ = False-#else+#if defined (GHC_8_8) isPatTypeSig (dL -> L _ SigPat{}) = True; isPatTypeSig _ = False isPBangPat (dL -> L _ BangPat{}) = True; isPBangPat _ = False isPViewPat (dL -> L _ ViewPat{}) = True; isPViewPat _ = False+#else+isPatTypeSig (L _ SigPat{}) = True; isPatTypeSig _ = False+isPBangPat (L _ BangPat{}) = True; isPBangPat _ = False+isPViewPat (L _ ViewPat{}) = True; isPViewPat _ = False #endif  isSplicePat :: LPat GhcPs -> Bool-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-isSplicePat (L _ SplicePat{}) = True; isSplicePat _ = False-#else+#if defined (GHC_8_8) isSplicePat (dL -> L _ SplicePat{}) = True; isSplicePat _ = False+#else+isSplicePat (L _ SplicePat{}) = True; isSplicePat _ = False #endif
src/Language/Haskell/GhclibParserEx/GHC/Hs/Type.hs view
@@ -1,7 +1,6 @@ -- Copyright (c) 2021-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Hs.Type (@@ -9,15 +8,15 @@   , isTyQuasiQuote, isUnboxedTuple, isKindTyApp ) where -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-import GHC.Hs-#else+#if defined (GHC_8_8) import HsSyn-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0)-import GHC.Types.SrcLoc #else+import GHC.Hs+#endif+#if defined (GHC_8_8) || defined (GHC_8_10) import SrcLoc+#else+import GHC.Types.SrcLoc #endif  isKindTyApp :: LHsType GhcPs -> Bool
src/Language/Haskell/GhclibParserEx/GHC/Parser.hs view
@@ -1,7 +1,7 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -{-# LANGUAGE CPP #-}+ #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Parser(     parseFile@@ -22,20 +22,45 @@   )   where -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10)-import GHC.Hs-#else+#if defined (GHC_8_8) import HsSyn-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)-#  if defined (GHC_9_2)+import DynFlags+import StringBuffer+import Lexer+import qualified Parser+import FastString+import SrcLoc+import BkpSyn+import PackageConfig+import RdrName+#elif defined (GHC_8_10)+import GHC.Hs+import DynFlags+import StringBuffer+import Lexer+import qualified Parser+import FastString+import SrcLoc+import BkpSyn+import PackageConfig+import RdrName+import RdrHsSyn+#elif defined (GHC_9_0)+import GHC.Hs+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+#elif defined (GHC_9_2)+import GHC.Hs import GHC.Driver.Config-#  endif-#  if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)-import GHC.Driver.Config.Parser-#  endif-#endif-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0) import GHC.Parser.PostProcess import GHC.Driver.Session import GHC.Data.StringBuffer@@ -48,18 +73,19 @@ 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 (GHC_8_10)-import RdrHsSyn+import GHC.Hs+import GHC.Driver.Config.Parser+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 #endif  parse :: P a -> String -> DynFlags -> ParseResult a@@ -69,7 +95,7 @@     location = mkRealSrcLoc (mkFastString "<string>") 1 1     buffer = stringToStringBuffer str     parseState =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )       initParserState (initParserOpts flags) buffer location #else       mkPState flags buffer location@@ -101,10 +127,8 @@ parseDeclaration = parse Parser.parseDeclaration  parseExpression :: String -> DynFlags -> ParseResult (LHsExpr GhcPs)-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) parseExpression s flags =-  -- The need for annotations here came about first manifested with-  -- ghc-9.0.1   case parse Parser.parseExpression s flags of     POk state e ->       let e' = e :: ECP@@ -130,7 +154,7 @@ parseStmt :: String -> DynFlags -> ParseResult (Maybe (LStmt GhcPs (LHsExpr GhcPs))) parseStmt = parse Parser.parseStmt -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) parseIdentifier :: String -> DynFlags -> ParseResult (LocatedN RdrName) #else parseIdentifier :: String -> DynFlags -> ParseResult (Located RdrName)@@ -164,7 +188,7 @@     location = mkRealSrcLoc (mkFastString filename) 1 1     buffer = stringToStringBuffer str     parseState =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2)+#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )       initParserState (initParserOpts flags) buffer location #else       mkPState flags buffer location
src/Language/Haskell/GhclibParserEx/GHC/Settings/Config.hs view
@@ -2,23 +2,20 @@ -- 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-#if !defined (GHC_9_10) && !defined (GHC_9_8) && !defined (GHC_9_6)+#if defined (GHC_8_8) || defined (GHC_8_10) || defined (GHC_9_0) || defined (GHC_9_2) || defined (GHC_9_4)   , fakeLlvmConfig #endif   ) where -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2) || defined (GHC_9_0)-import GHC.Settings.Config-import GHC.Driver.Session-import GHC.Utils.Fingerprint-import GHC.Platform-import GHC.Settings+#if defined (GHC_8_8)+import Config+import DynFlags+import Fingerprint+import Platform #elif defined (GHC_8_10) import Config import DynFlags@@ -26,53 +23,73 @@ import GHC.Platform import ToolSettings #else-import Config-import DynFlags-import Fingerprint-import Platform+import GHC.Settings.Config+import GHC.Driver.Session+import GHC.Utils.Fingerprint+import GHC.Platform+import GHC.Settings #endif  fakeSettings :: Settings fakeSettings = Settings-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)|| defined (GHC_8_10)+#if defined (GHC_8_8)+  { sTargetPlatform=platform+  , sPlatformConstants=platformConstants+  , sProjectVersion=cProjectVersion+  , sProgramName="ghc"+  , sOpt_P_fingerprint=fingerprint0+  }+#elif defined (GHC_8_10) || defined (GHC_9_0)   { sGhcNameVersion=ghcNameVersion   , sFileSettings=fileSettings   , sTargetPlatform=platform   , sPlatformMisc=platformMisc-#  if !defined(GHC_9_10) && !defined (GHC_9_8) && !defined(GHC_9_6) && !defined(GHC_9_4) && !defined(GHC_9_2)   , sPlatformConstants=platformConstants-#  endif   , sToolSettings=toolSettings   } #else-  { sTargetPlatform=platform-  , sPlatformConstants=platformConstants-  , sProjectVersion=cProjectVersion-  , sProgramName="ghc"-  , sOpt_P_fingerprint=fingerprint0+  { sGhcNameVersion=ghcNameVersion+  , sFileSettings=fileSettings+  , sTargetPlatform=platform+  , sPlatformMisc=platformMisc+  , sToolSettings=toolSettings   } #endif   where-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)|| defined (GHC_8_10)+#if !defined (GHC_8_8)     toolSettings = ToolSettings {-      toolSettings_opt_P_fingerprint=fingerprint0+        toolSettings_opt_P_fingerprint=fingerprint0       }     fileSettings = FileSettings {}     platformMisc = PlatformMisc {}-    ghcNameVersion =-      GhcNameVersion{ghcNameVersion_programName="ghc"-                    ,ghcNameVersion_projectVersion=cProjectVersion-                    }+    ghcNameVersion = GhcNameVersion {+        ghcNameVersion_programName="ghc"+      , ghcNameVersion_projectVersion=cProjectVersion+      } #endif-    platform =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined (GHC_9_2)-      genericPlatform-#else-      Platform{-#  if defined (GHC_9_0)-    -- 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.+#if defined (GHC_8_8) || defined (GHC_8_10) || defined (GHC_9_0)+    platformConstants = PlatformConstants {+        pc_DYNAMIC_BY_DEFAULT=False+      , pc_WORD_SIZE=8+      }+#endif+#if defined (GHC_8_8)+    platform = Platform {+        platformWordSize=8+      , platformOS=OSUnknown+      , platformUnregisterised=True+      }+#elif defined (GHC_8_10)+    platform = Platform {+        platformWordSize=PW8+      , platformMini=PlatformMini {+            platformMini_arch=ArchUnknown+          , platformMini_os=OSUnknown+          }+      , platformUnregisterised=True+      }+#elif defined (GHC_9_0)+    platform = Platform {         platformByteOrder=LittleEndian       , platformHasGnuNonexecStack=True       , platformHasIdentDirective=False@@ -80,29 +97,18 @@       , platformIsCrossCompiling=False       , platformLeadingUnderscore=False       , platformTablesNextToCode=False-      ,-#  endif-#  if defined (GHC_8_10) || defined (GHC_9_0)-        platformWordSize=PW8+      , platformWordSize=PW8       , platformMini=PlatformMini {platformMini_arch=ArchUnknown, platformMini_os=OSUnknown}-#  else-        platformWordSize=8-      , platformOS=OSUnknown-#  endif       , platformUnregisterised=True       }-#endif-#if !defined(GHC_9_10) && !defined (GHC_9_8) && !defined(GHC_9_6) && !defined(GHC_9_4) && !defined(GHC_9_2)-    platformConstants =-      PlatformConstants{pc_DYNAMIC_BY_DEFAULT=False,pc_WORD_SIZE=8}+#else+    platform = genericPlatform #endif -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6)--- Intentionally empty-#elif defined(GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)|| defined (GHC_8_10)-fakeLlvmConfig :: LlvmConfig-fakeLlvmConfig = LlvmConfig [] []-#else+#if defined (GHC_8_8) fakeLlvmConfig :: (LlvmTargets, LlvmPasses) fakeLlvmConfig = ([], [])+#elif defined (GHC_8_10) || defined (GHC_9_0) || defined(GHC_9_2) || defined(GHC_9_4)+fakeLlvmConfig :: LlvmConfig+fakeLlvmConfig = LlvmConfig [] [] #endif
src/Language/Haskell/GhclibParserEx/GHC/Types/Name/Reader.hs view
@@ -1,33 +1,31 @@ -- Copyright (c) 2020-2023, 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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined(GHC_9_4) || defined (GHC_9_2)+#if !( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) import GHC.Parser.Annotation #endif -#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined(GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)-import GHC.Types.SrcLoc-import GHC.Types.Name-import GHC.Types.Name.Reader-#else+#if defined (GHC_8_8) || defined (GHC_8_10) import SrcLoc import RdrName import OccName import Name+#else+import GHC.Types.SrcLoc+import GHC.Types.Name+import GHC.Types.Name.Reader #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-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined(GHC_9_4) || defined (GHC_9_2)+#if ! ( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) rdrNameStr :: GHC.Parser.Annotation.LocatedN RdrName -> String #else rdrNameStr :: Located RdrName -> String@@ -35,7 +33,7 @@ rdrNameStr = occNameStr . unLoc  -- Builtin type or data constructors.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined(GHC_9_4) || defined (GHC_9_2)+#if ! ( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) isSpecial :: LocatedN RdrName -> Bool #else isSpecial :: Located RdrName -> Bool@@ -45,7 +43,7 @@  -- Coerce qualified names to unqualified (by discarding the -- qualifier).-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined(GHC_9_4) || defined (GHC_9_2)+#if ! ( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) unqual :: LocatedN RdrName -> LocatedN RdrName #else unqual :: Located RdrName -> Located RdrName@@ -54,7 +52,7 @@ unqual x = x  -- Extract the occ name from a qualified/unqualified reader name.-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined(GHC_9_4) || defined (GHC_9_2)+#if ! ( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) ) fromQual :: LocatedN RdrName -> Maybe OccName #else fromQual :: Located RdrName -> Maybe OccName
src/Language/Haskell/GhclibParserEx/GHC/Utils/Outputable.hs view
@@ -1,22 +1,21 @@ -- Copyright (c) 2020-2023, 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 (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4) || defined(GHC_9_2) || defined (GHC_9_0)-import GHC.Utils.Outputable-#else+#if defined (GHC_8_8) || defined (GHC_8_10) import Outputable+#else+import GHC.Utils.Outputable #endif  unsafePrettyPrint :: Outputable a => a -> String unsafePrettyPrint =-#if defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4)+#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )   showPprUnsafe . ppr #else   showSDocUnsafe . ppr