diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index ae103b43..09d55459 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -17,6 +17,7 @@ on: push: branches: - main + - ghc96 pull_request: branches: - main @@ -32,6 +33,11 @@ jobs: strategy: matrix: include: + - compiler: ghc-9.6.5 + compilerKind: ghc + compilerVersion: 9.6.5 + setup-method: ghcup + allow-failure: false - compiler: ghc-9.4.5 compilerKind: ghc compilerVersion: 9.4.5 @@ -47,16 +53,6 @@ jobs: compilerVersion: 9.0.2 setup-method: ghcup allow-failure: false - - compiler: ghc-8.10.7 - compilerKind: ghc - compilerVersion: 8.10.7 - setup-method: ghcup - allow-failure: false - - compiler: ghc-8.8.4 - compilerKind: ghc - compilerVersion: 8.8.4 - setup-method: hvr-ppa - allow-failure: false fail-fast: false steps: - name: apt @@ -178,7 +174,6 @@ jobs: echo "packages: $GITHUB_WORKSPACE/source/large-records" >> cabal.project if [ $((HCNUMVER < 81000)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/large-records-benchmarks" >> cabal.project ; fi echo "packages: $GITHUB_WORKSPACE/source/large-anon" >> cabal.project - echo "packages: $GITHUB_WORKSPACE/source/beam-large-records" >> cabal.project echo "packages: $GITHUB_WORKSPACE/source/typelet" >> cabal.project cat cabal.project - name: sdist @@ -199,8 +194,6 @@ jobs: echo "PKGDIR_large_records_benchmarks=${PKGDIR_large_records_benchmarks}" >> "$GITHUB_ENV" PKGDIR_large_anon="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/large-anon-[0-9.]*')" echo "PKGDIR_large_anon=${PKGDIR_large_anon}" >> "$GITHUB_ENV" - PKGDIR_beam_large_records="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/beam-large-records-[0-9.]*')" - echo "PKGDIR_beam_large_records=${PKGDIR_beam_large_records}" >> "$GITHUB_ENV" PKGDIR_typelet="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/typelet-[0-9.]*')" echo "PKGDIR_typelet=${PKGDIR_typelet}" >> "$GITHUB_ENV" rm -f cabal.project cabal.project.local @@ -210,7 +203,6 @@ jobs: echo "packages: ${PKGDIR_large_records}" >> cabal.project if [ $((HCNUMVER < 81000)) -ne 0 ] ; then echo "packages: ${PKGDIR_large_records_benchmarks}" >> cabal.project ; fi echo "packages: ${PKGDIR_large_anon}" >> cabal.project - echo "packages: ${PKGDIR_beam_large_records}" >> cabal.project echo "packages: ${PKGDIR_typelet}" >> cabal.project echo "package large-generics" >> cabal.project echo " ghc-options: -Werror=missing-methods" >> cabal.project @@ -220,29 +212,9 @@ jobs: if [ $((HCNUMVER < 81000)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi echo "package large-anon" >> cabal.project echo " ghc-options: -Werror=missing-methods" >> cabal.project - echo "package beam-large-records" >> cabal.project - echo " ghc-options: -Werror=missing-methods" >> cabal.project echo "package typelet" >> cabal.project echo " ghc-options: -Werror=missing-methods" >> cabal.project cat >> cabal.project <> cabal.project.local + $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(large-anon|large-generics|large-records|large-records-benchmarks|typelet)$/; }' >> cabal.project.local cat cabal.project cat cabal.project.local - name: dump install plan diff --git a/cabal.project b/cabal.project index 1f8c4b36..9c785673 100644 --- a/cabal.project +++ b/cabal.project @@ -2,15 +2,15 @@ packages: large-generics , large-records , large-records-benchmarks , large-anon - , beam-large-records +-- , beam-large-records , typelet -- we need https://github.com/haskell-beam/beam/pull/585 -source-repository-package - type: git - location: https://github.com/well-typed/beam - tag: f13fedc299727b2706f26cdfeff3913923cb1a79 - subdir: beam-core beam-migrate beam-sqlite +-- source-repository-package +-- type: git +-- location: https://github.com/well-typed/beam +-- tag: f13fedc299727b2706f26cdfeff3913923cb1a79 +-- subdir: beam-core beam-migrate beam-sqlite -- enable for GHC head -- repository head.hackage.ghc.haskell.org @@ -33,10 +33,9 @@ package large-records-benchmarks package large-anon tests: True - ghc-options: -dcore-lint -package beam-large-records - tests: True +-- package beam-large-records +-- tests: True package typelet tests: True diff --git a/large-anon/large-anon.cabal b/large-anon/large-anon.cabal index 0ac5e819..bb44b6cf 100644 --- a/large-anon/large-anon.cabal +++ b/large-anon/large-anon.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: large-anon -version: 0.3.0 +version: 0.4.0 synopsis: Scalable anonymous records description: The @large-anon@ package provides support for anonymous records in Haskell, with a focus on compile-time (and @@ -70,23 +70,23 @@ library Data.Record.Anon.Internal.Plugin.Source.Options build-depends: - base >= 4.13 && < 4.18 - , aeson >= 1.4.4 && < 2.2 + base >= 4.13 && < 4.19 + , aeson >= 1.4.4 && < 2.3 , containers >= 0.6.2 && < 0.7 , deepseq >= 1.4.4 && < 1.5 , ghc-tcplugin-api >= 0.10 && < 0.11 , hashable >= 1.3 && < 1.5 - , mtl >= 2.2.1 && < 2.3 + , mtl >= 2.2.1 && < 2.4 , optics-core >= 0.3 && < 0.5 , primitive >= 0.8 && < 0.9 , record-hasfield >= 1.0 && < 1.1 , sop-core >= 0.5 && < 0.6 , syb >= 0.7 && < 0.8 , tagged >= 0.8.6 && < 0.9 - , typelet >= 0.1 && < 0.2 + , typelet >= 0.2 && < 0.3 -- large-generics 0.2 starts using 'SmallArray' instead of 'Vector' - , large-generics >= 0.2 && < 0.3 + , large-generics >= 0.3 && < 0.4 -- Whatever version is bundled with ghc , ghc diff --git a/large-anon/src/Data/Record/Anon/Advanced.hs b/large-anon/src/Data/Record/Anon/Advanced.hs index 4ef3c316..ccd20149 100644 --- a/large-anon/src/Data/Record/Anon/Advanced.hs +++ b/large-anon/src/Data/Record/Anon/Advanced.hs @@ -205,7 +205,7 @@ applyPending = A.applyPending -- absentField r = get #c r -- :} -- ... --- ...No instance for (RowHasField "c"... +-- ...No instance for...RowHasField "c"... -- ... -- -- Type mismatches will result in regular type errors: @@ -226,7 +226,7 @@ applyPending = A.applyPending -- unknownField r = get #b r -- :} -- ... --- ...No instance for (RowHasField "b"... +-- ...No instance for...RowHasField "b"... -- ... -- -- (Note that @x@ here is a variable, not a string.) It is important that the @@ -280,7 +280,7 @@ set = A.set -- example = project -- :} -- ... --- ...No instance for (SubRow... +-- ...No instance for...SubRow... -- ... -- -- Type inference will work through projections: field types are unified based @@ -347,7 +347,7 @@ lens = A.lens -- example r = get #b r -- :} -- ... --- ...No instance for (RowHasField "b"... +-- ...No instance for...RowHasField "b"... -- ... merge :: Record f r -> Record f r' -> Record f (Merge r r') merge = A.merge diff --git a/large-anon/src/Data/Record/Anon/Internal/Core/FieldName.hs b/large-anon/src/Data/Record/Anon/Internal/Core/FieldName.hs index 48a83a31..7dce454e 100644 --- a/large-anon/src/Data/Record/Anon/Internal/Core/FieldName.hs +++ b/large-anon/src/Data/Record/Anon/Internal/Core/FieldName.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + -- | Field name -- -- Intended for qualified import. @@ -17,6 +19,11 @@ import Data.String import Data.Record.Anon.Internal.Plugin.TC.GhcTcPluginAPI +#if __GLASGOW_HASKELL__ >= 906 +import GHC.Data.FastString (mkFastString) +#endif + + {------------------------------------------------------------------------------- Definition -------------------------------------------------------------------------------} @@ -63,6 +70,8 @@ instance Show FieldName where showString "fromString " . showsPrec 11 (fieldNameLabel n) instance Outputable FieldName where +#if __GLASGOW_HASKELL__ >= 906 + ppr = ppr . mkFastString . fieldNameLabel +#else ppr = ppr . fieldNameLabel - - +#endif diff --git a/large-anon/src/Data/Record/Anon/Internal/Plugin/Source/GhcShim.hs b/large-anon/src/Data/Record/Anon/Internal/Plugin/Source/GhcShim.hs index a07864ab..d6c9cba8 100644 --- a/large-anon/src/Data/Record/Anon/Internal/Plugin/Source/GhcShim.hs +++ b/large-anon/src/Data/Record/Anon/Internal/Plugin/Source/GhcShim.hs @@ -102,7 +102,6 @@ import GHC.Driver.Session (getDynFlags) import GHC.Types.Name (mkInternalName) import GHC.Types.Name.Occurrence import GHC.Types.Name.Reader (RdrName(Exact), rdrNameOcc, mkRdrQual, mkRdrUnqual) -import GHC.Types.SrcLoc (LayoutInfo(NoLayoutInfo)) import GHC.Types.Unique (Unique) import GHC.Types.Unique.Supply (takeUniqFromSupply) import GHC.Utils.Monad @@ -113,7 +112,9 @@ import GHC.Driver.Env.Types import GHC.Driver.Errors import GHC.Types.SourceText (SourceText(NoSourceText)) import GHC.Unit.Finder (findImportedModule, FindResult(Found)) +#if __GLASGOW_HASKELL__ < 906 import GHC.Unit.Types (IsBootInterface(NotBoot)) +#endif #else import GHC.Driver.Finder (findImportedModule) import GHC.Driver.Types @@ -131,14 +132,32 @@ import GHC.Driver.Config.Diagnostic (initDiagOpts) import GHC.Driver.Errors.Types (GhcMessage(..)) import GHC.Iface.Env (lookupNameCache) import GHC.Rename.Names (renamePkgQual) -import GHC.Types.Error (MsgEnvelope(..), mkMessages) +import GHC.Types.Error (mkMessages) import GHC.Types.Name.Cache (NameCache, takeUniqFromNameCache) import GHC.Types.PkgQual (RawPkgQual(NoRawPkgQual)) +#if __GLASGOW_HASKELL__ < 906 +import GHC.Types.Error (MsgEnvelope(..)) import GHC.Utils.Error (mkPlainError) #endif +#endif + +#endif + +#if __GLASGOW_HASKELL__ >= 906 +-- import Language.Haskell.Syntax.Concrete (LayoutInfo(NoLayoutInfo)) +#else +import GHC.Types.SrcLoc (LayoutInfo(NoLayoutInfo)) +#endif +#if __GLASGOW_HASKELL__ >= 906 +import GHC.Types.Error (UnknownDiagnostic(..), + DiagnosticReason(WarningWithoutFlag), + mkPlainDiagnostic) +import GHC.Driver.Config.Diagnostic (initPrintConfig) +import GHC.Utils.Error (mkMsgEnvelope) #endif + {------------------------------------------------------------------------------- Names -------------------------------------------------------------------------------} @@ -206,8 +225,12 @@ hscNameCacheIO = hsc_NC -- | Optionally @qualified@ import declaration importDecl :: Bool -> ModuleName -> LImportDecl GhcPs importDecl qualified name = reLocA $ noLoc $ ImportDecl { +#if __GLASGOW_HASKELL__ >= 906 + ideclExt = XImportDeclPass EpAnnNotUsed NoSourceText True +#else ideclExt = defExt , ideclSourceSrc = NoSourceText +#endif , ideclName = reLocA $ noLoc name #if __GLASGOW_HASKELL__ >= 904 , ideclPkgQual = NoRawPkgQual @@ -215,9 +238,13 @@ importDecl qualified name = reLocA $ noLoc $ ImportDecl { , ideclPkgQual = Nothing #endif , ideclSafe = False +#if __GLASGOW_HASKELL__ < 906 , ideclImplicit = False +#endif , ideclAs = Nothing +#if __GLASGOW_HASKELL__ < 906 , ideclHiding = Nothing +#endif #if __GLASGOW_HASKELL__ < 810 , ideclQualified = qualified #else @@ -227,6 +254,9 @@ importDecl qualified name = reLocA $ noLoc $ ImportDecl { , ideclSource = False #else , ideclSource = NotBoot +#endif +#if __GLASGOW_HASKELL__ >= 906 + , ideclImportList = Nothing #endif } @@ -237,6 +267,16 @@ issueWarning l errMsg = do logger <- getLogger liftIO $ printOrThrowWarnings logger dynFlags . bag $ mkWarnMsg l neverQualify errMsg +#elif __GLASGOW_HASKELL__ >= 906 + logger <- getLogger + let printOpts = initPrintConfig dynFlags + diagOpts = initDiagOpts dynFlags + liftIO $ printOrThrowDiagnostics logger printOpts diagOpts . mkMessages . bag $ + mkMsgEnvelope + diagOpts + l + neverQualify + (GhcUnknownMessage $ UnknownDiagnostic $ mkPlainDiagnostic WarningWithoutFlag [] errMsg) #elif __GLASGOW_HASKELL__ >= 904 logger <- getLogger liftIO $ printOrThrowDiagnostics logger (initDiagOpts dynFlags) . mkMessages . bag $ @@ -277,7 +317,10 @@ instance HasDefaultExt NoExtField where defExt = noExtField #endif -#if __GLASGOW_HASKELL__ >= 900 +#if __GLASGOW_HASKELL__ >= 906 +instance HasDefaultExt (LayoutInfo pass) where + defExt = NoLayoutInfo +#elif __GLASGOW_HASKELL__ >= 900 instance HasDefaultExt LayoutInfo where defExt = NoLayoutInfo #endif @@ -306,7 +349,9 @@ reLocA = id mkLabel :: SrcSpan -> FastString -> LHsExpr GhcPs mkLabel l n = reLocA $ L l $ HsOverLabel defExt -#if __GLASGOW_HASKELL__ < 902 +#if __GLASGOW_HASKELL__ >= 906 + NoSourceText +#elif __GLASGOW_HASKELL__ < 902 Nothing #endif n diff --git a/large-generics/large-generics.cabal b/large-generics/large-generics.cabal index c898707e..222cf749 100644 --- a/large-generics/large-generics.cabal +++ b/large-generics/large-generics.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: large-generics -version: 0.2.1 +version: 0.3.0 synopsis: Generic programming API for large-records and large-anon description: The large-generics package offers a style of generic programming inspired by generics-sop, but optimized for @@ -42,8 +42,8 @@ library hs-source-dirs: src build-depends: - base >= 4.13 && < 4.18 - , aeson >= 1.4.4 && < 2.2 + base >= 4.13 && < 4.19 + , aeson >= 1.4.4 && < 2.3 , deepseq >= 1.4.4 && < 1.5 , generics-sop >= 0.5 && < 0.6 , sop-core >= 0.5 && < 0.6 diff --git a/large-records-benchmarks/large-records-benchmarks.cabal b/large-records-benchmarks/large-records-benchmarks.cabal index 53ea5a67..f53eaa96 100644 --- a/large-records-benchmarks/large-records-benchmarks.cabal +++ b/large-records-benchmarks/large-records-benchmarks.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: large-records-benchmarks -version: 0.1.0.0 +version: 0.2.0.0 synopsis: Benchmarks for the large-records library. description: Detailed benchmarks of the compile-time performance of the large-records library, as well as various experiments @@ -21,7 +21,7 @@ common defaults default-language: Haskell2010 build-depends: - base >= 4.13 && < 4.18 + base >= 4.13 && < 4.19 ghc-options: -Wall diff --git a/large-records/large-records.cabal b/large-records/large-records.cabal index 1409ecef..d4d6506f 100644 --- a/large-records/large-records.cabal +++ b/large-records/large-records.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: large-records -version: 0.4 +version: 0.5 synopsis: Efficient compilation for large records, linear in the size of the record description: For many reasons, the internal code generated for modules that contain records is quadratic in the number of record @@ -44,15 +44,15 @@ library Data.Record.Internal.Plugin.Record build-depends: - base >= 4.13 && < 4.18 + base >= 4.13 && < 4.19 , containers >= 0.6.2 && < 0.7 - , mtl >= 2.2.1 && < 2.3 + , mtl >= 2.2.1 && < 2.4 , primitive >= 0.8 && < 0.9 , syb >= 0.7 && < 0.8 , record-hasfield >= 1.0 && < 1.1 -- large-generics 0.2 starts using 'SmallArray' instead of 'Vector' - , large-generics >= 0.2 && < 0.3 + , large-generics >= 0.3 && < 0.4 -- transformers 0.5.6 introduces Writer.CPS , transformers >= 0.5.6 && < 0.7 diff --git a/large-records/src/Data/Record/Internal/GHC/Shim.hs b/large-records/src/Data/Record/Internal/GHC/Shim.hs index c6b555ea..a0875117 100644 --- a/large-records/src/Data/Record/Internal/GHC/Shim.hs +++ b/large-records/src/Data/Record/Internal/GHC/Shim.hs @@ -163,6 +163,10 @@ import GHC.Rename.Names (renamePkgQual) import GHC.Types.Name.Cache (NameCache, takeUniqFromNameCache) #endif +#if __GLASGOW_HASKELL__ >= 906 +import Language.Haskell.Syntax.Basic (FieldLabelString(..)) +#endif + #endif {------------------------------------------------------------------------------- @@ -226,8 +230,12 @@ lookupOrigIO env modl occ = lookupNameCache (hsc_NC env) modl occ -- | Optionally @qualified@ import declaration importDecl :: ModuleName -> Bool -> LImportDecl GhcPs importDecl name qualified = noLocA $ ImportDecl { +#if __GLASGOW_HASKELL__ >= 906 + ideclExt = XImportDeclPass EpAnnNotUsed NoSourceText True +#else ideclExt = defExt , ideclSourceSrc = NoSourceText +#endif , ideclName = noLocA name #if __GLASGOW_HASKELL__ >= 904 , ideclPkgQual = NoRawPkgQual @@ -235,9 +243,13 @@ importDecl name qualified = noLocA $ ImportDecl { , ideclPkgQual = Nothing #endif , ideclSafe = False +#if __GLASGOW_HASKELL__ < 906 , ideclImplicit = False +#endif , ideclAs = Nothing +#if __GLASGOW_HASKELL__ < 906 , ideclHiding = Nothing +#endif #if __GLASGOW_HASKELL__ < 810 , ideclQualified = qualified #else @@ -247,6 +259,9 @@ importDecl name qualified = noLocA $ ImportDecl { , ideclSource = False #else , ideclSource = NotBoot +#endif +#if __GLASGOW_HASKELL__ >= 906 + , ideclImportList = Nothing #endif } @@ -270,7 +285,11 @@ type HsModule = GHC.HsModule GhcPs type HsModule = GHC.HsModule #endif +#if __GLASGOW_HASKELL__ >= 906 +type LHsModule = Located (HsModule GhcPs) +#else type LHsModule = Located HsModule +#endif type LRdrName = Located RdrName {------------------------------------------------------------------------------- @@ -331,10 +350,19 @@ instance HasDefaultExt NoExtField where defExt = noExtField #endif -#if __GLASGOW_HASKELL__ >= 900 +#if __GLASGOW_HASKELL__ >= 906 +instance HasDefaultExt (LayoutInfo pass) where + defExt = NoLayoutInfo +#elif __GLASGOW_HASKELL__ >= 900 instance HasDefaultExt LayoutInfo where defExt = NoLayoutInfo #endif +#if __GLASGOW_HASKELL__ >= 906 +instance HasDefaultExt Origin where + defExt = Generated +instance HasDefaultExt SourceText where + defExt = NoSourceText +#endif instance (HasDefaultExt a, HasDefaultExt b) => HasDefaultExt (a, b) where defExt = (defExt, defExt) @@ -559,7 +587,11 @@ simpleRecordUpdates = isSingleLabel :: FieldLabelStrings GhcPs -> Maybe LRdrName isSingleLabel (FieldLabelStrings labels) = case labels of +#if __GLASGOW_HASKELL__ >= 906 + [L _ (DotFieldOcc _ (L l (FieldLabelString label)))] -> +#else [L _ (DotFieldOcc _ (L l label))] -> +#endif Just $ reLoc $ L l (Unqual $ mkVarOccFS label) _otherwise -> Nothing diff --git a/large-records/src/Data/Record/Internal/GHC/TemplateHaskellStyle.hs b/large-records/src/Data/Record/Internal/GHC/TemplateHaskellStyle.hs index ea2a1d79..6bd92c14 100644 --- a/large-records/src/Data/Record/Internal/GHC/TemplateHaskellStyle.hs +++ b/large-records/src/Data/Record/Internal/GHC/TemplateHaskellStyle.hs @@ -289,7 +289,11 @@ listE es = inheritLoc es $ ExplicitList defExt lamE :: NonEmpty (LPat GhcPs) -> LHsExpr GhcPs -> LHsExpr GhcPs lamE pats body = inheritLoc body $ HsLam defExt $ +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + MG defExt (inheritLoc body [inheritLoc body match]) +#else MG defExt (inheritLoc body [inheritLoc body match]) Generated +#endif where match :: Match GhcPs (LHsExpr GhcPs) match = Match defExt LambdaExpr (NE.toList pats) (simpleGHRSs body) @@ -301,7 +305,11 @@ lamE1 p = lamE (p :| []) -- | Equivalent of 'Language.Haskell.TH.Lib.caseE' caseE :: LHsExpr GhcPs -> [(LPat GhcPs, LHsExpr GhcPs)] -> LHsExpr GhcPs caseE x alts = inheritLoc x $ +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + HsCase defExt x (MG defExt (inheritLoc x (map mkAlt alts))) +#else HsCase defExt x (MG defExt (inheritLoc x (map mkAlt alts)) Generated) +#endif where mkAlt :: (LPat GhcPs, LHsExpr GhcPs) -> LMatch GhcPs (LHsExpr GhcPs) mkAlt (pat, body) = inheritLoc x $ @@ -314,6 +322,9 @@ appsE = foldl' appE -- | Equivalent of 'Language.Haskell.TH.Lib.appT' appTypeE :: LHsExpr GhcPs -> LHsType GhcPs -> LHsExpr GhcPs appTypeE expr typ = inheritLoc expr $ +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + HsAppType noExtField expr noHsTok (HsWC defExt typ) +#else HsAppType #if __GLASGOW_HASKELL__ >= 902 (toSrcSpan expr) @@ -322,7 +333,7 @@ appTypeE expr typ = inheritLoc expr $ #endif expr (HsWC defExt typ) - +#endif -- | Equivalent of 'Language.Haskell.TH.Lib.tupE' tupE :: NonEmpty (LHsExpr GhcPs) -> LHsExpr GhcPs tupE xs = inheritLoc xs $ @@ -353,7 +364,11 @@ parensT :: LHsType GhcPs -> LHsType GhcPs parensT = noLocA . HsParTy defExt -- | Equivalent of 'Language.Haskell.TH.Lib.litT' +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) +litT :: HsTyLit GhcPs -> LHsType GhcPs +#else litT :: HsTyLit -> LHsType GhcPs +#endif litT = noLocA . HsTyLit defExt -- | Equivalent of 'Language.Haskell.TH.Lib.varT' @@ -604,7 +619,10 @@ dataD typeName tyVars cons derivs = inheritLoc typeName $ , tcdFixity = Prefix , tcdDataDefn = HsDataDefn { dd_ext = defExt +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) +#else , dd_ND = DataType +#endif #if __GLASGOW_HASKELL__ >= 902 , dd_ctxt = Nothing #else @@ -612,7 +630,11 @@ dataD typeName tyVars cons derivs = inheritLoc typeName $ #endif , dd_cType = Nothing , dd_kindSig = Nothing +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + , dd_cons = DataTypeCons False cons +#else , dd_cons = cons +#endif , dd_derivs = inheritLoc typeName derivs } } @@ -635,15 +657,22 @@ viewDataD , tcdTyVars = HsQTvs {hsq_explicit = tyVars} , tcdFixity = Prefix , tcdDataDefn = HsDataDefn { - dd_ND = DataType +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) +#else + dd_ND = DataType, +#endif #if __GLASGOW_HASKELL__ >= 902 - , dd_ctxt = Nothing + dd_ctxt = Nothing #else - , dd_ctxt = L _ [] + dd_ctxt = L _ [] #endif , dd_cType = Nothing , dd_kindSig = Nothing +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + , dd_cons = DataTypeCons False cons +#else , dd_cons = cons +#endif #if __GLASGOW_HASKELL__ >= 902 , dd_derivs = derivs #else @@ -746,6 +775,9 @@ classD :: classD = \ctx name clsVars sigs -> inheritLoc name $ TyClD defExt $ ClassDecl { tcdCExt = defExt +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + , tcdLayout = NoLayoutInfo +#endif #if __GLASGOW_HASKELL__ >= 902 , tcdCtxt = Just (inheritLoc name ctx) #else @@ -821,14 +853,22 @@ pattern TypeAnnotation name <- (viewTypeAnnotation -> Just name) -- | Equivalent of 'Language.Haskell.TH.Lib.pragAnnD' pragAnnD :: AnnProvenancePs -> LHsExpr GhcPs -> AnnDecl GhcPs pragAnnD prov value = +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + HsAnnotation defExt prov value +#else HsAnnotation defExt NoSourceText prov value +#endif viewPragAnnD :: AnnDecl GhcPs -> (AnnProvenancePs, LHsExpr GhcPs) +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) +viewPragAnnD (HsAnnotation _ prov value) = (prov, value) +#else viewPragAnnD (HsAnnotation _ _ prov value) = (prov, value) +#endif #if __GLASGOW_HASKELL__ < 900 viewPragAnnD _ = panic "viewPragAnnD" #endif @@ -881,5 +921,3 @@ simpleGHRSs body = GRHSs defExt [inheritLoc body $ GRHS defExt [] body] (inheritLoc body $ EmptyLocalBinds defExt) - - diff --git a/large-records/src/Data/Record/Internal/Plugin/Options.hs b/large-records/src/Data/Record/Internal/Plugin/Options.hs index c62e55dd..d1614938 100644 --- a/large-records/src/Data/Record/Internal/Plugin/Options.hs +++ b/large-records/src/Data/Record/Internal/Plugin/Options.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DerivingStrategies #-} @@ -67,7 +68,11 @@ instance HasField "debugLargeRecords" LargeRecordOptions Bool where -- | Extract all 'LargeRecordOptions' in a module -- -- Additionally returns the location of the ANN pragma. +#if __GLASGOW_HASKELL__ >= 906 +getLargeRecordOptions :: HsModule GhcPs -> Map String [(SrcSpan, LargeRecordOptions)] +#else getLargeRecordOptions :: HsModule -> Map String [(SrcSpan, LargeRecordOptions)] +#endif getLargeRecordOptions = Map.fromListWith (++) . map (second (:[])) diff --git a/large-records/src/Data/Record/Plugin.hs b/large-records/src/Data/Record/Plugin.hs index 7ae35da3..5915cbfe 100644 --- a/large-records/src/Data/Record/Plugin.hs +++ b/large-records/src/Data/Record/Plugin.hs @@ -39,6 +39,10 @@ module Data.Record.Plugin ( , plugin ) where +import Control.Monad +#if __GLASGOW_HASKELL__ >= 906 +import Control.Monad.Trans.Class (lift) +#endif import Control.Monad.Except import Control.Monad.Trans.Writer.CPS import Data.List (intersperse) @@ -75,7 +79,10 @@ import GHC.Driver.Errors.Types (GhcMessage(GhcUnknownMessage)) import GHC.Types.Error (mkPlainError, mkMessages, mkPlainDiagnostic) import GHC.Utils.Error (mkMsgEnvelope, mkErrorMsgEnvelope) #endif - +#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) +import GHC.Types.Error (UnknownDiagnostic(..)) +import GHC.Driver.Config.Diagnostic (initPrintConfig) +#endif {------------------------------------------------------------------------------- Top-level: the plugin proper -------------------------------------------------------------------------------} @@ -213,6 +220,12 @@ issueError l errMsg = do #if __GLASGOW_HASKELL__ == 902 throwOneError $ mkErr l neverQualify (mkDecorated [errMsg]) +#elif MIN_VERSION_GLASGOW_HASKELL(9,6,0,0) + throwOneError $ + mkErrorMsgEnvelope + l + neverQualify + (GhcUnknownMessage $ UnknownDiagnostic $ mkPlainError [] errMsg) #elif __GLASGOW_HASKELL__ >= 904 throwOneError $ mkErrorMsgEnvelope @@ -232,6 +245,16 @@ issueWarning l errMsg = do logger <- getLogger liftIO $ printOrThrowWarnings logger dynFlags . bag $ mkWarnMsg l neverQualify errMsg +#elif __GLASGOW_HASKELL__ >= 906 + logger <- getLogger + let printOpts = initPrintConfig dynFlags + diagOpts = initDiagOpts dynFlags + liftIO $ printOrThrowDiagnostics logger printOpts diagOpts . mkMessages . bag $ + mkMsgEnvelope + diagOpts + l + neverQualify + (GhcUnknownMessage $ UnknownDiagnostic $ mkPlainDiagnostic WarningWithoutFlag [] errMsg) #elif __GLASGOW_HASKELL__ >= 904 logger <- getLogger liftIO $ printOrThrowDiagnostics logger (initDiagOpts dynFlags) . mkMessages . bag $ diff --git a/large-records/test/Test/Record/Util.hs b/large-records/test/Test/Record/Util.hs index 23892a8c..72635f87 100644 --- a/large-records/test/Test/Record/Util.hs +++ b/large-records/test/Test/Record/Util.hs @@ -18,7 +18,11 @@ module Test.Record.Util ( ) where import Control.Exception +#if __GLASGOW_HASKELL__ >= 906 +import Control.Monad.Except +#else import Control.Monad.Except hiding (lift) +#endif import Control.Monad.State hiding (lift) import Data.Bifunctor import Data.List (isPrefixOf) diff --git a/typelet/src/TypeLet/Plugin/GhcTcPluginAPI.hs b/typelet/src/TypeLet/Plugin/GhcTcPluginAPI.hs index 325a7df5..24ccb6ad 100644 --- a/typelet/src/TypeLet/Plugin/GhcTcPluginAPI.hs +++ b/typelet/src/TypeLet/Plugin/GhcTcPluginAPI.hs @@ -22,7 +22,6 @@ import GHC.Utils.Outputable #if MIN_VERSION_ghc(9,0,0) import GHC.Core.TyCo.FVs (tyCoVarsOfType) -import GHC.Core.TyCo.Subst (TCvSubst) import GHC.Types.Var.Set (elemVarSet) import qualified GHC.Core.TyCo.Subst as Subst @@ -36,3 +35,9 @@ import qualified TcType as Subst #endif +#if __GLASGOW_HASKELL__ >= 906 +import GHC.Core.Subst (Subst) +type TCvSubst = Subst +#else +import GHC.Core.TyCo.Subst (TCvSubst) +#endif diff --git a/typelet/typelet.cabal b/typelet/typelet.cabal index 8129400c..1771c6d7 100644 --- a/typelet/typelet.cabal +++ b/typelet/typelet.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 build-type: Simple name: typelet -version: 0.1.3 +version: 0.2.0 synopsis: Plugin to faciliate type-level let description: For a certain class of programs, type-level let is essential in order to be able to write these programs in such a way @@ -34,7 +34,7 @@ library TypeLet.Plugin.NameResolution TypeLet.Plugin.Substitution build-depends: - base >= 4.13 && < 4.18 + base >= 4.13 && < 4.19 , ghc-tcplugin-api >= 0.10 && < 0.11 -- whichever versions are bundled with ghc: