Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GHC 9.10 #262

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- ghc948
- ghc965
- ghc982
- ghc910
dhall:
- false
- true
Expand Down
16 changes: 8 additions & 8 deletions proto3-suite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ library

other-modules: Turtle.Compat

build-depends: aeson >= 1.1.1.0 && < 2.2,
build-depends: aeson >= 1.1.1.0 && < 2.3,
aeson-pretty,
attoparsec >= 0.13.0.1,
base >=4.15 && <5.0,
Expand All @@ -109,11 +109,11 @@ library
bytestring >=0.10.6.0 && <0.13,
deepseq >=1.4 && <1.6,
cereal >= 0.5.1 && <0.6,
containers >=0.5 && < 0.7,
containers >=0.5 && < 0.8,
contravariant >=1.4 && <1.6,
filepath,
foldl,
ghc >=9.0 && <9.9,
ghc >=9.0 && <9.11,
hashable,
insert-ordered-containers,
lens,
Expand All @@ -130,7 +130,7 @@ library
split,
system-filepath,
time,
text >= 0.2 && <2.2,
text >= 0.2 && <2.3,
text-short >=0.1.3 && <0.2,
transformers >=0.4 && <0.7,
turtle < 1.6.0 || >= 1.6.1 && < 1.7.0,
Expand Down Expand Up @@ -192,13 +192,13 @@ test-suite tests
Test.Proto.Parse.Option

build-depends:
aeson >= 1.1.1.0 && < 2.2
aeson >= 1.1.1.0 && < 2.4
, attoparsec >= 0.13.0.1
, base >=4.15 && <5.0
, base64-bytestring >= 1.0.0.1 && < 1.3
, bytestring >=0.10.6.0 && <0.13
, cereal >= 0.5.1 && <0.6
, containers >=0.5 && < 0.7
, containers >=0.5 && < 0.8
, deepseq >=1.4 && <1.6
, doctest
, generic-arbitrary
Expand All @@ -216,7 +216,7 @@ test-suite tests
, tasty-hedgehog
, tasty-hunit >= 0.9 && <0.11
, tasty-quickcheck >= 0.8.4 && <0.11
, text >= 0.2 && <2.2
, text >= 0.2 && <2.3
, text-short >=0.1.3 && <0.2
, transformers >=0.4 && <0.7
, turtle
Expand All @@ -242,7 +242,7 @@ executable canonicalize-proto-file
hs-source-dirs: tools/canonicalize-proto-file
default-language: Haskell2010
build-depends: base >=4.15 && <5.0
, containers >=0.5 && <0.7
, containers >=0.5 && <0.8
, mtl >=2.2 && <2.4
, optparse-generic
, proto3-suite
Expand Down
91 changes: 90 additions & 1 deletion src/Proto3/Suite/DotProto/Generate/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import GHC.Types.Name.Occurrence (NameSpace, dataName, mkOccName, tcName, tvName
import GHC.Types.Name.Reader (mkRdrQual, mkRdrUnqual, rdrNameSpace)
import GHC.Types.SrcLoc (GenLocated(..), SrcSpan, generatedSrcSpan)

#if MIN_VERSION_ghc(9,10,0)
import GHC.Types.Basic (GenReason(OtherExpansion))
#endif
#if MIN_VERSION_ghc(9,8,0)
import Control.Arrow ((***))
import Data.Bool (bool)
Expand Down Expand Up @@ -150,6 +153,61 @@ instance SyntaxDefault SrcSpan
where
synDef = generatedSrcSpan

#if MIN_VERSION_ghc(9,10,0)

instance NoAnn a => SyntaxDefault (EpAnn a)
where
synDef = noSrcSpanA

instance SyntaxDefault (EpToken tok)
where
synDef = NoEpTok

instance SyntaxDefault AnnParen
where
synDef = noAnn

instance SyntaxDefault EpAnnHsCase
where
synDef = noAnn

instance SyntaxDefault AnnSig
where
synDef = noAnn

instance SyntaxDefault AnnsIf
where
synDef = noAnn

instance SyntaxDefault (EpUniToken _a _b)
where
synDef = noAnn

instance SyntaxDefault (AnnSortKey BindTag)
where
synDef = mempty

instance SyntaxDefault (Maybe _a, [_b], AnnSortKey _c)
where
synDef = (Nothing, [], mempty)

instance SyntaxDefault (HsMultAnn GhcPs)
where
synDef = HsNoMultAnn NoExtField

instance SyntaxDefault GHC.Hs.AnnPragma
where
synDef = noAnn

instance SyntaxDefault (GHC.Hs.HsBndrVis GHC.Hs.GhcPs)
where
synDef = HsBndrRequired NoExtField

pattern PfxCon :: [arg] -> HsConDetails Void arg r
pattern PfxCon args = PrefixCon [] args

#else

#if MIN_VERSION_ghc(9,8,0)

instance SyntaxDefault (HsBndrVis GhcPs)
Expand Down Expand Up @@ -211,6 +269,8 @@ instance SyntaxDefault e => SyntaxDefault (GenLocated SrcSpan e)
where
synDef = noLocA synDef

#endif

pattern PfxCon :: [arg] -> HsConDetails arg r
pattern PfxCon args = PrefixCon args

Expand Down Expand Up @@ -280,8 +340,11 @@ apply f xs = mkHsApps f (map paren xs)

appAt :: HsExp -> HsType -> HsExp
appAt f t = noLocA (HsAppType synDef f
#if MIN_VERSION_ghc(9,10,0)
#else
#if MIN_VERSION_ghc(9,6,0)
synDef
#endif
#endif
(HsWC NoExtField (parenTy t)))

Expand Down Expand Up @@ -355,7 +418,11 @@ module_ moduleName maybeExports imports decls = GHC.HsModule
#if MIN_VERSION_ghc(9,6,0)
hsmodExt = XModulePs
{ hsmodAnn = synDef
#if MIN_VERSION_ghc(9,10,0)
, hsmodLayout = EpVirtualBraces 2
#else
, hsmodLayout = VirtualBraces 2
#endif
, hsmodDeprecMessage = Nothing
, hsmodHaddockModHeader = Nothing
}
Expand Down Expand Up @@ -415,13 +482,21 @@ importDecl_ moduleName qualified maybeAs details = noLocA ImportDecl
}

