Skip to content

Commit 34e925c

Browse files
authored
Merge pull request #148 from guibou/ghc_914
GHC 9.14 support
2 parents cf03e5f + cb95501 commit 34e925c

8 files changed

Lines changed: 66 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: cachix/install-nix-action@v21
13-
- uses: cachix/cachix-action@v12
12+
- uses: cachix/install-nix-action@v31
13+
- uses: cachix/cachix-action@v15
1414
with:
1515
name: guibou
1616
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

.github/workflows/master.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
nix_matrix:
99
strategy:
1010
matrix:
11-
ghc: [90, 92, 94, 96, 98, 910, 912]
11+
ghc: [94, 96, 98, 910, 912, 914]
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15-
- uses: cachix/install-nix-action@v21
16-
- uses: cachix/cachix-action@v12
15+
- uses: cachix/install-nix-action@v31
16+
- uses: cachix/cachix-action@v15
1717
with:
1818
name: guibou
1919
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
@@ -23,7 +23,8 @@ jobs:
2323
stack_build:
2424
strategy:
2525
matrix:
26-
resolver: [lts-14.27, # 8.6
26+
resolver: [
27+
lts-14.27, # 8.6
2728
lts-16.31, # 8.8
2829
lts-17.1, # 8.10
2930
lts-19.1, # 9.0

PyF.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ library
3131
PyF.Internal.QQ
3232

3333
build-depends:
34-
, base >=4.12 && <4.22
34+
, base >=4.12 && <4.23
3535
, bytestring >=0.10.8 && <0.13
3636
, ghc >=8.6.1
3737
, mtl >=2.2.2 && <2.4
3838
, parsec >=3.1.13 && <3.2
39-
, template-haskell >=2.14.0 && <2.24
39+
, template-haskell >=2.14.0 && <2.25
4040
, text >=1.2.3 && <2.2
41-
, time >=1.8.0 && <1.15
41+
, time >=1.8.0 && <1.16
4242

4343
if impl(ghc <9.2.1)
4444
build-depends: ghc-boot >=8.6.1 && <9.7

flake.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description = "PyF";
33

44
inputs.flake-utils.url = "github:numtide/flake-utils";
5-
inputs.nixpkgs.url = "github:nixos/nixpkgs/haskell-updates";
5+
inputs.nixpkgs.url = "github:guibou/nixpkgs/ghc-914";
66
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
77

88
nixConfig.extra-substituters = [ "https://guibou.cachix.org" ];
@@ -53,9 +53,6 @@
5353
rec {
5454
checks = {
5555
inherit (packages)
56-
pyf_810
57-
pyf_90
58-
pyf_92
5956
pyf_94
6057
pyf_96
6158
pyf_98
@@ -68,17 +65,15 @@
6865

6966
packages = {
7067
# GHC 8.6 is tested with stack, I'm stopping the testing with nix.
71-
# GHC 8.8 is not in nixpkgs anymore.
68+
# GHC 8.6..9.2 are not in nixpkgs anymore.
7269

73-
pyf_810 = pyfBuilder haskell.packages.ghc810;
74-
pyf_90 = pyfBuilder haskell.packages.ghc90;
75-
pyf_92 = pyfBuilder haskell.packages.ghc92;
7670
pyf_94 = pyfBuilder haskell.packages.ghc94;
7771
pyf_96 = pyfBuilder haskell.packages.ghc96;
7872
pyf_98 = pkgs.haskell.lib.dontCheck (pyfBuilder haskell.packages.ghc98);
7973

8074
pyf_910 = pyfBuilder haskell.packages.ghc910;
8175
pyf_912 = pyfBuilder haskell.packages.ghc912;
76+
pyf_914 = pyfBuilder haskell.packages.ghc914;
8277

8378
default = pyfBuilder haskellPackages;
8479
};

src/PyF/Internal/Meta.hs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
module PyF.Internal.Meta (toExp, baseDynFlags, toName) where
88

9+
import qualified Data.List.NonEmpty as NE
10+
911
#if MIN_VERSION_ghc(9,2,0)
1012
import GHC.Hs.Type (HsWildCardBndrs (..), HsType (..), HsSigType(HsSig), sig_body)
1113
#elif MIN_VERSION_ghc(9,0,0)
@@ -95,8 +97,13 @@ toLit (HsIntPrim _ i) = TH.IntPrimL i
9597
toLit (HsWordPrim _ i) = TH.WordPrimL i
9698
toLit (HsInt64Prim _ i) = TH.IntegerL i
9799
toLit (HsWord64Prim _ i) = TH.WordPrimL i
98-
toLit (HsInteger _ i _) = TH.IntegerL i
100+
#if MIN_VERSION_ghc(9,13,0)
101+
-- toLit (HsRat _ f _) = TH.FloatPrimL (fl_value f)
102+
-- toLit (HsInteger _ i _) = TH.IntegerL i
103+
#else
99104
toLit (HsRat _ f _) = TH.FloatPrimL (fl_value f)
105+
toLit (HsInteger _ i _) = TH.IntegerL i
106+
#endif
100107
toLit (HsFloatPrim _ f) = TH.FloatPrimL (fl_value f)
101108
toLit (HsDoublePrim _ f) = TH.DoublePrimL (fl_value f)
102109
#if MIN_VERSION_ghc(9,7,0)
@@ -150,13 +157,16 @@ toExp _ (Expr.HsVar _ n) =
150157
in if isRdrDataCon n'
151158
then TH.ConE (toName n')
152159
else TH.VarE (toName n')
153-
#if MIN_VERSION_ghc(9,6,0)
160+
#if MIN_VERSION_ghc(9, 13, 0)
161+
162+
#elif MIN_VERSION_ghc(9,6,0)
154163
toExp _ (Expr.HsUnboundVar _ n) = TH.UnboundVarE (TH.mkName . occNameString . rdrNameOcc $ n)
155164
#elif MIN_VERSION_ghc(9,0,0)
156165
toExp _ (Expr.HsUnboundVar _ n) = TH.UnboundVarE (TH.mkName . occNameString $ n)
157166
#else
158167
toExp _ (Expr.HsUnboundVar _ n) = TH.UnboundVarE (TH.mkName . occNameString . Expr.unboundVarOcc $ n)
159168
#endif
169+
160170
toExp _ Expr.HsIPVar {} = noTH "toExp" "HsIPVar"
161171
toExp _ (Expr.HsLit _ l) = TH.LitE (toLit l)
162172
toExp _ (Expr.HsOverLit _ OverLit {ol_val}) = TH.LitE (toLit' ol_val)
@@ -179,8 +189,10 @@ toExp d (Expr.ExprWithTySig HsWC{hswc_body=HsIB{hsib_body}} e) = TH.SigE (toExp
179189
#endif
180190
toExp d (Expr.OpApp _ e1 o e2) = TH.UInfixE (toExp d . unLoc $ e1) (toExp d . unLoc $ o) (toExp d . unLoc $ e2)
181191
toExp d (Expr.NegApp _ e _) = TH.AppE (TH.VarE 'negate) (toExp d . unLoc $ e)
192+
#if MIN_VERSION_ghc(9,13,0)
193+
toExp d (Expr.HsLam _ _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (Expr.GRHSs _ (NE.toList -> [unLoc -> Expr.GRHS _ _ (unLoc -> e)]) _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e)
194+
#elif MIN_VERSION_ghc(9,12,0)
182195
-- NOTE: for lambda, there is only one match
183-
#if MIN_VERSION_ghc(9,12,0)
184196
toExp d (Expr.HsLam _ _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (Expr.GRHSs _ [unLoc -> Expr.GRHS _ _ (unLoc -> e)] _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e)
185197
#elif MIN_VERSION_ghc(9,10,0)
186198
toExp d (Expr.HsLam _ _ (Expr.MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (map unLoc -> ps) (Expr.GRHSs _ [unLoc -> Expr.GRHS _ _ (unLoc -> e)] _)])))) = TH.LamE (fmap (toPat d) ps) (toExp d e)

src/PyF/Internal/ParserEx.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,28 @@ import OccName
9696
import GHC.Driver.Config.Parser (initParserOpts)
9797
#endif
9898

99+
#if MIN_VERSION_ghc(9,13,0)
100+
import GHC.Unit.Types (UnitId(..))
101+
#endif
102+
99103
import Data.Maybe
100104

101105
fakeSettings :: Settings
102106
fakeSettings = Settings
103-
#if MIN_VERSION_ghc(9, 2, 0)
107+
#if MIN_VERSION_ghc(9, 13, 0)
104108
{ sGhcNameVersion=ghcNameVersion
105109
, sFileSettings=fileSettings
106110
, sTargetPlatform=platform
111+
, sToolSettings=toolSettings
107112
, sPlatformMisc=platformMisc
113+
, sUnitSettings = UnitSettings (UnitId $ fsLit "pyf-preprocessor")
114+
}
115+
#elif MIN_VERSION_ghc(9, 2, 0)
116+
{ sGhcNameVersion=ghcNameVersion
117+
, sFileSettings=fileSettings
118+
, sTargetPlatform=platform
108119
, sToolSettings=toolSettings
120+
, sPlatformMisc=platformMisc
109121
}
110122
#elif MIN_VERSION_ghc(8, 10, 0)
111123
{ sGhcNameVersion=ghcNameVersion

src/PyF/Internal/QQ.hs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module PyF.Internal.QQ
2727
)
2828
where
2929

30+
import qualified Data.List.NonEmpty as NE
31+
3032
import Control.Monad.Reader
3133
import Data.Data (Data (gmapQ), Typeable, cast)
3234
import Data.Kind
@@ -196,7 +198,13 @@ findFreeVariables item = allNames
196198
Just (HsVar _ l) -> [l]
197199
#endif
198200

199-
#if MIN_VERSION_ghc(9,12,0)
201+
#if MIN_VERSION_ghc(9,13,0)
202+
Just (HsLam _ _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (GRHSs _ (NE.toList -> [unLoc -> GRHS _ _ (unLoc -> e)]) _)])))) -> filter keepVar subVars
203+
where
204+
keepVar (L _ n) = n `notElem` subPats
205+
subVars = concat $ gmapQ f [e]
206+
subPats = concat $ gmapQ findPats ps
207+
#elif MIN_VERSION_ghc(9,12,0)
200208
Just (HsLam _ _ (MG _ (unLoc -> (map unLoc -> [Expr.Match _ _ (unLoc -> map unLoc -> ps) (GRHSs _ [unLoc -> GRHS _ _ (unLoc -> e)] _)])))) -> filter keepVar subVars
201209
where
202210
keepVar (L _ n) = n `notElem` subPats
@@ -273,7 +281,10 @@ unsafeRunTcM m = Q (unsafeCoerce m)
273281
reportErrorAt :: SrcSpan -> String -> Q ()
274282
reportErrorAt loc msg = unsafeRunTcM $ addErrAt loc msg'
275283
where
276-
#if MIN_VERSION_ghc(9,7,0)
284+
#if MIN_VERSION_ghc(9,13,0)
285+
-- TODO: maybe leverage the "hint" logic to add additionnal hints here?
286+
msg' = TcRnUnknownMessage (UnknownDiagnostic (const NoDiagnosticOpts) (\x -> x) (mkPlainError noHints (text msg)))
287+
#elif MIN_VERSION_ghc(9,7,0)
277288
msg' = TcRnUnknownMessage (UnknownDiagnostic (const NoDiagnosticOpts) (mkPlainError noHints (text msg)))
278289
#elif MIN_VERSION_ghc(9,6,0)
279290
msg' = TcRnUnknownMessage (UnknownDiagnostic $ mkPlainError noHints $

0 commit comments

Comments
 (0)