Skip to content

Commit af146d9

Browse files
authored
Merge pull request #37 from gelisam/gelisam/ghc-9.0
Support for ghc-9.0
2 parents 0dd9304 + 6501dee commit af146d9

File tree

16 files changed

+107
-30
lines changed

16 files changed

+107
-30
lines changed

.github/workflows/ci.yml renamed to .github/workflows/haskell.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,22 @@ jobs:
6565
strategy:
6666
matrix:
6767
include:
68-
# Check that our upper bounds are correct by building with the latest
69-
# version of everything. We use cabal because it uses the latest
70-
# versions of our dependencies allowed by our upper bounds.
68+
# The purpose of that section is two-fold. First, because we are
69+
# using cabal and not stack, cabal will pick the most recent version
70+
# of our dependencies which has been released. This way, if a
71+
# dependency releases a breaking change, the next monthly CI will
72+
# pick that version and notify us if we are affected by the change.
7173
#
72-
# TODO: switch back to "ghc: latest" once we support ghc-9.0
73-
- name: newest
74-
ghc: "8.10"
74+
# Second, since this project is a ghc plugin, we rely on details of
75+
# the GHC library which change between versions. It is thus quite
76+
# easy to accidentally make a change which works for the latest
77+
# version of GHC but not with older versions. CI should thus test all
78+
# the supported GHC versions.
79+
- name: ghc-8.10
80+
ghc: "8.10.7"
81+
os: ubuntu-latest
82+
- name: ghc-9.0
83+
ghc: "9.0.2"
7584
os: ubuntu-latest
7685

7786
steps:
@@ -118,7 +127,7 @@ jobs:
118127
strategy:
119128
matrix:
120129
include:
121-
- ghc: "8.10"
130+
- ghc: "9.0"
122131
os: ubuntu-latest
123132

124133
steps:

package.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ extra-source-files:
1818
# for release
1919
ghc-options: -W -Wall
2020

21+
tested-with:
22+
- GHC == 9.0.2
23+
- GHC == 8.10.7
24+
2125
dependencies:
2226
- base >= 4.12 && < 5
2327
- ghc-prim >= 0.5.3
2428

2529
library:
2630
source-dirs: src
2731
dependencies:
28-
- ghc >= 8.10.2 && < 9.0
32+
- ghc >= 8.10.2 && <9.1
2933
- containers >= 0.6.2.1
3034
- term-rewriting >= 0.3.0.1
3135
- transformers >= 0.5.6.2

src/TypeLevel/Rewrite.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE LambdaCase, OverloadedStrings, RecordWildCards, ViewPatterns #-}
1+
{-# LANGUAGE CPP, LambdaCase, OverloadedStrings, RecordWildCards, ViewPatterns #-}
22
module TypeLevel.Rewrite (plugin) where
33

44
import Control.Monad
@@ -8,6 +8,17 @@ import Data.Foldable
88
import Data.Traversable
99

1010
-- GHC API
11+
#if MIN_VERSION_ghc(9,0,0)
12+
import GHC.Core.Coercion (Role(Representational), mkUnivCo)
13+
import GHC.Tc.Types.Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical)
14+
import GHC.Plugins (PredType, SDoc, eqType, fsep, ppr)
15+
import GHC.Plugins (Plugin(pluginRecompile, tcPlugin), CommandLineOption, defaultPlugin, purePlugin)
16+
import GHC.Tc.Types.Evidence (EvExpr, EvTerm, evCast)
17+
import GHC.Tc.Plugin (newWanted)
18+
import GHC.Core.TyCo.Rep (UnivCoProvenance(PluginProv))
19+
import GHC.Plugins (synTyConDefn_maybe)
20+
import GHC.Tc.Types (TcPluginResult(..), TcPluginM, ErrCtxt, pushErrCtxtSameOrigin, TcPlugin(..))
21+
#else
1122
import Coercion (Role(Representational), mkUnivCo)
1223
import Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical)
1324
import GhcPlugins (PredType, SDoc, eqType, fsep, ppr)
@@ -17,6 +28,7 @@ import TcPluginM (newWanted)
1728
import TcRnTypes
1829
import TyCoRep (UnivCoProvenance(PluginProv))
1930
import TyCon (synTyConDefn_maybe)
31+
#endif
2032

2133
import TypeLevel.Rewrite.Internal.ApplyRules
2234
import TypeLevel.Rewrite.Internal.DecomposedConstraint