ieName_ :: HsName -> HsImportSpec
#if MIN_VERSION_ghc(9,10,0)
ieName_ = noLocA . (\n -> IEVar synDef n Nothing) . noLocA . IEName
#else
ieName_ = noLocA . IEVar synDef . noLocA . IEName
#endif
#if MIN_VERSION_ghc(9,6,0)
synDef
#endif

ieNameAll_ :: HsName -> HsImportSpec
#if MIN_VERSION_ghc(9,10,0)
ieNameAll_ = noLocA . (\n -> IEThingAll synDef n Nothing) . noLocA . IEName
#else
ieNameAll_ = noLocA . IEThingAll synDef . noLocA . IEName
#endif
#if MIN_VERSION_ghc(9,6,0)
synDef
#endif
Expand Down Expand Up @@ -611,6 +686,9 @@ patBind_ pat rhs = noLocA PatBind
#endif
#if !MIN_VERSION_ghc(9,6,0)
, pat_ticks = synDef
#endif
#if MIN_VERSION_ghc(9,10,0)
, pat_mult = synDef
#endif
}

Expand All @@ -627,14 +705,20 @@ functionLike_ strictness name alts = noLocA $ mkFunBind generated name (map matc
where
generated :: Origin
generated = Generated
#if MIN_VERSION_ghc(9,10,0)
OtherExpansion
#endif
#if MIN_VERSION_ghc(9,8,0)
DoPmc
#endif

match :: ([HsPat], HsExp) -> HsMatch
match (pats, rhs) = mkSimpleMatch ctxt pats rhs

#if MIN_VERSION_ghc(9,10,0)
#else
ctxt :: HsMatchContext GhcPs
#endif
ctxt = FunRhs
{ mc_fun = name
, mc_fixity = Prefix
Expand Down Expand Up @@ -834,14 +918,19 @@ case_ e = noLocA . HsCase synDef e . mkMatchGroup generated
where
generated :: Origin
generated = Generated
#if MIN_VERSION_ghc(9,10,0)
OtherExpansion
#endif
#if MIN_VERSION_ghc(9,8,0)
DoPmc
#endif

-- | Simple let expression for ordinary bindings.
let_ :: [HsBind] -> HsExp -> HsExp
let_ locals e =
#if MIN_VERSION_ghc(9,4,0)
#if MIN_VERSION_ghc(9,10,0)
noLocA $ HsLet synDef binds e
#elif MIN_VERSION_ghc(9,4,0)
noLocA $ HsLet synDef synDef binds synDef e
#elif MIN_VERSION_ghc(9,2,0)
noLocA $ HsLet synDef binds e
Expand Down
Loading