packages feed

ghc-lib-parser-ex 9.10.0.0 → 9.12.0.0

raw patch · 24 files changed

+362/−92 lines, 24 filesdep +optparse-applicativedep +timedep ~directorydep ~extradep ~filepathnew-component:exe:ghc-lib-parser-ex-build-tool

Dependencies added: optparse-applicative, time

Dependency ranges changed: directory, extra, filepath, ghc, ghc-lib-parser

Files

+ CI.hs view
@@ -0,0 +1,150 @@+-- Copyright (c) 2020, 2024 Shayne Fletcher. All rights reserved.+-- SPDX-License-Identifier: BSD-3-Clause.+{-# LANGUAGE CPP #-}+{-# LANGUAGE NamedFieldPuns #-}++import Control.Monad.Extra+#if __GLASGOW_HASKELL__ < 906+import Control.Applicative (liftA2)+#endif+import Data.Bifunctor+import Data.List.Extra+import Data.Time.Calendar+import Data.Time.Clock+import qualified Options.Applicative as Opts+import System.Exit+import System.IO.Extra+import System.Process.Extra++main :: IO ()+main = do+  let opts =+        Opts.info+          (parseOptions Opts.<**> Opts.helper)+          ( Opts.fullDesc+              <> Opts.progDesc "Build and test ghc-lib-parser-ex."+              <> Opts.header "CI - CI script for ghc-lib-parser-ex"+          )+  options <- Opts.execParser opts+  buildTestDist options++buildTestDist :: Options -> IO ()+buildTestDist Options {versionTag = userGivenTag, noBuilds} = do+  assignVersionPatchCabal userGivenTag++  system_ "cabal sdist -o ."+  when noBuilds exitSuccess+  system_ "cabal build lib:ghc-lib-parser-ex --ghc-options=-j"+  system_ "cabal test test:ghc-lib-parser-ex-test --ghc-options=-j --test-show-details=direct --test-options=\"--color always\""+#if __GLASGOW_HASKELL__ == 808 && \+    (__GLASGOW_HASKELL_PATCHLEVEL1__ == 1 || __GLASGOW_HASKELL_PATCHLEVEL1__ == 2) && \+    defined (mingw32_HOST_OS)+      -- https://gitlab.haskell.org/ghc/ghc/issues/17599+#else+  system_ "cabal exec -- ghc -ignore-dot-ghci -package=ghc-lib-parser-ex -e \"print 1\""+#endif++assignVersionPatchCabal :: Maybe String -> IO ()+assignVersionPatchCabal userTag = do+  version <- mkVersion userTag+  patchCabal version+  contents <- readFile' "ghc-lib-parser-ex.cabal"+  putStrLn contents+  hFlush stdout+  where+    mkVersion :: Maybe String -> IO String+    mkVersion = maybe (do UTCTime day _ <- getCurrentTime; pure $ genVersionStr day) pure++    genVersionStr :: Day -> String+    genVersionStr day = "0." ++ replace "-" "" (showGregorian day)++patchCabal :: String -> IO ()+patchCabal version = do+  putStrLn "Patching cabal:"+  putStrLn $ "- version " ++ version+  writeFile "ghc-lib-parser-ex.cabal"+    . replace "version: 0.1.0" ("version: " ++ version)+    =<< readFile' "ghc-lib-parser-ex.cabal"+  let series+        | Just (major, Just (minor, _)) <- second (stripInfix ".") <$> stripInfix "." version = liftA2 (,) (maybeRead major) (maybeRead minor)+        | otherwise = Nothing+  case series of+    Just (major, minor) -> do+      let (lower, upper, family) = bounds (major, minor)+      putStrLn $ "- ghc >= " ++ lower ++ " && ghc < " ++ upper+      putStrLn $ "- ghc-lib-parser " ++ family+      writeFile "ghc-lib-parser-ex.cabal"+        . replace "9.0.0" lower+        . replace "9.1.0" upper+        . replace "9.0.*" family+        =<< readFile' "ghc-lib-parser-ex.cabal"+    Nothing -> do+      let ghcLibParserVersion = version+      putStrLn $ "- ghc-lib-parser " ++ ghcLibParserVersion+      writeFile "ghc-lib-parser-ex.cabal"+        . replace+          buildDependsSection+          ( unlines+              [ "  build-depends:",+                "      ghc-lib-parser == " ++ ghcLibParserVersion,+                "  -- pseduo use of flags to suppress cabal check warnings",+                "  if flag(auto)",+                "  if flag(no-ghc-lib)"+              ]+          )+        =<< readFile' "ghc-lib-parser-ex.cabal"+  where+    maybeRead :: String -> Maybe Int+    maybeRead s+      | [(x, "")] <- reads s = Just x+      | otherwise = Nothing++    buildDependsSection :: String+    buildDependsSection =+      unlines+        [ "  if flag(auto) && impl(ghc >= 9.0.0) && impl(ghc < 9.1.0)",+          "    build-depends:",+          "      ghc == 9.0.*,",+          "      ghc-boot-th,",+          "      ghc-boot",+          "  else",+          "    if flag(auto)",+          "      build-depends:",+          "        ghc-lib-parser == 9.0.*",+          "    else",+          "      if flag(no-ghc-lib)",+          "        build-depends:",+          "          ghc == 9.0.*,",+          "          ghc-boot-th,",+          "          ghc-boot",+          "      else",+          "        build-depends:",+          "          ghc-lib-parser == 9.0.*"+        ]++    bounds :: (Int, Int) -> (String, String, String)+    bounds (major, minor) =+      let lower = if lower' == "9.2.0" then "9.2.2" else lower'+          upper = upper'+          family = family'+       in (lower, upper, family)+      where+        lower' = show major ++ "." ++ show minor ++ ".0"+        upper' = show major ++ "." ++ show (minor + 1) ++ ".0"+        family' = show major ++ "." ++ show minor ++ ".*"++data Options = Options+  { versionTag :: Maybe String, -- If 'Just _' use this as the version (e.g. "8.8.1.20191204")+    noBuilds :: Bool -- Don't build or run tests+  }+  deriving (Show)++parseOptions :: Opts.Parser Options+parseOptions =+  Options+    <$> Opts.optional+      ( Opts.strOption+          (Opts.long "version-tag" <> Opts.help "Set version")+      )+    <*> Opts.switch+      (Opts.long "no-builds" <> Opts.help "If enabled, stop after producing sdists")
ChangeLog.md view
@@ -1,6 +1,9 @@ # Changelog for ghc-lib-parser-ex -## unreleased+# 9.12.0.0 released+- Add support for ghc-9.12 series: `GHCLIB_API_912`++## 9.10.0.0 released - Deprecate `Dump` - New module `GHC.Hs.Dump` - Add support for ghc-9.10 series: `GHCLIB_API_910`
README.md view
@@ -1,4 +1,6 @@-# ghc-lib-parser-ex [![License BSD3](https://img.shields.io/badge/license-BSD3-brightgreen.svg)](http://opensource.org/licenses/BSD-3-Clause) [![Hackage version](https://img.shields.io/hackage/v/ghc-lib-parser-ex.svg?label=Hackage)](https://hackage.haskell.org/package/ghc-lib-parser-ex) [![Stackage version](https://www.stackage.org/package/ghc-lib-parser-ex/badge/nightly?label=Stackage)](https://www.stackage.org/package/ghc-lib-parser-ex)  [![Build Status](https://shayne-fletcher.visualstudio.com/ghc-lib-parser-ex/_apis/build/status/shayne-fletcher.ghc-lib-parser-ex?branchName=master)](https://shayne-fletcher.visualstudio.com/ghc-lib-parser-ex/_build/latest?definitionId=1&branchName=master)[![stack runhaskell](https://github.com/shayne-fletcher/ghc-lib-parser-ex/actions/workflows/main.yml/badge.svg)](https://github.com/shayne-fletcher/ghc-lib-parser-ex/actions/workflows/main.yml)+# ghc-lib-parser-ex+ [![License BSD3](https://img.shields.io/badge/license-BSD3-brightgreen.svg)](http://opensource.org/licenses/BSD-3-Clause) [![Hackage version](https://img.shields.io/hackage/v/ghc-lib-parser-ex.svg?label=Hackage)](https://hackage.haskell.org/package/ghc-lib-parser-ex) [![Stackage version](https://www.stackage.org/package/ghc-lib-parser-ex/badge/nightly?label=Stackage)](https://www.stackage.org/package/ghc-lib-parser-ex) [![ghc-lib-parser-ex-ghc-lib-parser-9.10.1.20240511](https://github.com/shayne-fletcher/ghc-lib-parser-ex/actions/workflows/ghc-lib-parser-ex-ghc-lib-parser-9.10.1.20240511.yml/badge.svg)](https://github.com/shayne-fletcher/ghc-lib-parser-ex/actions/workflows/ghc-lib-parser-ex-ghc-lib-parser-9.10.1.20240511.yml)+ Copyright © 2020-2024 Shayne Fletcher. All rights reserved. SPDX-License-Identifier: BSD-3-Clause @@ -10,7 +12,9 @@  ### 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:+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). @@ -20,12 +24,10 @@  Produce and test `ghc-lib-parser-ex` package distributions by executing the CI script: ```bash-# Setup-git clone git@github.com:shayne-fletcher/ghc-lib-parser-ex.git-cd ghc-lib-parser-ex-stack runhaskell --package extra --package optparse-applicative CI.hs+    git clone git@github.com:shayne-fletcher/ghc-lib-parser-ex.git+    cd ghc-lib-parser-ex+    cabal run exe:ghc-lib-parser-ex-build-tool --allow-newer="ghc-lib-parser-ex:ghc-lib-parser" --constraint="ghc-lib-parser == 9.10.1.20240511" -- --version-tag 9.10.0.1 ```-Run `stack runhaskell --package extra --package optparse-applicative CI.hs -- --help` for more options.  To run [`hlint`](https://github.com/ndmitchell/hlint) on this repository, `hlint --cpp-include cbits --cpp-define GHC_XXXX .` (where `XXXX` at this time is one of `8_8`, `8_10`, `9_0`, `9_2`, `9_4`, `9_6`, `9_8` or `9_10`). 
cbits/ghclib_api.h view
@@ -6,8 +6,9 @@ #if !defined(GHCLIB_API_H) #  define GHCLIB_API_H -#  if !(defined (GHC_9_12) \-     || defined (GHC_9_10)  \+#  if !(defined (GHC_9_14) \+     || defined (GHC_9_12) \+     || defined (GHC_9_10) \      || defined (GHC_9_8)  \      || defined (GHC_9_6)  \      || defined (GHC_9_4)  \@@ -17,6 +18,8 @@      || defined (GHC_8_8)) #    if defined (MIN_VERSION_ghc_lib_parser) #       if !MIN_VERSION_ghc_lib_parser ( 1,  0,  0)+#         define GHC_9_14+#       elif MIN_VERSION_ghc_lib_parser (9,  12,  0) #         define GHC_9_12 #       elif MIN_VERSION_ghc_lib_parser (9,  10,  0) #         define GHC_9_10@@ -38,7 +41,9 @@ #         error Unsupported GHC API version #      endif #    else-#      if __GLASGOW_HASKELL__   == 911+#      if __GLASGOW_HASKELL__   == 914+#        define GHC_9_14+#      elif __GLASGOW_HASKELL__ == 912 #        define GHC_9_12 #      elif __GLASGOW_HASKELL__ == 910 #        define GHC_9_10
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.4 name: ghc-lib-parser-ex-version: 9.10.0.0+version: 9.12.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@@ -32,33 +32,32 @@ common base   default-language: Haskell2010   ghc-options:-    -Wall -Wincomplete-record-updates-    -Wredundant-constraints -Widentities-    -Wno-simplifiable-class-constraints+    -Wall -Wincomplete-record-updates -Wredundant-constraints -Widentities+    -Wunused-imports -Wno-name-shadowing   build-depends:       base >=4.7 && <5  common ghc_libs   include-dirs: cbits   default-extensions: CPP-  if flag(auto) && impl(ghc >= 9.10.0) && impl(ghc < 9.11.0)+  if flag(auto) && impl(ghc >= 9.12.0) && impl(ghc < 9.13.0)     build-depends:-      ghc == 9.10.*,+      ghc == 9.12.*,       ghc-boot-th,       ghc-boot   else     if flag(auto)       build-depends:-        ghc-lib-parser == 9.10.*+        ghc-lib-parser == 9.12.*     else       if flag(no-ghc-lib)         build-depends:-          ghc == 9.10.*,+          ghc == 9.12.*,           ghc-boot-th,           ghc-boot       else         build-depends:-          ghc-lib-parser == 9.10.*+          ghc-lib-parser == 9.12.*  common lib   import: base, ghc_libs@@ -95,7 +94,7 @@ common test   import: lib   build-depends:-    tasty >= 1.2, tasty-hunit >= 0.10.0, directory >= 1.3.3,+    tasty >= 1.2, tasty-hunit >= 0.10.0, directory >= 1.3.1,     filepath >= 1.4.2, extra >=1.6, uniplate >= 1.6.12,     ghc-lib-parser-ex @@ -105,3 +104,8 @@   ghc-options: -threaded -rtsopts -with-rtsopts=-N   main-is: Test.hs   hs-source-dirs: test++executable ghc-lib-parser-ex-build-tool+  import: base+  build-depends: directory, filepath, time, extra, optparse-applicative+  main-is: CI.hs
src/Language/Haskell/GhclibParserEx/Dump.hs view
@@ -2,8 +2,9 @@ -- SPDX-License-Identifier: BSD-3-Clause.  module Language.Haskell.GhclibParserEx.Dump-  {-# DEPRECATED "Use Language.Haskell.GhclibParserEx.GHC.Hs.Dump instead" #-} (-  module Language.Haskell.GhclibParserEx.GHC.Hs.Dump-  ) where+  {-# DEPRECATED "Use Language.Haskell.GhclibParserEx.GHC.Hs.Dump instead" #-}+  ( module Language.Haskell.GhclibParserEx.GHC.Hs.Dump,+  )+where  import Language.Haskell.GhclibParserEx.GHC.Hs.Dump
src/Language/Haskell/GhclibParserEx/Fixity.hs view
@@ -1,9 +1,9 @@--- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved.+-- Copyright (c) 2020-2024, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -- -- Adapted from (1) https://github.com/mpickering/apply-refact.git and -- (2) https://gitlab.haskell.org/ghc/ghc ('compiler/renamer/RnTypes.hs').-+{- ORMOLU_DISABLE -} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TupleSections #-} #include "ghclib_api.h"@@ -15,42 +15,48 @@   ) where  #if defined (GHC_8_8)-import HsSyn import BasicTypes-import RdrName+import HsSyn import OccName+import RdrName import SrcLoc #elif defined (GHC_8_10)-import GHC.Hs import BasicTypes-import RdrName+import GHC.Hs import OccName+import RdrName 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.Name.Reader 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 import GHC.Types.Name.Reader+import GHC.Types.SourceText+import GHC.Types.SrcLoc+#elif defined (GHC_9_8) || defined (GHC_9_10)+import GHC.Data.FastString+import GHC.Hs+import GHC.Types.Fixity import GHC.Types.Name+import GHC.Types.Name.Reader+import GHC.Types.SourceText 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.Maybe import Data.Generics.Uniplate.Data  #if defined (GHC_9_0) || defined (GHC_8_10)@@ -149,9 +155,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_0) || defined (GHC_8_10) || defined (GHC_8_8))+# 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) || defined (GHC_8_8) )+-- ghc > 9.10+  | nofix_error = L loc (OpApp noExtField e1 op2 e2)+#elif ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))+-- ghc > 9.0   | nofix_error = L loc (OpApp noAnn e1 op2 e2) #else+-- otherwise   | 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 ))@@ -165,9 +176,14 @@     (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_0) || defined (GHC_8_10) || defined (GHC_8_8))+# 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) || defined (GHC_8_8) )+-- ghc > 9.10+  | nofix_error = L loc (OpApp noExtField e1 op2 e2)+#elif ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))+-- ghc > 9.0   | nofix_error = L loc (OpApp noAnn e1 op2 e2) #else+-- otherwise   | nofix_error = L loc (OpApp noExt e1 op2 e2) #endif #if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))@@ -184,7 +200,10 @@     (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_0) || defined (GHC_8_10) || defined (GHC_8_8))+# 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) || defined (GHC_8_8) )+-- ghc > 9.10+  | not associate_right  = L loc (OpApp noExtField e1 op1 e2)-- We *want* right association.+#elif ! (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.@@ -192,7 +211,10 @@   where     (_, associate_right) = compareFixity fix1 negateFixity  --     Default case, no rearrangment.-#if ! (defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))+# 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) || defined (GHC_8_8) )+-- ghc > 9.10+mkOpApp _ loc e1 op _fix e2 = L loc (OpApp noExtField e1 op e2)+#elif ! (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)@@ -270,7 +292,9 @@ infix_  = fixity InfixN  fixity :: FixityDirection -> Int -> [String] -> [(String, Fixity)]-#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) )+# 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) || defined (GHC_8_8) )+fixity a p = map (,Fixity p a)+#elif ! (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)@@ -291,6 +315,10 @@ #endif   where     f :: LHsDecl GhcPs -> [(String, Fixity)]+# 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) || defined (GHC_8_8) )+    f (L _ (SigD _ (FixSig _ (FixitySig _ ops (Fixity p dir))))) =+#else     f (L _ (SigD _ (FixSig _ (FixitySig _ ops (Fixity _ p dir))))) =+#endif           fixity dir p (map (occNameString. rdrNameOcc . unLoc) ops)     f _ = []
src/Language/Haskell/GhclibParserEx/GHC/Driver/Flags.hs view
@@ -1,6 +1,5 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause.- {-# OPTIONS_GHC -Wno-orphans #-} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Driver.Flags () where
src/Language/Haskell/GhclibParserEx/GHC/Driver/Session.hs view
@@ -1,6 +1,7 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. +{- ORMOLU_DISABLE -} #include "ghclib_api.h" {-# OPTIONS_GHC -Wno-orphans #-} module Language.Haskell.GhclibParserEx.GHC.Driver.Session(@@ -59,6 +60,7 @@ readExtension :: String -> Maybe Extension readExtension s = flagSpecFlag <$> find (\(FlagSpec n _ _ _) -> n == s) xFlags +#if (defined (GHC_9_12) || 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) || defined(GHC_8_8) ) -- | Implicitly enabled/disabled extensions. extensionImplications :: [(Extension, ([Extension], [Extension]))] extensionImplications = map f $ Map.toList implicationsMap@@ -67,8 +69,28 @@     implicationsMap :: Map.Map String ([Extension], [Extension])     implicationsMap = Map.fromListWith (<>)       [(show a, ([c | b], [c | not b]))-        | (a, flag, c) <- impliedXFlags, let b = flag == turnOn]+        | (a, flag, c) <- impliedXFlags,+          let b = flag == turnOn+      ]+#else+  {- defined (GHC_9_14) -}+-- | Implicitly enabled/disabled extensions.+extensionImplications :: [(Extension, ([Extension], [Extension]))]+extensionImplications = map f $ Map.toList implicationsMap+  where+    f (e, ps) = (fromJust (readExtension e), ps)+    implicationsMap :: Map.Map String ([Extension], [Extension])+    implicationsMap = Map.fromListWith (<>)+      [(show a, ([strip c | b], [strip c | not b]))+        | (a, c) <- impliedXFlags,+          let b = case c of On _ -> True; Off _ -> False+      ] +    strip :: OnOff a -> a+    strip (On e) = e+    strip (Off e) = e+#endif+ -- Landed in -- https://gitlab.haskell.org/ghc/ghc/merge_requests/2654. Copied from -- 'ghc/compiler/main/DynFlags.hs'.@@ -168,14 +190,13 @@                          -> IO (Either String DynFlags) parsePragmasIntoDynFlags flags (enable, disable) file str =   catchErrors $ do-#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+#if (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8))+    let opts = getOptions flags (stringToStringBuffer str) file+#elif (defined (GHC_9_12) || defined (GHC_9_10) || defined (GHC_9_8) || defined (GHC_9_6) || defined (GHC_9_4))+    let (_, opts) = getOptions (initParserOpts flags) (stringToStringBuffer str) file #else-    let opts =-          getOptions flags (stringToStringBuffer str) file+    let (_, opts) = getOptions (initParserOpts flags) (supportedLanguagePragmas flags) (stringToStringBuffer str) file #endif-     -- Important : apply enables, disables *before* parsing dynamic     -- file pragmas.     let flags' =  foldl' xopt_set flags enable
src/Language/Haskell/GhclibParserEx/GHC/Hs.hs view
@@ -2,9 +2,9 @@ -- SPDX-License-Identifier: BSD-3-Clause.  #include "ghclib_api.h"-module Language.Haskell.GhclibParserEx.GHC.Hs(-   modName- )+module Language.Haskell.GhclibParserEx.GHC.Hs+  ( modName,+  ) where  #if defined (GHC_8_8)@@ -29,5 +29,5 @@ #else modName :: Located (HsModule GhcPs) -> String #endif-modName (L _ HsModule {hsmodName=Nothing}) = "Main"-modName (L _ HsModule {hsmodName=Just (L _ n)}) = moduleNameString n+modName (L _ HsModule {hsmodName = Nothing}) = "Main"+modName (L _ HsModule {hsmodName = Just (L _ n)}) = moduleNameString n
src/Language/Haskell/GhclibParserEx/GHC/Hs/Binds.hs view
@@ -2,8 +2,8 @@ -- SPDX-License-Identifier: BSD-3-Clause.  #include "ghclib_api.h"-module Language.Haskell.GhclibParserEx.GHC.Hs.Binds(-  isPatSynBind+module Language.Haskell.GhclibParserEx.GHC.Hs.Binds+  ( isPatSynBind,   ) where @@ -16,5 +16,5 @@ #endif  isPatSynBind :: HsBind GhcPs -> Bool-isPatSynBind PatSynBind{} = True+isPatSynBind PatSynBind {} = True isPatSynBind _ = False
src/Language/Haskell/GhclibParserEx/GHC/Hs/Decls.hs view
@@ -2,9 +2,13 @@ -- SPDX-License-Identifier: BSD-3-Clause.  #include "ghclib_api.h"-module Language.Haskell.GhclibParserEx.GHC.Hs.Decls(-    isNewType, isForD, isDerivD, isClsDefSig-  ) where+module Language.Haskell.GhclibParserEx.GHC.Hs.Decls+  ( isNewType,+    isForD,+    isDerivD,+    isClsDefSig,+  )+where  #if defined(GHC_8_8) import HsSyn@@ -22,8 +26,8 @@ isNewType DataType = False  isForD, isDerivD :: LHsDecl GhcPs -> Bool-isForD (L _ ForD{}) = True; isForD _ = False-isDerivD (L _ DerivD{}) = True; isDerivD _ = False+isForD (L _ ForD {}) = True; isForD _ = False+isDerivD (L _ DerivD {}) = True; isDerivD _ = False  isClsDefSig :: Sig GhcPs -> Bool isClsDefSig (ClassOpSig _ True _ _) = True; isClsDefSig _ = False
src/Language/Haskell/GhclibParserEx/GHC/Hs/Dump.hs view
@@ -4,6 +4,7 @@ (c) The University of Glasgow 2006 (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 -}+{- ORMOLU_DISABLE -} {- HLINT ignore -} -- Not our code. {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-}
src/Language/Haskell/GhclibParserEx/GHC/Hs/Expr.hs view
@@ -1,6 +1,7 @@--- Copyright (c) 2020, Shayne Fletcher. All rights reserved.+-- Copyright (c) 2020-2024, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. +{- ORMOLU_DISABLE -} {-# OPTIONS_GHC -Wno-missing-fields #-} {-# LANGUAGE LambdaCase #-} #include "ghclib_api.h"@@ -102,7 +103,12 @@ isTypeApp = \case (L _ HsAppType{}) -> True; _ -> False isWHNF = \case   (L _ (HsVar _ (L _ x))) -> isRdrDataCon x+#if ! ( defined(GHC_9_12) || 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) || defined (GHC_8_8) )+-- ghc api > 9.12.1+  (L _ (HsLit _ x)) -> case x of HsString{} -> False; _ -> True+#else   (L _ (HsLit _ x)) -> case x of HsString{} -> False; HsInt{} -> False; HsRat{} -> False; _ -> True+#endif   (L _ HsLam{}) -> True   (L _ ExplicitTuple{}) -> True   (L _ ExplicitList{}) -> True@@ -158,8 +164,12 @@ #endif -- Field puns in updates have a different type to field puns in -- constructions.-#if ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )--- ghc api >= 9.4.1+#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) || defined (GHC_8_8) )+-- ghc api > 9.10.1+isFieldPunUpdate :: HsFieldBind (LFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool+isFieldPunUpdate = \case HsFieldBind {hfbPun=True} -> True; _ -> False+#elif ! ( defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+-- ghc api >= 9.4.1 && <= 9.12.1 isFieldPunUpdate :: HsFieldBind (LAmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool isFieldPunUpdate = \case HsFieldBind {hfbPun=True} -> True; _ -> False #else@@ -288,7 +298,10 @@  isWholeFrac :: HsExpr GhcPs -> Bool -#if ! (defined (GHC_9_2) || defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )+#if ! ( defined(GHC_9_12) || 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) || defined (GHC_8_8) )+-- ghc api > 9.12.1+isWholeFrac (HsOverLit _ (OverLit _ (HsFractional fl@FL {}) )) = denominator (rationalFromFractionalLit fl) == 1+#elif ! (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
src/Language/Haskell/GhclibParserEx/GHC/Hs/ExtendInstances.hs view
@@ -1,6 +1,7 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. +{- ORMOLU_DISABLE -} {-# LANGUAGE GeneralizedNewtypeDeriving #-} #include "ghclib_api.h" 
src/Language/Haskell/GhclibParserEx/GHC/Hs/ImpExp.hs view
@@ -1,6 +1,7 @@ -- Copyright (c) 2020-2023 Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. +{- ORMOLU_DISABLE -} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp(     isPatSynIE
src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs view
@@ -1,16 +1,22 @@ -- Copyright (c) 2020-203, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause.- {-# LANGUAGE ViewPatterns #-} #include "ghclib_api.h"-module Language.Haskell.GhclibParserEx.GHC.Hs.Pat(-    patToStr, strToPat-  , fromPChar-  , hasPFieldsDotDot-  , isPFieldWildcard, isPWildcard, isPFieldPun, isPatTypeSig, isPBangPat, isPViewPat-  , isWildPat {- alias for 'isPWildcard' -}-  , isSplicePat- ) where+module Language.Haskell.GhclibParserEx.GHC.Hs.Pat+  ( patToStr,+    strToPat,+    fromPChar,+    hasPFieldsDotDot,+    isPFieldWildcard,+    isPWildcard,+    isPFieldPun,+    isPatTypeSig,+    isPBangPat,+    isPViewPat,+    isWildPat {- alias for 'isPWildcard' -},+    isSplicePat,+  )+where  #if defined (GHC_8_8) import HsSyn@@ -59,6 +65,7 @@ #endif  strToPat :: String -> LPat GhcPs+ strToPat z #if defined (GHC_8_8)   | z == "True" = ConPatIn (noLoc true_RDR) (PrefixCon [])@@ -92,7 +99,7 @@  -- Contains a '..' as in 'Foo{..}' hasPFieldsDotDot :: HsRecFields GhcPs (LPat GhcPs) -> Bool-hasPFieldsDotDot HsRecFields {rec_dotdot=Just _} = True+hasPFieldsDotDot HsRecFields {rec_dotdot = Just _} = True hasPFieldsDotDot _ = False  -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'.
src/Language/Haskell/GhclibParserEx/GHC/Hs/Type.hs view
@@ -1,12 +1,14 @@ -- Copyright (c) 2021-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause.- {-# LANGUAGE LambdaCase #-} #include "ghclib_api.h"-module Language.Haskell.GhclibParserEx.GHC.Hs.Type (-    fromTyParen-  , isTyQuasiQuote, isUnboxedTuple, isKindTyApp-) where+module Language.Haskell.GhclibParserEx.GHC.Hs.Type+  ( fromTyParen,+    isTyQuasiQuote,+    isUnboxedTuple,+    isKindTyApp,+  )+where  #if defined (GHC_8_8) import HsSyn@@ -20,14 +22,14 @@ #endif  isKindTyApp :: LHsType GhcPs -> Bool-isKindTyApp = \case (L _ HsAppKindTy{}) -> True; _ -> False+isKindTyApp = \case (L _ HsAppKindTy {}) -> True; _ -> False  fromTyParen :: LHsType GhcPs -> LHsType GhcPs fromTyParen (L _ (HsParTy _ x)) = x fromTyParen x = x  isTyQuasiQuote :: LHsType GhcPs -> Bool-isTyQuasiQuote (L _ (HsSpliceTy _ HsQuasiQuote{})) = True+isTyQuasiQuote (L _ (HsSpliceTy _ HsQuasiQuote {})) = True isTyQuasiQuote _ = False  isUnboxedTuple :: HsTupleSort -> Bool
src/Language/Haskell/GhclibParserEx/GHC/Hs/Types.hs view
@@ -2,8 +2,9 @@ -- SPDX-License-Identifier: BSD-3-Clause.  module Language.Haskell.GhclibParserEx.GHC.Hs.Types-  {-# DEPRECATED "Use Language.Haskell.GhclibParserEx.GHC.Hs.Type instead" #-} (-  module Language.Haskell.GhclibParserEx.GHC.Hs.Type-  ) where+  {-# DEPRECATED "Use Language.Haskell.GhclibParserEx.GHC.Hs.Type instead" #-}+  ( module Language.Haskell.GhclibParserEx.GHC.Hs.Type,+  )+where  import Language.Haskell.GhclibParserEx.GHC.Hs.Type
src/Language/Haskell/GhclibParserEx/GHC/Parser.hs view
@@ -1,7 +1,7 @@--- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved.+-- Copyright (c) 2020-2024, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. -+{- ORMOLU_DISABLE -} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Parser(     parseFile
src/Language/Haskell/GhclibParserEx/GHC/Settings/Config.hs view
@@ -1,6 +1,7 @@--- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved.+-- Copyright (c) 2020-2024, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. +{- ORMOLU_DISABLE -} {-# OPTIONS_GHC -Wno-missing-fields #-} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Settings.Config(@@ -29,6 +30,10 @@ import GHC.Platform import GHC.Settings #endif+#if ! (defined (GHC_9_12) || 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) || defined (GHC_8_8))+{- since 9.14 -}+import GHC.Unit.Types (stringToUnitId)+#endif  fakeSettings :: Settings fakeSettings = Settings@@ -47,15 +52,31 @@   , sPlatformConstants=platformConstants   , sToolSettings=toolSettings   }+#elif (defined (GHC_9_2) || defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12))+  { sGhcNameVersion=ghcNameVersion+  , sFileSettings=fileSettings+  , sTargetPlatform=platform+  , sPlatformMisc=platformMisc+  , sToolSettings=toolSettings+  } #else+ {- defined (GHC_9_14) -}   { sGhcNameVersion=ghcNameVersion   , sFileSettings=fileSettings   , sTargetPlatform=platform   , sPlatformMisc=platformMisc   , sToolSettings=toolSettings+  , sUnitSettings=unitSettings   } #endif   where+#if !(defined (GHC_8_8) || defined (GHC_8_10) || defined (GHC_9_0) || defined (GHC_9_2) || (defined GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12))+{- ghc-api>=9.14.1  -}+    unitSettings = UnitSettings {+        unitSettings_baseUnitId = stringToUnitId "base"+      }+#endif+ #if !defined (GHC_8_8)     toolSettings = ToolSettings {         toolSettings_opt_P_fingerprint=fingerprint0
src/Language/Haskell/GhclibParserEx/GHC/Types/Name/Reader.hs view
@@ -2,9 +2,14 @@ -- SPDX-License-Identifier: BSD-3-Clause.  #include "ghclib_api.h"-module Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader(-   occNameStr, rdrNameStr, isSpecial, unqual, fromQual, isSymbolRdrName- )+module Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader+  ( occNameStr,+    rdrNameStr,+    isSpecial,+    unqual,+    fromQual,+    isSymbolRdrName,+  ) where  #if !( defined (GHC_9_0) || defined (GHC_8_10) || defined (GHC_8_8) )
src/Language/Haskell/GhclibParserEx/GHC/Utils/Outputable.hs view
@@ -1,6 +1,7 @@ -- Copyright (c) 2020-2023, Shayne Fletcher. All rights reserved. -- SPDX-License-Identifier: BSD-3-Clause. +{- ORMOLU_DISABLE -} #include "ghclib_api.h" module Language.Haskell.GhclibParserEx.GHC.Utils.Outputable (     unsafePrettyPrint
test/Test.hs view
@@ -354,7 +354,7 @@   ]   where     assert' = assertBool ""-    test s = declTest s (flags [])+    test s = declTest s (flags [ BangPatterns ])     flags = foldl' xopt_set basicDynFlags  expressionPredicateTests :: TestTree