Skip to content

Commit

Permalink
Support GHC 9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrsales committed May 24, 2024
1 parent 6323af1 commit bd74b39
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 68 deletions.
37 changes: 0 additions & 37 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,4 @@ packages: large-generics
, large-records
, large-records-benchmarks
, large-anon
, 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

-- enable for GHC head
-- repository head.hackage.ghc.haskell.org
-- url: https://ghc.gitlab.haskell.org/head.hackage/
-- secure: True
-- key-threshold: 3
-- root-keys:
-- f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
-- 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
-- 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d

package large-generics
tests: True

package large-records
tests: True

package large-records-benchmarks
tests: True

package large-anon
tests: True
ghc-options: -dcore-lint

package beam-large-records
tests: True

package typelet
tests: True
12 changes: 6 additions & 6 deletions large-anon/large-anon.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions large-anon/src/Data/Record/Anon/Internal/Core/FieldName.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

-- | Field name
--
-- Intended for qualified import.
Expand All @@ -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
-------------------------------------------------------------------------------}
Expand Down Expand Up @@ -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
53 changes: 49 additions & 4 deletions large-anon/src/Data/Record/Anon/Internal/Plugin/Source/GhcShim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
-------------------------------------------------------------------------------}
Expand Down Expand Up @@ -206,18 +225,26 @@ 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
#else
, 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
Expand All @@ -227,6 +254,9 @@ importDecl qualified name = reLocA $ noLoc $ ImportDecl {
, ideclSource = False
#else
, ideclSource = NotBoot
#endif
#if __GLASGOW_HASKELL__ >= 906
, ideclImportList = Nothing
#endif
}

Expand All @@ -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 $
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions large-generics/large-generics.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions large-records-benchmarks/large-records-benchmarks.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,7 +21,7 @@ common defaults
default-language:
Haskell2010
build-depends:
base >= 4.13 && < 4.18
base >= 4.13 && < 4.19
ghc-options:
-Wall

Expand Down
8 changes: 4 additions & 4 deletions large-records/large-records.cabal
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
34 changes: 33 additions & 1 deletion large-records/src/Data/Record/Internal/GHC/Shim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

{-------------------------------------------------------------------------------
Expand Down Expand Up @@ -226,18 +230,26 @@ 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
#else
, 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
Expand All @@ -247,6 +259,9 @@ importDecl name qualified = noLocA $ ImportDecl {
, ideclSource = False
#else
, ideclSource = NotBoot
#endif
#if __GLASGOW_HASKELL__ >= 906
, ideclImportList = Nothing
#endif
}

Expand All @@ -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

{-------------------------------------------------------------------------------
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit bd74b39

Please sign in to comment.