ghc-tcplugin-api 0.12.0.0 → 0.13.0.0
raw patch · 3 files changed
+53/−35 lines, 3 filesdep ~ghcPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: ghc
API changes (from Hackage documentation)
- GHC.TcPlugin.API: ctEvId :: HasDebugCallStack => Ct -> EvVar
- GHC.TcPlugin.API: emptyDVarSet :: DVarSet
- GHC.TcPlugin.API: extendDVarSet :: DVarSet -> Var -> DVarSet
- GHC.TcPlugin.API: mkDVarSet :: [Var] -> DVarSet
- GHC.TcPlugin.API: type DVarSet = UniqDSet Var
- GHC.TcPlugin.API: unionDVarSet :: DVarSet -> DVarSet -> DVarSet
- GHC.TcPlugin.API: unitDVarSet :: Var -> DVarSet
+ GHC.TcPlugin.API: ctEvCoercion :: HasDebugCallStack => CtEvidence -> TcCoercion
- GHC.TcPlugin.API: mkPluginUnivCo :: String -> Role -> DVarSet -> TcType -> TcType -> Coercion
+ GHC.TcPlugin.API: mkPluginUnivCo :: String -> Role -> [Coercion] -> TcType -> TcType -> Coercion
- GHC.TcPlugin.API: mkPluginUnivEvTerm :: String -> Role -> DVarSet -> TcType -> TcType -> EvTerm
+ GHC.TcPlugin.API: mkPluginUnivEvTerm :: String -> Role -> [Coercion] -> TcType -> TcType -> EvTerm
- GHC.TcPlugin.API: mkTyFamAppReduction :: String -> Role -> DVarSet -> TyCon -> [TcType] -> TcType -> Reduction
+ GHC.TcPlugin.API: mkTyFamAppReduction :: String -> Role -> [Coercion] -> TyCon -> [TcType] -> TcType -> Reduction
Files
- changelog.md +17/−1
- ghc-tcplugin-api.cabal +2/−2
- src/GHC/TcPlugin/API.hs +34/−32
changelog.md view
@@ -1,6 +1,22 @@+# Version 0.13.0.0 (2024-30-10) + +- Update to changes in the type of GHC's `mkUnivCo` + in order to (properly) add support for GHC 9.12. + +- Change `mkPluginUnivCo`, `mkPluginUnivEvTerm` and `mkTyFamAppReduction` + to take a `[Coercion]` rather than a `DVarSet` for specifying dependencies. + +- Stop re-exporting `DVarSet`, `emptyDVarSet`, `extendDVarSet`, `unionDVarSet`, + `unitDVarSet`, and `mkDVarSet`. + +- Update documentation to suggest using `ctEvCoercion` + rather than `ctEvId` to specify coercions that a `UnivCo` depends on. + +- Re-export `ctEvCoercion`, and stop re-exporting `ctEvId`. + # Version 0.12.0.0 (2024-22-10) -- Add support for GHC 9.12. +- Add preliminary support for GHC 9.12. - `mkPluginUnivCo`, `mkPluginUnivEvTerm` and `mkTyFamAppReduction` now all take an additional `DVarSet` argument which allows specifying evidence that we
ghc-tcplugin-api.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: ghc-tcplugin-api -version: 0.12.0.0 +version: 0.13.0.0 synopsis: An API for type-checker plugins. license: BSD-3-Clause build-type: Simple @@ -37,7 +37,7 @@ containers >= 0.6 && < 0.8, ghc - >= 8.8 && < 9.13, + >= 8.8 && < 9.14, transformers >= 0.5 && < 0.7,
src/GHC/TcPlugin/API.hs view
@@ -246,7 +246,6 @@ -- | == Some further functions for inspecting constraints , eqType , ctLoc, ctEvidence, ctFlavour, ctEqRel, ctOrigin - , ctEvId -- ** Constraint evidence @@ -263,16 +262,16 @@ -- *** Depending on outer Givens -- | When a plugin returns a coercion that depends on outer Given constraints, - -- it should declare this dependency using the 'DVarSet' argument to + -- it should declare this dependency using the '[Coercion]' argument to -- functions such as 'mkPluginUnivCo', 'mkPluginUnivEvTerm' and 'mkTyFamAppReduction' -- in order to avoid this coercion getting floated out past such enclosing -- Givens. -- - -- You can use 'ctEvId' to obtain the evidence variable corresponding to - -- a Given constraint, and functions such as 'emptyDVarSet', 'unitDVarSet', - -- 'unionDVarSet' and 'extendDVarSet' to construct the appropriate 'DVarSet's. - , DVarSet - , emptyDVarSet, unitDVarSet, unionDVarSet, extendDVarSet, mkDVarSet + -- You can use 'ctEvCoercion' to obtain the coercion underlying an equality + -- constraint (whether Given or Wanted). It is not possible to declare + -- a dependency on non-equality constraints, and calling 'ctEvCoercion' + -- on a non-equality constraint will cause a crash. + , ctEvCoercion -- *** Evidence terms @@ -623,13 +622,20 @@ , RewriteEnv(..) #endif ) +#if MIN_VERSION_ghc(9,11,0) +import GHC.Tc.Types.CtLoc + ( CtLoc(..), bumpCtLocDepth ) +#endif import GHC.Tc.Types.Constraint - ( Ct(..), CtLoc(..), CtEvidence(..), CtFlavour(..) + ( Ct(..), CtEvidence(..), CtFlavour(..) , QCInst(..), TcEvDest(..) - , ctPred, ctLoc, ctEvidence, ctEvId, ctEvExpr + , ctPred, ctLoc, ctEvidence, ctEvExpr + , ctEvCoercion , ctFlavour, ctEqRel, ctOrigin - , bumpCtLocDepth , mkNonCanonical +#if !MIN_VERSION_ghc(9,11,0) + , CtLoc(..), bumpCtLocDepth +#endif ) import GHC.Tc.Types.Evidence ( EvBind(..), EvTerm(..), EvExpr, EvBindsVar(..) @@ -664,11 +670,6 @@ ( OccName(..) , mkVarOcc, mkDataOcc, mkTyVarOcc, mkTcOcc, mkClsOcc ) -import GHC.Types.Var.Set - ( mkDVarSet, emptyDVarSet, extendDVarSet - , unitDVarSet, extendDVarSet, unionDVarSet - , DVarSet - ) #if MIN_VERSION_ghc(9,3,0) import GHC ( HscEnv ) @@ -1029,18 +1030,19 @@ mkPluginUnivCo :: String -- ^ Name of equality (for the plugin's internal use, or for debugging) -> Role - -> DVarSet -- ^ Evidence that this proof term depends on (use e.g. 'ctEvId' for a Given) + -> [Coercion] -- ^ Evidence that this proof term depends on (use 'ctEvCoercion') -> TcType -- ^ LHS -> TcType -- ^ RHS -> Coercion mkPluginUnivCo str role _deps lhs rhs = - let prov = - PluginProv - str -#if MIN_VERSION_ghc(9,11,0) - _deps + mkUnivCo + ( PluginProv str ) +#if MIN_VERSION_ghc(9,12,0) + _deps #endif - in mkUnivCo prov role lhs rhs + role + lhs + rhs -- | Conjure up an evidence term for an equality between two types -- at the given 'Role' ('Nominal' or 'Representational'). @@ -1050,11 +1052,11 @@ -- The plugin is responsible for not emitting any unsound equalities, -- such as an equality between 'Int' and 'Float'. mkPluginUnivEvTerm - :: String -- ^ Name of equality (for the plugin's internal use, or for debugging) + :: String -- ^ Name of equality (for the plugin's internal use, or for debugging) -> Role - -> DVarSet -- ^ Evidence that this proof term depends on (use e.g. 'ctEvId' for a Given) - -> TcType -- ^ LHS - -> TcType -- ^ RHS + -> [Coercion] -- ^ Evidence that this proof term depends on (use 'ctEvCoercion') + -> TcType -- ^ LHS + -> TcType -- ^ RHS -> EvTerm mkPluginUnivEvTerm str role deps lhs rhs = evCoercion $ mkPluginUnivCo str role deps lhs rhs @@ -1065,12 +1067,12 @@ -- The result can be passed to 'TcPluginRewriteTo' to specify the outcome -- of rewriting a type family application. mkTyFamAppReduction - :: String -- ^ Name of reduction (for debugging) - -> Role -- ^ Role of reduction ('Nominal' or 'Representational') - -> DVarSet -- ^ Evidence that this reduction depends on (use e.g. 'ctEvId' for a Given) - -> TyCon -- ^ Type family 'TyCon' - -> [TcType] -- ^ Type family arguments - -> TcType -- ^ The type that the type family application reduces to + :: String -- ^ Name of reduction (for debugging) + -> Role -- ^ Role of reduction ('Nominal' or 'Representational') + -> [Coercion] -- ^ Evidence that this reduction depends on (use 'ctEvCoercion') + -> TyCon -- ^ Type family 'TyCon' + -> [TcType] -- ^ Type family arguments + -> TcType -- ^ The type that the type family application reduces to -> Reduction mkTyFamAppReduction str role deps tc args ty = Reduction ( mkPluginUnivCo str role deps ( mkTyConApp tc args ) ty ) ty