typelevel-rewrite-rules 1.0 → 1.0.0.1
raw patch · 13 files changed
+86/−20 lines, 13 filesdep ~ghcPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ghc
API changes (from Hackage documentation)
Files
- CHANGELOG.md +3/−0
- src/TypeLevel/Rewrite.hs +13/−1
- src/TypeLevel/Rewrite/Internal/ApplyRules.hs +5/−1
- src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs +6/−1
- src/TypeLevel/Rewrite/Internal/Lookup.hs +14/−6
- src/TypeLevel/Rewrite/Internal/PrettyPrint.hs +7/−1
- src/TypeLevel/Rewrite/Internal/TypeEq.hs +5/−0
- src/TypeLevel/Rewrite/Internal/TypeNode.hs +6/−1
- src/TypeLevel/Rewrite/Internal/TypeRule.hs +7/−1
- src/TypeLevel/Rewrite/Internal/TypeTemplate.hs +5/−1
- src/TypeLevel/Rewrite/Internal/TypeTerm.hs +5/−1
- test/should-compile/GHC/TypeLits/Test.hs +3/−2
- typelevel-rewrite-rules.cabal +7/−4
CHANGELOG.md view
@@ -1,3 +1,6 @@+# 1.0.0.1+* Now supports ghc-9.0 (and remains compatible with ghc-8.10)+ # 1.0 * Now supports ghc-8.10! Unfortunately, ghc-8.6 and ghc-8.8 are no longer supported.
src/TypeLevel/Rewrite.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE LambdaCase, OverloadedStrings, RecordWildCards, ViewPatterns #-}+{-# LANGUAGE CPP, LambdaCase, OverloadedStrings, RecordWildCards, ViewPatterns #-} module TypeLevel.Rewrite (plugin) where import Control.Monad@@ -8,6 +8,17 @@ 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)+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(..))+#else import Coercion (Role(Representational), mkUnivCo) import Constraint (CtEvidence(ctev_loc), Ct, ctEvExpr, ctLoc, mkNonCanonical) import GhcPlugins (PredType, SDoc, eqType, fsep, ppr)@@ -17,6 +28,7 @@ import TcRnTypes import TyCoRep (UnivCoProvenance(PluginProv)) import TyCon (synTyConDefn_maybe)+#endif import TypeLevel.Rewrite.Internal.ApplyRules import TypeLevel.Rewrite.Internal.DecomposedConstraint
src/TypeLevel/Rewrite/Internal/ApplyRules.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE LambdaCase, TupleSections, ViewPatterns #-}+{-# LANGUAGE CPP, LambdaCase, TupleSections, ViewPatterns #-} {-# OPTIONS -Wno-name-shadowing #-} module TypeLevel.Rewrite.Internal.ApplyRules where @@ -13,7 +13,11 @@ 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(..))
src/TypeLevel/Rewrite/Internal/DecomposedConstraint.hs view
@@ -1,12 +1,17 @@-{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, LambdaCase, RecordWildCards, ViewPatterns #-}+{-# LANGUAGE CPP, DeriveFunctor, DeriveFoldable, DeriveTraversable, LambdaCase, RecordWildCards, ViewPatterns #-} module TypeLevel.Rewrite.Internal.DecomposedConstraint where 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
src/TypeLevel/Rewrite/Internal/Lookup.hs view
@@ -1,21 +1,29 @@-{-# LANGUAGE LambdaCase, ViewPatterns #-}+{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} module TypeLevel.Rewrite.Internal.Lookup where import Control.Arrow ((***), first) import Data.Tuple (swap) -- GHC API-import 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)+import GHC.Tc.Plugin+ ( FindResult(Found), TcPluginM, findImportedModule, lookupOrig, tcLookupDataCon, tcLookupTyCon+ , 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- ( FindResult(Found), TcPluginM, findImportedModule, lookupOrig, tcLookupDataCon, tcLookupTyCon- , unsafeTcPluginTcM- ) import TcSMonad (getDynFlags)-+#endif lookupModule :: String -- ^ module name
src/TypeLevel/Rewrite/Internal/PrettyPrint.hs view
@@ -1,12 +1,18 @@-{-# LANGUAGE LambdaCase, RecordWildCards #-}+{-# LANGUAGE CPP, LambdaCase, RecordWildCards #-} 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(..))
src/TypeLevel/Rewrite/Internal/TypeEq.hs view
@@ -1,8 +1,13 @@+{-# LANGUAGE CPP #-} 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.
src/TypeLevel/Rewrite/Internal/TypeNode.hs view
@@ -1,9 +1,14 @@-{-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE CPP, ViewPatterns #-} 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
src/TypeLevel/Rewrite/Internal/TypeRule.hs view
@@ -1,11 +1,17 @@-{-# LANGUAGE LambdaCase, ViewPatterns #-}+{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} {-# OPTIONS -Wno-name-shadowing #-} 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(..))
src/TypeLevel/Rewrite/Internal/TypeTemplate.hs view
@@ -1,8 +1,12 @@-{-# LANGUAGE LambdaCase, ViewPatterns #-}+{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} 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))
src/TypeLevel/Rewrite/Internal/TypeTerm.hs view
@@ -1,8 +1,12 @@-{-# LANGUAGE LambdaCase, ViewPatterns #-}+{-# LANGUAGE CPP, LambdaCase, ViewPatterns #-} 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))
test/should-compile/GHC/TypeLits/Test.hs view
@@ -17,6 +17,7 @@ ~ (s1 `AppendSymbol` ("foo" `AppendSymbol` s2)) => r )- -> proxy s+ -> proxy s1+ -> proxy s2 -> r-ex2 r _ = r+ex2 r _ _ = r
typelevel-rewrite-rules.cabal view
@@ -1,13 +1,13 @@ 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.35.2. -- -- see: https://github.com/sol/hpack ----- hash: 2673197ba6a9e92128e851017519e221b95a23ca70b1f7b84158feae74eba11b+-- hash: 228b6969b9e5934cdf11b460c5fa1ee3e3f5e70e3f58d4b5422a80a9676c49b3 name: typelevel-rewrite-rules-version: 1.0+version: 1.0.0.1 synopsis: Solve type equalities using custom type-level rewrite rules description: A typechecker plugin which allows the user to specify a set of domain-specific rewrite rules. These get applied whenever the compiler is unable to solve a type equality constraint, in the hope that the rewritten equality constraint will be easier to solve. category: Type System@@ -17,6 +17,9 @@ 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@@ -48,7 +51,7 @@ 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