From cf81c96be84307737a9debd70dcdb263eea55b13 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Thu, 22 Jul 2021 16:07:25 +0900 Subject: [PATCH 01/14] Update GHC-api's paths --- src/TypeLevel/Rewrite.hs | 18 +++++++++--------- src/TypeLevel/Rewrite/Internal/ApplyRules.hs | 2 +- .../Rewrite/Internal/DecomposedConstraint.hs | 4 ++-- src/TypeLevel/Rewrite/Internal/Lookup.hs | 12 ++++++------ src/TypeLevel/Rewrite/Internal/PrettyPrint.hs | 6 +++--- src/TypeLevel/Rewrite/Internal/TypeEq.hs | 2 +- src/TypeLevel/Rewrite/Internal/TypeNode.hs | 4 ++-- src/TypeLevel/Rewrite/Internal/TypeRule.hs | 6 +++--- src/TypeLevel/Rewrite/Internal/TypeTemplate.hs | 2 +- src/TypeLevel/Rewrite/Internal/TypeTerm.hs | 2 +- typelevel-rewrite-rules.cabal | 2 +- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/TypeLevel/Rewrite.hs b/src/TypeLevel/Rewrite.hs index 0738291..88875b2 100644 --- a/src/TypeLevel/Rewrite.hs +++ b/src/TypeLevel/Rewrite.hs @@ -8,15 +8,15 @@ import Data.Foldable import Data.Traversable -- GHC API -import Coercion (Role(Representational), mkUnivCo) -import Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical) -import GhcPlugins (PredType, SDoc, eqType, fsep, ppr) -import Plugins (Plugin(pluginRecompile, tcPlugin), CommandLineOption, defaultPlugin, purePlugin) -import TcEvidence (EvExpr, EvTerm, evCast) -import TcPluginM (newWanted) -import TcRnTypes -import TyCoRep (UnivCoProvenance(PluginProv)) -import TyCon (synTyConDefn_maybe) +import GHC.Core.Coercion (Role(Representational), mkUnivCo) +import GHC.Tc.Types.Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical) +import GHC.Plugins (PredType, SDoc, eqType, fsep, ppr) +import GHC.Plugins (Plugin(pluginRecompile, tcPlugin), CommandLineOption, defaultPlugin, purePlugin) +import GHC.Tc.Types.Evidence (EvExpr, EvTerm, evCast) +import GHC.Tc.Plugin (newWanted) +import GHC.Core.TyCo.Rep (UnivCoProvenance(PluginProv)) +import GHC.Plugins (synTyConDefn_maybe) +import GHC.Tc.Types (TcPluginResult(..), TcPluginM, ErrCtxt, pushErrCtxtSameOrigin, TcPlugin(..)) import TypeLevel.Rewrite.Internal.ApplyRules import TypeLevel.Rewrite.Internal.DecomposedConstraint diff --git a/src/TypeLevel/Rewrite/Internal/ApplyRules.hs b/src/TypeLevel/Rewrite/Internal/ApplyRules.hs index 3587918..8c40150 100644 --- a/src/TypeLevel/Rewrite/Internal/ApplyRules.hs +++ b/src/TypeLevel/Rewrite/Internal/ApplyRules.hs @@ -13,7 +13,7 @@ import Data.Traversable import qualified Data.Map as Map -- GHC API -import Type (TyVar) +import GHC.Plugins (TyVar) -- term-rewriting API import Data.Rewriting.Rule (Rule(..)) diff --git a/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs b/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs index 87d47af..1b9c66e 100644 --- a/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs +++ b/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs @@ -5,8 +5,8 @@ import Control.Applicative -- GHC API import GHC (Class, Type) -import Constraint (Ct, ctEvPred, ctEvidence) -import Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred) +import GHC.Tc.Types.Constraint (Ct, ctEvPred, ctEvidence) +import GHC.Core.Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred) data DecomposedConstraint a diff --git a/src/TypeLevel/Rewrite/Internal/Lookup.hs b/src/TypeLevel/Rewrite/Internal/Lookup.hs index dbb8323..758efbf 100644 --- a/src/TypeLevel/Rewrite/Internal/Lookup.hs +++ b/src/TypeLevel/Rewrite/Internal/Lookup.hs @@ -5,16 +5,16 @@ import Control.Arrow ((***), first) import Data.Tuple (swap) -- GHC API -import Finder (cannotFindModule) +import GHC.Driver.Finder (cannotFindModule) import GHC (DataCon, TyCon, dataConTyCon) -import Module (Module, ModuleName, mkModuleName) -import OccName (mkDataOcc, mkTcOcc) -import Panic (panicDoc) -import TcPluginM +import GHC (Module, ModuleName, mkModuleName) +import GHC.Plugins (mkDataOcc, mkTcOcc) +import GHC.Utils.Panic (panicDoc) +import GHC.Tc.Plugin ( FindResult(Found), TcPluginM, findImportedModule, lookupOrig, tcLookupDataCon, tcLookupTyCon , unsafeTcPluginTcM ) -import TcSMonad (getDynFlags) +import GHC.Tc.Solver.Monad (getDynFlags) lookupModule diff --git a/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs b/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs index afc19ed..787e025 100644 --- a/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs +++ b/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs @@ -4,9 +4,9 @@ module TypeLevel.Rewrite.Internal.PrettyPrint where import Data.List (intercalate) -- GHC API -import Outputable (ppr, showSDocUnsafe) -import TyCon (TyCon) -import Type (TyVar, Type) +import GHC.Utils.Outputable (ppr, showSDocUnsafe) +import GHC.Plugins (TyCon) +import GHC.Plugins (TyVar, Type) -- term-rewriting API import Data.Rewriting.Rule (Rule(..)) diff --git a/src/TypeLevel/Rewrite/Internal/TypeEq.hs b/src/TypeLevel/Rewrite/Internal/TypeEq.hs index 30272a6..2af9472 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeEq.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeEq.hs @@ -2,7 +2,7 @@ module TypeLevel.Rewrite.Internal.TypeEq where import Data.Function -import GhcPlugins (Type, eqType) +import GHC.Plugins (Type, eqType) -- | A newtype around 'Type' which has an 'Eq' instance. diff --git a/src/TypeLevel/Rewrite/Internal/TypeNode.hs b/src/TypeLevel/Rewrite/Internal/TypeNode.hs index 97e14ae..53c1c60 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeNode.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeNode.hs @@ -2,8 +2,8 @@ module TypeLevel.Rewrite.Internal.TypeNode where -- GHC API -import TyCon (TyCon) -import Type (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe) +import GHC (TyCon) +import GHC.Plugins (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe) import TypeLevel.Rewrite.Internal.TypeEq diff --git a/src/TypeLevel/Rewrite/Internal/TypeRule.hs b/src/TypeLevel/Rewrite/Internal/TypeRule.hs index c44b46d..7021d42 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeRule.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeRule.hs @@ -3,9 +3,9 @@ module TypeLevel.Rewrite.Internal.TypeRule where -- GHC API -import Name (getOccString) -import Predicate (mkPrimEqPred) -import Type (TyVar, Type, mkTyVarTy) +import GHC.Plugins (getOccString) +import GHC.Core.Predicate (mkPrimEqPred) +import GHC.Plugins (TyVar, Type, mkTyVarTy) -- term-rewriting API import Data.Rewriting.Rule (Rule(..)) diff --git a/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs b/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs index bd870f2..831f8bb 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs @@ -2,7 +2,7 @@ module TypeLevel.Rewrite.Internal.TypeTemplate where -- GHC API -import Type (TyVar, Type, getTyVar_maybe) +import GHC.Plugins (TyVar, Type, getTyVar_maybe) -- term-rewriting API import Data.Rewriting.Term (Term(Fun, Var)) diff --git a/src/TypeLevel/Rewrite/Internal/TypeTerm.hs b/src/TypeLevel/Rewrite/Internal/TypeTerm.hs index 28ef65a..68309bc 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeTerm.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeTerm.hs @@ -2,7 +2,7 @@ module TypeLevel.Rewrite.Internal.TypeTerm where -- GHC API -import Type (Type, mkTyConApp) +import GHC.Plugins (Type, mkTyConApp) -- term-rewriting API import Data.Rewriting.Term (Term(Fun, Var)) diff --git a/typelevel-rewrite-rules.cabal b/typelevel-rewrite-rules.cabal index c33115e..df8a73d 100644 --- a/typelevel-rewrite-rules.cabal +++ b/typelevel-rewrite-rules.cabal @@ -48,7 +48,7 @@ library build-depends: base >=4.12 && <5 , containers >=0.6.2.1 - , ghc >=8.10.2 && <9.0 + , ghc >=8.10.2 && <= 9.1 , ghc-prim >=0.5.3 , term-rewriting >=0.3.0.1 , transformers >=0.5.6.2 From 26f8fd156f1d4f5bf22c0ef03ad904e01be98b55 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Thu, 22 Jul 2021 16:12:30 +0900 Subject: [PATCH 02/14] Add AllowAmbiguousTypes for test --- test/should-compile/GHC/TypeLits/Test.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/should-compile/GHC/TypeLits/Test.hs b/test/should-compile/GHC/TypeLits/Test.hs index a228cce..da3aa55 100644 --- a/test/should-compile/GHC/TypeLits/Test.hs +++ b/test/should-compile/GHC/TypeLits/Test.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DataKinds, RankNTypes, TypeFamilies, TypeOperators #-} +{-# LANGUAGE DataKinds, RankNTypes, TypeFamilies, TypeOperators, AllowAmbiguousTypes #-} {-# OPTIONS_GHC -fplugin TypeLevel.Rewrite -fplugin-opt=TypeLevel.Rewrite:GHC.TypeLits.RewriteRules.NatRule -fplugin-opt=TypeLevel.Rewrite:GHC.TypeLits.RewriteRules.SymbolRule #-} From f3282bd37b30fd32b85ab4a2f6bc7d89b666a006 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Fri, 23 Jul 2021 02:33:50 +0900 Subject: [PATCH 03/14] Add CPP to support both ghc-8.10 and ghc-9 --- package.yaml | 3 ++- src/TypeLevel/Rewrite.hs | 12 ++++++++++++ src/TypeLevel/Rewrite/Internal/ApplyRules.hs | 4 ++++ .../Rewrite/Internal/DecomposedConstraint.hs | 5 +++++ src/TypeLevel/Rewrite/Internal/Lookup.hs | 12 ++++++++++-- src/TypeLevel/Rewrite/Internal/PrettyPrint.hs | 6 ++++++ src/TypeLevel/Rewrite/Internal/TypeEq.hs | 4 ++++ src/TypeLevel/Rewrite/Internal/TypeNode.hs | 5 +++++ src/TypeLevel/Rewrite/Internal/TypeRule.hs | 6 ++++++ src/TypeLevel/Rewrite/Internal/TypeTemplate.hs | 4 ++++ src/TypeLevel/Rewrite/Internal/TypeTerm.hs | 4 ++++ typelevel-rewrite-rules.cabal | 1 + 12 files changed, 63 insertions(+), 3 deletions(-) diff --git a/package.yaml b/package.yaml index 9f05ea6..8a36653 100644 --- a/package.yaml +++ b/package.yaml @@ -25,10 +25,11 @@ dependencies: library: source-dirs: src dependencies: - - ghc >= 8.10.2 && < 9.0 + - ghc >= 8.10.2 && <= 9.1 - containers >= 0.6.2.1 - term-rewriting >= 0.3.0.1 - transformers >= 0.5.6.2 + default-extensions: CPP tests: should-compile: diff --git a/src/TypeLevel/Rewrite.hs b/src/TypeLevel/Rewrite.hs index 88875b2..5d1ef6a 100644 --- a/src/TypeLevel/Rewrite.hs +++ b/src/TypeLevel/Rewrite.hs @@ -8,6 +8,7 @@ import Data.Foldable import Data.Traversable -- GHC API +#if MIN_VERSION_ghc(9,0,0) import GHC.Core.Coercion (Role(Representational), mkUnivCo) import GHC.Tc.Types.Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical) import GHC.Plugins (PredType, SDoc, eqType, fsep, ppr) @@ -17,6 +18,17 @@ import GHC.Tc.Plugin (newWanted) import GHC.Core.TyCo.Rep (UnivCoProvenance(PluginProv)) import GHC.Plugins (synTyConDefn_maybe) import GHC.Tc.Types (TcPluginResult(..), TcPluginM, ErrCtxt, pushErrCtxtSameOrigin, TcPlugin(..)) +#else +import Coercion (Role(Representational), mkUnivCo) +import Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical) +import GhcPlugins (PredType, SDoc, eqType, fsep, ppr) +import Plugins (Plugin(pluginRecompile, tcPlugin), CommandLineOption, defaultPlugin, purePlugin) +import TcEvidence (EvExpr, EvTerm, evCast) +import TcPluginM (newWanted) +import TcRnTypes +import TyCoRep (UnivCoProvenance(PluginProv)) +import TyCon (synTyConDefn_maybe) +#endif import TypeLevel.Rewrite.Internal.ApplyRules import TypeLevel.Rewrite.Internal.DecomposedConstraint diff --git a/src/TypeLevel/Rewrite/Internal/ApplyRules.hs b/src/TypeLevel/Rewrite/Internal/ApplyRules.hs index 8c40150..1fbbfca 100644 --- a/src/TypeLevel/Rewrite/Internal/ApplyRules.hs +++ b/src/TypeLevel/Rewrite/Internal/ApplyRules.hs @@ -13,7 +13,11 @@ import Data.Traversable import qualified Data.Map as Map -- GHC API +#if MIN_VERSION_ghc(9,0,0) import GHC.Plugins (TyVar) +#else +import Type (TyVar) +#endif -- term-rewriting API import Data.Rewriting.Rule (Rule(..)) diff --git a/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs b/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs index 1b9c66e..8226dbb 100644 --- a/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs +++ b/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs @@ -5,8 +5,13 @@ import Control.Applicative -- GHC API import GHC (Class, Type) +#if MIN_VERSION_ghc(9,0,0) import GHC.Tc.Types.Constraint (Ct, ctEvPred, ctEvidence) import GHC.Core.Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred) +#else +import Constraint (Ct, ctEvPred, ctEvidence) +import Predicate (EqRel(NomEq), Pred(ClassPred, EqPred), classifyPredType, mkClassPred, mkPrimEqPred) +#endif data DecomposedConstraint a diff --git a/src/TypeLevel/Rewrite/Internal/Lookup.hs b/src/TypeLevel/Rewrite/Internal/Lookup.hs index 758efbf..62a1d32 100644 --- a/src/TypeLevel/Rewrite/Internal/Lookup.hs +++ b/src/TypeLevel/Rewrite/Internal/Lookup.hs @@ -5,8 +5,9 @@ import Control.Arrow ((***), first) import Data.Tuple (swap) -- GHC API -import GHC.Driver.Finder (cannotFindModule) import GHC (DataCon, TyCon, dataConTyCon) +#if MIN_VERSION_ghc(9,0,0) +import GHC.Driver.Finder (cannotFindModule) import GHC (Module, ModuleName, mkModuleName) import GHC.Plugins (mkDataOcc, mkTcOcc) import GHC.Utils.Panic (panicDoc) @@ -15,7 +16,14 @@ import GHC.Tc.Plugin , unsafeTcPluginTcM ) import GHC.Tc.Solver.Monad (getDynFlags) - +#else +import Finder (cannotFindModule) +import Module (Module, ModuleName, mkModuleName) +import OccName (mkDataOcc, mkTcOcc) +import Panic (panicDoc) +import TcPluginM +import TcSMonad (getDynFlags) +#endif lookupModule :: String -- ^ module name diff --git a/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs b/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs index 787e025..4af808e 100644 --- a/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs +++ b/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs @@ -4,9 +4,15 @@ module TypeLevel.Rewrite.Internal.PrettyPrint where import Data.List (intercalate) -- GHC API +#if MIN_VERSION_ghc(9,0,0) import GHC.Utils.Outputable (ppr, showSDocUnsafe) import GHC.Plugins (TyCon) import GHC.Plugins (TyVar, Type) +#else +import Outputable (ppr, showSDocUnsafe) +import TyCon (TyCon) +import Type (TyVar, Type) +#endif -- term-rewriting API import Data.Rewriting.Rule (Rule(..)) diff --git a/src/TypeLevel/Rewrite/Internal/TypeEq.hs b/src/TypeLevel/Rewrite/Internal/TypeEq.hs index 2af9472..53d2df5 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeEq.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeEq.hs @@ -2,7 +2,11 @@ module TypeLevel.Rewrite.Internal.TypeEq where import Data.Function +#if MIN_VERSION_ghc(9,0,0) import GHC.Plugins (Type, eqType) +#else +import GhcPlugins (Type, eqType) +#endif -- | A newtype around 'Type' which has an 'Eq' instance. diff --git a/src/TypeLevel/Rewrite/Internal/TypeNode.hs b/src/TypeLevel/Rewrite/Internal/TypeNode.hs index 53c1c60..31f32e6 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeNode.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeNode.hs @@ -2,8 +2,13 @@ module TypeLevel.Rewrite.Internal.TypeNode where -- GHC API +#if MIN_VERSION_ghc(9,0,0) import GHC (TyCon) import GHC.Plugins (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe) +#else +import TyCon (TyCon) +import Type (Type, isNumLitTy, isStrLitTy, mkTyConApp, splitTyConApp_maybe) +#endif import TypeLevel.Rewrite.Internal.TypeEq diff --git a/src/TypeLevel/Rewrite/Internal/TypeRule.hs b/src/TypeLevel/Rewrite/Internal/TypeRule.hs index 7021d42..9aeb5dd 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeRule.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeRule.hs @@ -3,9 +3,15 @@ module TypeLevel.Rewrite.Internal.TypeRule where -- GHC API +#if MIN_VERSION_ghc(9,0,0) import GHC.Plugins (getOccString) import GHC.Core.Predicate (mkPrimEqPred) import GHC.Plugins (TyVar, Type, mkTyVarTy) +#else +import Name (getOccString) +import Predicate (mkPrimEqPred) +import Type (TyVar, Type, mkTyVarTy) +#endif -- term-rewriting API import Data.Rewriting.Rule (Rule(..)) diff --git a/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs b/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs index 831f8bb..12dbe38 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs @@ -2,7 +2,11 @@ module TypeLevel.Rewrite.Internal.TypeTemplate where -- GHC API +#if MIN_VERSION_ghc(9,0,0) import GHC.Plugins (TyVar, Type, getTyVar_maybe) +#else +import Type (TyVar, Type, getTyVar_maybe) +#endif -- term-rewriting API import Data.Rewriting.Term (Term(Fun, Var)) diff --git a/src/TypeLevel/Rewrite/Internal/TypeTerm.hs b/src/TypeLevel/Rewrite/Internal/TypeTerm.hs index 68309bc..80fb411 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeTerm.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeTerm.hs @@ -2,7 +2,11 @@ module TypeLevel.Rewrite.Internal.TypeTerm where -- GHC API +#if MIN_VERSION_ghc(9,0,0) import GHC.Plugins (Type, mkTyConApp) +#else +import Type (Type, mkTyConApp) +#endif -- term-rewriting API import Data.Rewriting.Term (Term(Fun, Var)) diff --git a/typelevel-rewrite-rules.cabal b/typelevel-rewrite-rules.cabal index df8a73d..437b328 100644 --- a/typelevel-rewrite-rules.cabal +++ b/typelevel-rewrite-rules.cabal @@ -53,6 +53,7 @@ library , term-rewriting >=0.3.0.1 , transformers >=0.5.6.2 default-language: Haskell2010 + default-extensions: CPP test-suite should-compile type: exitcode-stdio-1.0 From 8b7955c794d5ce97b57b53f7ab113e3e9389f415 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Fri, 23 Jul 2021 02:41:32 +0900 Subject: [PATCH 04/14] Update CI-settings to support for ghc-9 --- .github/workflows/ci.yml | 7 ++++++- oldest-supported-lts.yaml | 2 +- stack.yaml | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b246375..2229d74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,9 +70,12 @@ jobs: # versions of our dependencies allowed by our upper bounds. # # TODO: switch back to "ghc: latest" once we support ghc-9.0 - - name: newest + - name: oldest ghc: "8.10" os: ubuntu-latest + - name: newest + ghc: "9.0" + os: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -120,6 +123,8 @@ jobs: include: - ghc: "8.10" os: ubuntu-latest + - ghc: "9.0" + os: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/oldest-supported-lts.yaml b/oldest-supported-lts.yaml index bae91e3..04c2037 100644 --- a/oldest-supported-lts.yaml +++ b/oldest-supported-lts.yaml @@ -1,7 +1,7 @@ # if this build fails and you need to bump the lts, remember # to also bump the lower bounds in package.yaml to match the # versions provided by that new lts! -resolver: nightly-2020-12-10 +resolver: lts-18.3 packages: - '.' diff --git a/stack.yaml b/stack.yaml index 7e0065b..8f2fd20 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,7 +1,7 @@ -resolver: nightly-2020-12-10 +resolver: nightly-2021-07-22 packages: - '.' extra-deps: - term-rewriting-0.4.0.2 -- union-find-array-0.1.0.2 +- union-find-array-0.1.0.3 From 1c3ee60f4de5ee7cd5ee40adbc178c45e8507913 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Fri, 23 Jul 2021 02:54:16 +0900 Subject: [PATCH 05/14] Revert oldest-supported-lts.yaml --- oldest-supported-lts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oldest-supported-lts.yaml b/oldest-supported-lts.yaml index 04c2037..bae91e3 100644 --- a/oldest-supported-lts.yaml +++ b/oldest-supported-lts.yaml @@ -1,7 +1,7 @@ # if this build fails and you need to bump the lts, remember # to also bump the lower bounds in package.yaml to match the # versions provided by that new lts! -resolver: lts-18.3 +resolver: nightly-2020-12-10 packages: - '.' From cf23a3ccd4f9271b5cc4279da7a9e759a4a5b96f Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Fri, 6 Aug 2021 18:24:33 +0900 Subject: [PATCH 06/14] Remove ghc-8.0 of error-messages test --- .github/workflows/ci.yml | 2 -- package.yaml | 2 +- typelevel-rewrite-rules.cabal | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2229d74..4437222 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,8 +121,6 @@ jobs: strategy: matrix: include: - - ghc: "8.10" - os: ubuntu-latest - ghc: "9.0" os: ubuntu-latest diff --git a/package.yaml b/package.yaml index 8a36653..1450ec8 100644 --- a/package.yaml +++ b/package.yaml @@ -25,7 +25,7 @@ dependencies: library: source-dirs: src dependencies: - - ghc >= 8.10.2 && <= 9.1 + - ghc >= 8.10.2 && <9.1 - containers >= 0.6.2.1 - term-rewriting >= 0.3.0.1 - transformers >= 0.5.6.2 diff --git a/typelevel-rewrite-rules.cabal b/typelevel-rewrite-rules.cabal index 437b328..b13df50 100644 --- a/typelevel-rewrite-rules.cabal +++ b/typelevel-rewrite-rules.cabal @@ -48,7 +48,7 @@ library build-depends: base >=4.12 && <5 , containers >=0.6.2.1 - , ghc >=8.10.2 && <= 9.1 + , ghc >=8.10.2 && <9.1 , ghc-prim >=0.5.3 , term-rewriting >=0.3.0.1 , transformers >=0.5.6.2 From f3f810f2be9a8cc31c4e4aeb6578bbd8a7d203b2 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Fri, 6 Aug 2021 19:16:31 +0900 Subject: [PATCH 07/14] Update error messages for ghc-9 --- test/error-messages-cases/no-plugin/expected | 27 +++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/error-messages-cases/no-plugin/expected b/test/error-messages-cases/no-plugin/expected index 430509e..ec5caf3 100644 --- a/test/error-messages-cases/no-plugin/expected +++ b/test/error-messages-cases/no-plugin/expected @@ -1 +1,26 @@ - • Couldn't match type ‘as ++ (bs ++ cs)’ with ‘(as ++ bs) ++ cs’ +configure (lib) +Configuring no-plugin-0.0.0... +build (lib) +Preprocessing library for no-plugin-0.0.0.. +Building library for no-plugin-0.0.0.. +[1 of 2] Compiling NoPlugin.Test + +/error-messages-cases/no-plugin/src/NoPlugin/Test.hs:15:16: error: + • Couldn't match type: as ++ (bs ++ cs) + with: (as ++ bs) ++ cs + Expected: proxy ((as ++ bs) ++ cs) + Actual: proxy (as ++ (bs ++ cs)) + NB: ‘++’ is a non-injective type family + • In the expression: r + In an equation for ‘ex2e’: ex2e _ _ _ r = r + • Relevant bindings include + r :: proxy (as ++ (bs ++ cs)) (bound at src/NoPlugin/Test.hs:15:12) + ex2e :: proxy as + -> proxy bs + -> proxy cs + -> proxy (as ++ (bs ++ cs)) + -> proxy ((as ++ bs) ++ cs) + (bound at src/NoPlugin/Test.hs:15:1) + | +15 | ex2e _ _ _ r = r + | ^ From 1262d69e7e16705c1a85832125ce0b5b82a41278 Mon Sep 17 00:00:00 2001 From: Junji Hashimoto Date: Thu, 12 Aug 2021 14:30:52 +0900 Subject: [PATCH 08/14] Bump hash of cabal-file --- typelevel-rewrite-rules.cabal | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/typelevel-rewrite-rules.cabal b/typelevel-rewrite-rules.cabal index b13df50..bd2c839 100644 --- a/typelevel-rewrite-rules.cabal +++ b/typelevel-rewrite-rules.cabal @@ -1,10 +1,10 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0. +-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack -- --- hash: 2673197ba6a9e92128e851017519e221b95a23ca70b1f7b84158feae74eba11b +-- hash: 201dd297be3e249f9d5773e714652b18086e8f3160a1bdca783242cb52598513 name: typelevel-rewrite-rules version: 1.0 @@ -53,7 +53,8 @@ library , term-rewriting >=0.3.0.1 , transformers >=0.5.6.2 default-language: Haskell2010 - default-extensions: CPP + default-extensions: + CPP test-suite should-compile type: exitcode-stdio-1.0 From d4b6b514c3784814f74b1453544349bf7812f3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20G=C3=A9lineau?= Date: Wed, 15 Mar 2023 21:02:28 -0400 Subject: [PATCH 09/14] rename CI config file According to my experiments in #36, renaming the CI config file mysteriously allows CI to start running again! --- .github/workflows/{ci.yml => haskell.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ci.yml => haskell.yml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/haskell.yml similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/haskell.yml From 9385576a99642cb60e445451e9ef152110a80a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20G=C3=A9lineau?= Date: Wed, 15 Mar 2023 21:26:31 -0400 Subject: [PATCH 10/14] test all the supported GHC versions and list them in the "tested-with" section of the cabal file --- .github/workflows/haskell.yml | 22 ++++++++++++++-------- package.yaml | 4 ++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 4437222..48f97a6 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -65,16 +65,22 @@ jobs: strategy: matrix: include: - # Check that our upper bounds are correct by building with the latest - # version of everything. We use cabal because it uses the latest - # versions of our dependencies allowed by our upper bounds. + # The purpose of that section is two-fold. First, because we are + # using cabal and not stack, cabal will pick the most recent version + # of our dependencies which has been released. This way, if a + # dependency releases a breaking change, the next monthly CI will + # pick that version and notify us if we are affected by the change. # - # TODO: switch back to "ghc: latest" once we support ghc-9.0 - - name: oldest - ghc: "8.10" + # Second, since this project is a ghc plugin, we rely on details of + # the GHC library which change between versions. It is thus quite + # easy to accidentally make a change which works for the latest + # version of GHC but not with older versions. CI should thus test all + # the supported GHC versions. + - name: ghc-8.10 + ghc: "8.10.7" os: ubuntu-latest - - name: newest - ghc: "9.0" + - name: ghc-9.0 + ghc: "9.0.2" os: ubuntu-latest steps: diff --git a/package.yaml b/package.yaml index 1450ec8..4e1e046 100644 --- a/package.yaml +++ b/package.yaml @@ -18,6 +18,10 @@ extra-source-files: # for release ghc-options: -W -Wall +tested-with: + - GHC == 9.0.2 + - GHC == 8.10.7 + dependencies: - base >= 4.12 && < 5 - ghc-prim >= 0.5.3 From f5254d30f0f599aac4ebad49a06cbc062db22d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20G=C3=A9lineau?= Date: Wed, 15 Mar 2023 21:35:09 -0400 Subject: [PATCH 11/14] move CPP from the .cabal file to each .hs file This makes it easier for some tools to determine all the language extensions which apply. --- package.yaml | 1 - src/TypeLevel/Rewrite.hs | 2 +- src/TypeLevel/Rewrite/Internal/ApplyRules.hs | 2 +- src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs | 2 +- src/TypeLevel/Rewrite/Internal/Lookup.hs | 2 +- src/TypeLevel/Rewrite/Internal/PrettyPrint.hs | 2 +- src/TypeLevel/Rewrite/Internal/TypeEq.hs | 1 + src/TypeLevel/Rewrite/Internal/TypeNode.hs | 2 +- src/TypeLevel/Rewrite/Internal/TypeRule.hs | 2 +- src/TypeLevel/Rewrite/Internal/TypeTemplate.hs | 2 +- src/TypeLevel/Rewrite/Internal/TypeTerm.hs | 2 +- typelevel-rewrite-rules.cabal | 9 +++++---- 12 files changed, 15 insertions(+), 14 deletions(-) diff --git a/package.yaml b/package.yaml index 4e1e046..87e2716 100644 --- a/package.yaml +++ b/package.yaml @@ -33,7 +33,6 @@ library: - containers >= 0.6.2.1 - term-rewriting >= 0.3.0.1 - transformers >= 0.5.6.2 - default-extensions: CPP tests: should-compile: diff --git a/src/TypeLevel/Rewrite.hs b/src/TypeLevel/Rewrite.hs index 5d1ef6a..27759f6 100644 --- a/src/TypeLevel/Rewrite.hs +++ b/src/TypeLevel/Rewrite.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, OverloadedStrings, RecordWildCards, ViewPatterns #-} +{-# LANGUAGE CPP, LambdaCase, OverloadedStrings, RecordWildCards, ViewPatterns #-} module TypeLevel.Rewrite (plugin) where import Control.Monad diff --git a/src/TypeLevel/Rewrite/Internal/ApplyRules.hs b/src/TypeLevel/Rewrite/Internal/ApplyRules.hs index 1fbbfca..e6e7cfa 100644 --- a/src/TypeLevel/Rewrite/Internal/ApplyRules.hs +++ b/src/TypeLevel/Rewrite/Internal/ApplyRules.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, TupleSections, ViewPatterns #-} +{-# LANGUAGE CPP, LambdaCase, TupleSections, ViewPatterns #-} {-# OPTIONS -Wno-name-shadowing #-} module TypeLevel.Rewrite.Internal.ApplyRules where diff --git a/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs b/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs index 8226dbb..e121dbd 100644 --- a/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs +++ b/src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, LambdaCase, RecordWildCards, ViewPatterns #-} +{-# LANGUAGE CPP, DeriveFunctor, DeriveFoldable, DeriveTraversable, LambdaCase, RecordWildCards, ViewPatterns #-} module TypeLevel.Rewrite.Internal.DecomposedConstraint where import Control.Applicative diff --git a/src/TypeLevel/Rewrite/Internal/Lookup.hs b/src/TypeLevel/Rewrite/Internal/Lookup.hs index 62a1d32..c390638 100644 --- a/src/TypeLevel/Rewrite/Internal/Lookup.hs +++ b/src/TypeLevel/Rewrite/Internal/Lookup.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, ViewPatterns #-} +{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} module TypeLevel.Rewrite.Internal.Lookup where import Control.Arrow ((***), first) diff --git a/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs b/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs index 4af808e..efad118 100644 --- a/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs +++ b/src/TypeLevel/Rewrite/Internal/PrettyPrint.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, RecordWildCards #-} +{-# LANGUAGE CPP, LambdaCase, RecordWildCards #-} module TypeLevel.Rewrite.Internal.PrettyPrint where import Data.List (intercalate) diff --git a/src/TypeLevel/Rewrite/Internal/TypeEq.hs b/src/TypeLevel/Rewrite/Internal/TypeEq.hs index 53d2df5..acda114 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeEq.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeEq.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} module TypeLevel.Rewrite.Internal.TypeEq where import Data.Function diff --git a/src/TypeLevel/Rewrite/Internal/TypeNode.hs b/src/TypeLevel/Rewrite/Internal/TypeNode.hs index 31f32e6..ca320d5 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeNode.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeNode.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE CPP, ViewPatterns #-} module TypeLevel.Rewrite.Internal.TypeNode where -- GHC API diff --git a/src/TypeLevel/Rewrite/Internal/TypeRule.hs b/src/TypeLevel/Rewrite/Internal/TypeRule.hs index 9aeb5dd..0c1fab3 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeRule.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeRule.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, ViewPatterns #-} +{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} {-# OPTIONS -Wno-name-shadowing #-} module TypeLevel.Rewrite.Internal.TypeRule where diff --git a/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs b/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs index 12dbe38..b2fa608 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeTemplate.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, ViewPatterns #-} +{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} module TypeLevel.Rewrite.Internal.TypeTemplate where -- GHC API diff --git a/src/TypeLevel/Rewrite/Internal/TypeTerm.hs b/src/TypeLevel/Rewrite/Internal/TypeTerm.hs index 80fb411..5e06acd 100644 --- a/src/TypeLevel/Rewrite/Internal/TypeTerm.hs +++ b/src/TypeLevel/Rewrite/Internal/TypeTerm.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE LambdaCase, ViewPatterns #-} +{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} module TypeLevel.Rewrite.Internal.TypeTerm where -- GHC API diff --git a/typelevel-rewrite-rules.cabal b/typelevel-rewrite-rules.cabal index bd2c839..26a9688 100644 --- a/typelevel-rewrite-rules.cabal +++ b/typelevel-rewrite-rules.cabal @@ -1,10 +1,10 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4. +-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack -- --- hash: 201dd297be3e249f9d5773e714652b18086e8f3160a1bdca783242cb52598513 +-- hash: cac2a8aec9cc51f367be3e13c24e6efa7d62ba4ec28e8368137d8292de814188 name: typelevel-rewrite-rules version: 1.0 @@ -17,6 +17,9 @@ author: Samuel Gélineau maintainer: gelisam+github@gmail.com license: PublicDomain build-type: Simple +tested-with: + GHC == 9.0.2 + , GHC == 8.10.7 extra-source-files: README.md CHANGELOG.md @@ -53,8 +56,6 @@ library , term-rewriting >=0.3.0.1 , transformers >=0.5.6.2 default-language: Haskell2010 - default-extensions: - CPP test-suite should-compile type: exitcode-stdio-1.0 From 2aa4ed22034d3e72cde2199dea3f9c08d56f13ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20G=C3=A9lineau?= Date: Wed, 15 Mar 2023 21:49:51 -0400 Subject: [PATCH 12/14] bump the recommended stackage snapshot --- stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index 8f2fd20..1db2e48 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: nightly-2021-07-22 +resolver: lts-19.33 packages: - '.' From 62c540baa0953154cffbe3dff30f7553f86e23da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20G=C3=A9lineau?= Date: Wed, 15 Mar 2023 21:57:46 -0400 Subject: [PATCH 13/14] focus on the important part of the expected error this way the test is less likely to break when the surrounding text changes. --- test/error-messages-cases/no-plugin/expected | 24 -------------------- 1 file changed, 24 deletions(-) diff --git a/test/error-messages-cases/no-plugin/expected b/test/error-messages-cases/no-plugin/expected index ec5caf3..b2ac572 100644 --- a/test/error-messages-cases/no-plugin/expected +++ b/test/error-messages-cases/no-plugin/expected @@ -1,26 +1,2 @@ -configure (lib) -Configuring no-plugin-0.0.0... -build (lib) -Preprocessing library for no-plugin-0.0.0.. -Building library for no-plugin-0.0.0.. -[1 of 2] Compiling NoPlugin.Test - -/error-messages-cases/no-plugin/src/NoPlugin/Test.hs:15:16: error: • Couldn't match type: as ++ (bs ++ cs) with: (as ++ bs) ++ cs - Expected: proxy ((as ++ bs) ++ cs) - Actual: proxy (as ++ (bs ++ cs)) - NB: ‘++’ is a non-injective type family - • In the expression: r - In an equation for ‘ex2e’: ex2e _ _ _ r = r - • Relevant bindings include - r :: proxy (as ++ (bs ++ cs)) (bound at src/NoPlugin/Test.hs:15:12) - ex2e :: proxy as - -> proxy bs - -> proxy cs - -> proxy (as ++ (bs ++ cs)) - -> proxy ((as ++ bs) ++ cs) - (bound at src/NoPlugin/Test.hs:15:1) - | -15 | ex2e _ _ _ r = r - | ^ From 6501dee5e59a9741346b12b89a66bc3b33caebce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20G=C3=A9lineau?= Date: Wed, 15 Mar 2023 22:05:26 -0400 Subject: [PATCH 14/14] use the right proxy arguments the purpose of the proxy argument was to make the type variables unambiguous, but it was naming the wrong type variables. --- test/should-compile/GHC/TypeLits/Test.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/should-compile/GHC/TypeLits/Test.hs b/test/should-compile/GHC/TypeLits/Test.hs index da3aa55..ffc8fdd 100644 --- a/test/should-compile/GHC/TypeLits/Test.hs +++ b/test/should-compile/GHC/TypeLits/Test.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DataKinds, RankNTypes, TypeFamilies, TypeOperators, AllowAmbiguousTypes #-} +{-# LANGUAGE DataKinds, RankNTypes, TypeFamilies, TypeOperators #-} {-# OPTIONS_GHC -fplugin TypeLevel.Rewrite -fplugin-opt=TypeLevel.Rewrite:GHC.TypeLits.RewriteRules.NatRule -fplugin-opt=TypeLevel.Rewrite:GHC.TypeLits.RewriteRules.SymbolRule #-} @@ -17,6 +17,7 @@ ex2 :: ( ((s1 `AppendSymbol` "foo") `AppendSymbol` s2) ~ (s1 `AppendSymbol` ("foo" `AppendSymbol` s2)) => r ) - -> proxy s + -> proxy s1 + -> proxy s2 -> r -ex2 r _ = r +ex2 r _ _ = r