src/TypeLevel/Rewrite/Internal/ApplyRules.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE LambdaCase, TupleSections, ViewPatterns #-}
1+
{-# LANGUAGE CPP, LambdaCase, TupleSections, ViewPatterns #-}
22
{-# OPTIONS -Wno-name-shadowing #-}
33
module TypeLevel.Rewrite.Internal.ApplyRules where
44

@@ -13,7 +13,11 @@ import Data.Traversable
1313
import qualified Data.Map as Map
1414

1515
-- GHC API
16+
#if MIN_VERSION_ghc(9,0,0)
17+
import GHC.Plugins (TyVar)
18+
#else
1619
import Type (TyVar)
20+
#endif
1721

1822
-- term-rewriting API
1923
import Data.Rewriting.Rule (Rule(..))

src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, LambdaCase, RecordWildCards, ViewPatterns #-}
1+
{-# LANGUAGE CPP, DeriveFunctor, DeriveFoldable, DeriveTraversable, LambdaCase, RecordWildCards, ViewPatterns #-}
22
module TypeLevel.Rewrite.Internal.DecomposedConstraint where
33

44
import Control.Applicative
55

66
-- GHC API
77
import GHC (Class, Type)
8+
#if MIN_VERSION_ghc(9,0,0)
9+
import GHC.Tc.Types.Constraint (Ct, ctEvPred, ctEvidence)
10+
import GHC.Core.Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred)
11+
#else
812
import Constraint (Ct, ctEvPred, ctEvidence)
913
import Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred)
14+
#endif
1015

1116

1217
data DecomposedConstraint a

src/TypeLevel/Rewrite/Internal/Lookup.hs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
{-# LANGUAGE LambdaCase, ViewPatterns #-}
1+
{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-}
22
module TypeLevel.Rewrite.Internal.Lookup where
33

44
import Control.Arrow ((***), first)
55
import Data.Tuple (swap)
66

77
-- GHC API
8-
import Finder (cannotFindModule)
98
import GHC (DataCon, TyCon, dataConTyCon)
9+
#if MIN_VERSION_ghc(9,0,0)
10+
import GHC.Driver.Finder (cannotFindModule)
11+
import GHC (Module, ModuleName, mkModuleName)
12+
import GHC.Plugins (mkDataOcc, mkTcOcc)
13+
import GHC.Utils.Panic (panicDoc)
14+
import GHC.Tc.Plugin
15+
( FindResult(Found), TcPluginM, findImportedModule, lookupOrig, tcLookupDataCon, tcLookupTyCon
16+
, unsafeTcPluginTcM
17+
)
18+
import GHC.Tc.Solver.Monad (getDynFlags)
19+
#else
20+
import Finder (cannotFindModule)
1021
import Module (Module, ModuleName, mkModuleName)
1122
import OccName (mkDataOcc, mkTcOcc)
1223
import Panic (panicDoc)
1324
import TcPluginM
14-
( FindResult(Found), TcPluginM, findImportedModule, lookupOrig, tcLookupDataCon, tcLookupTyCon
15-
, unsafeTcPluginTcM
16-
)
1725
import TcSMonad (getDynFlags)
18-
26+
#endif
1927

2028
lookupModule
2129
:: String -- ^ module name

src/TypeLevel/Rewrite/Internal/PrettyPrint.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
{-# LANGUAGE LambdaCase, RecordWildCards #-}
1+
{-# LANGUAGE CPP, LambdaCase, RecordWildCards #-}
22
module TypeLevel.Rewrite.Internal.PrettyPrint where
33

44
import Data.List (intercalate)
55

66
-- GHC API
7+
#if MIN_VERSION_ghc(9,0,0)
8+
import GHC.Utils.Outputable (ppr, showSDocUnsafe)
9+
import GHC.Plugins (TyCon)
10+
import GHC.Plugins (TyVar, Type)
11+
#else
712
import Outputable (ppr, showSDocUnsafe)
813
import TyCon (TyCon)
914
import Type (TyVar, Type)
15+
#endif
1016

1117
-- term-rewriting API
1218
import Data.Rewriting.Rule (Rule(..))

src/TypeLevel/Rewrite/Internal/TypeEq.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
{-# LANGUAGE CPP #-}
12
module TypeLevel.Rewrite.Internal.TypeEq where
23

34
import Data.Function
45

6+
#if MIN_VERSION_ghc(9,0,0)
7+
import GHC.Plugins (Type, eqType)
8+
#else
59
import GhcPlugins (Type, eqType)
10+
#endif
611

712

813
-- | A newtype around 'Type' which has an 'Eq' instance.

src/TypeLevel/Rewrite/Internal/TypeNode.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
{-# LANGUAGE ViewPatterns #-}
1+
{-# LANGUAGE CPP, ViewPatterns #-}
22
module TypeLevel.Rewrite.Internal.TypeNode where
33

44
-- GHC API
5+
#if MIN_VERSION_ghc(9,0,0)
6+
import GHC (TyCon)
7+
import GHC.Plugins (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe)
8+
#else
59
import TyCon (TyCon)
610
import Type (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe)
11+
#endif
712

813
import TypeLevel.Rewrite.Internal.TypeEq
914

src/TypeLevel/Rewrite/Internal/TypeRule.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
{-# LANGUAGE LambdaCase, ViewPatterns #-}
1+
{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-}
22
{-# OPTIONS -Wno-name-shadowing #-}
33
module TypeLevel.Rewrite.Internal.TypeRule where
44

55
-- GHC API
6+
#if MIN_VERSION_ghc(9,0,0)
7+
import GHC.Plugins (getOccString)
8+
import GHC.Core.Predicate (mkPrimEqPred)
9+
import GHC.Plugins (TyVar, Type, mkTyVarTy)
10+
#else
611
import Name (getOccString)
712
import Predicate (mkPrimEqPred)
813
import Type (TyVar, Type, mkTyVarTy)
14+
#endif
915

1016
-- term-rewriting API
1117
import Data.Rewriting.Rule (Rule(..))

0 commit comments

Comments
 (0)