ghc-tcplugin-api 0.6.0.0 → 0.6.1.0
raw patch · 4 files changed
+73/−43 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- GHC.TcPlugin.API: InvisArg :: AnonArgFlag
- GHC.TcPlugin.API: VisArg :: AnonArgFlag
- GHC.TcPlugin.API: data AnonArgFlag
- GHC.TcPlugin.API: infixr 3 `mkInvisFunTy`
- GHC.TcPlugin.API: mkFunTy :: AnonArgFlag -> Type -> Type -> Type
- GHC.TcPlugin.API: mkInvisFunTy :: Type -> Type -> Type
- GHC.TcPlugin.API: mkVisFunTy :: Type -> Type -> Type
- GHC.TcPlugin.API: mkVisFunTys :: [Type] -> Type -> Type
+ GHC.TcPlugin.API: L :: l -> e -> GenLocated l e
+ GHC.TcPlugin.API: data GenLocated l e
+ GHC.TcPlugin.API: data MetaDetails
+ GHC.TcPlugin.API: data MetaInfo
+ GHC.TcPlugin.API: getLoc :: HasSrcSpan a => a -> SrcSpan
+ GHC.TcPlugin.API: isFilledMetaTyVar_maybe :: TcTyVar -> TcM (Maybe Type)
+ GHC.TcPlugin.API: isMetaTyVar :: TcTyVar -> Bool
+ GHC.TcPlugin.API: isSkolemTyVar :: TcTyVar -> Bool
+ GHC.TcPlugin.API: mkInvisFunTyMany :: Type -> Type -> Type
+ GHC.TcPlugin.API: mkInvisFunTysMany :: [Type] -> Type -> Type
+ GHC.TcPlugin.API: panic :: String -> a
+ GHC.TcPlugin.API: pprPanic :: HasCallStack => String -> SDoc -> a
+ GHC.TcPlugin.API: type CoVar = Id
+ GHC.TcPlugin.API: type Located = GenLocated SrcSpan
+ GHC.TcPlugin.API: type RealLocated = GenLocated RealSrcSpan
+ GHC.TcPlugin.API: type TyVar = Var
+ GHC.TcPlugin.API: unLoc :: HasSrcSpan a => a -> SrcSpanLess a
+ GHC.TcPlugin.API: writeMetaTyVar :: TcTyVar -> TcType -> TcM ()
Files
- changelog.md +12/−0
- ghc-tcplugin-api.cabal +3/−1
- src/GHC/TcPlugin/API.hs +57/−41
- src/GHC/TcPlugin/API/Internal.hs +1/−1
changelog.md view
@@ -1,4 +1,16 @@ +# Version 0.6.1.0 (2021-12-13) + +- Re-export various useful types and functions to deal with type and coercion variables. + +- Re-export a few types and functions to deal with source locations. + +- Remove some re-exports for constructing function types: only re-export `mkVisFunTyMany` + and `mkVisFunTysMany`, as these are the only functions that make sense across all + GHC versions. + +- Re-export `panic` and `pprPanic`. + # Version 0.6.0.0 (2021-12-13) - Add support for GHC 8.8.
ghc-tcplugin-api.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: ghc-tcplugin-api -version: 0.6.0.0 +version: 0.6.1.0 synopsis: An API for type-checker plugins. license: BSD-3-Clause build-type: Simple @@ -112,10 +112,12 @@ , TcEvidence as GHC.Tc.Types.Evidence , TcRnMonad as GHC.Tc.Utils.Monad , TcType as GHC.Tc.Utils.TcType + , TcMType as GHC.Tc.Utils.TcMType , Id as GHC.Types.Id , Name as GHC.Types.Name , OccName as GHC.Types.Name.Occurrence + , SrcLoc as GHC.Types.SrcLoc , Unique as GHC.Types.Unique , UniqDFM as GHC.Types.Unique.DFM , UniqFM as GHC.Types.Unique.FM
src/GHC/TcPlugin/API.hs view
@@ -225,8 +225,17 @@ -- - a type-class constraint? for which class? -- - an irreducible constraint, e.g. something of the form @c a@? -- - a quantified constraint? + , Pred + , pattern ClassPred, pattern EqPred, pattern IrredPred, pattern ForAllPred , classifyPredType, ctPred + -- | == Handling type variables + , TyVar, CoVar + , MetaDetails, MetaInfo + , isSkolemTyVar + , isMetaTyVar, isFilledMetaTyVar_maybe + , writeMetaTyVar + -- | == Some further functions for inspecting constraints , eqType , ctLoc, ctEvidence, ctFlavour, ctEqRel, ctOrigin @@ -365,18 +374,12 @@ , mkAppTy, mkAppTys -- ** Function types - - , AnonArgFlag(..) - , mkFunTy, mkVisFunTy, mkInvisFunTy, mkVisFunTys + , mkInvisFunTyMany, mkInvisFunTysMany , mkForAllTy, mkForAllTys , mkPiTy, mkPiTys #if MIN_VERSION_ghc(9,0,0) , Mult, pattern One, pattern Many - , mkFunTyMany - , mkScaledFunTy - , mkVisFunTyMany, mkVisFunTysMany - , mkInvisFunTyMany, mkInvisFunTysMany #endif -- ** Zonking @@ -388,6 +391,13 @@ , zonkTcType , zonkCt + -- ** Panicking + + -- | It is often better for type-checking plugins to panic when encountering a problem, + -- as opposed to silently doing something wrong. Use 'pprPanic' to throw an informative + -- error message, so that users of your plugin can report an issue if a problem occurs. + , panic, pprPanic + -- ** Map-like data structures based on 'Unique's -- | Import "GHC.Types.Unique.FM" or "GHC.Types.Unique.DFM" for @@ -421,8 +431,6 @@ , FastString -- | == Constraints - , Pred - , pattern ClassPred, pattern EqPred, pattern IrredPred, pattern ForAllPred , EqRel(..), FunDep, CtFlavour , Ct, CtLoc, CtEvidence, CtOrigin , QCInst @@ -439,6 +447,10 @@ -- | == The type-checking environment , TcGblEnv, TcLclEnv + -- | == Source locations + , GenLocated(..), Located, RealLocated + , unLoc, getLoc + -- | == Pretty-printing , SDoc, Outputable(..) @@ -491,22 +503,20 @@ ( Type, PredType, Kind , Coercion(..), CoercionHole(..) , UnivCoProvenance(..) +#if MIN_VERSION_ghc(9,0,0) + , Mult + , mkInvisFunTyMany, mkInvisFunTysMany +#elif MIN_VERSION_ghc(8,10,0) + , mkInvisFunTy, mkInvisFunTys +#else + , mkFunTy, mkFunTys +#endif #if MIN_VERSION_ghc(8,10,0) - , AnonArgFlag(..) - , mkVisFunTy, mkInvisFunTy, mkVisFunTys , mkPiTy #endif , mkPiTys , mkTyVarTy, mkTyVarTys , mkForAllTy, mkForAllTys - , mkFunTy -#if MIN_VERSION_ghc(9,0,0) - , Mult - , mkFunTyMany - , mkScaledFunTy - , mkVisFunTyMany, mkVisFunTysMany - , mkInvisFunTyMany, mkInvisFunTysMany -#endif ) import GHC.Core.Type ( eqType, mkTyConTy, mkTyConApp, splitTyConApp_maybe @@ -547,7 +557,11 @@ as GHC ( traceTc, setCtLocM ) import GHC.Tc.Utils.TcType - ( TcType, TcLevel ) + ( TcType, TcLevel, MetaDetails, MetaInfo + , isSkolemTyVar, isMetaTyVar + ) +import GHC.Tc.Utils.TcMType + ( isFilledMetaTyVar_maybe, writeMetaTyVar ) import GHC.Types.Id ( Id, mkLocalId ) import GHC.Types.Name @@ -556,6 +570,10 @@ ( OccName(..) , mkVarOcc, mkDataOcc, mkTyVarOcc, mkTcOcc, mkClsOcc ) +import GHC.Types.SrcLoc + ( GenLocated(..), Located, RealLocated + , unLoc, getLoc + ) import GHC.Types.Unique ( Unique ) #if MIN_VERSION_ghc(9,0,0) @@ -570,16 +588,20 @@ import GHC.Types.Unique.DFM ( UniqDFM, lookupUDFM, lookupUDFM_Directly, elemUDFM ) import GHC.Types.Var - ( TcTyVar, EvVar + ( TyVar, CoVar, TcTyVar, EvVar , mkTyVar ) import GHC.Utils.Outputable ( Outputable(..), SDoc -#if !MIN_VERSION_ghc(8,10,0) - , panic +#if !MIN_VERSION_ghc(9,2,0) + , panic, pprPanic #endif ) #if MIN_VERSION_ghc(9,2,0) +import GHC.Utils.Panic + ( panic, pprPanic ) +#endif +#if MIN_VERSION_ghc(9,2,0) import GHC.Unit.Finder ( FindResult(..) ) #else @@ -849,30 +871,23 @@ type UniqFM ty a = GHC.UniqFM a -#endif +#if MIN_VERSION_ghc(8,10,0) -#if !MIN_VERSION_ghc(8,10,0) +mkInvisFunTyMany :: Type -> Type -> Type +mkInvisFunTyMany = mkInvisFunTy --- | The non-dependent version of 'ArgFlag'. --- See Note [AnonArgFlag] --- Appears here partly so that it's together with its friends ArgFlag --- and ForallVisFlag, but also because it is used in IfaceType, rather --- early in the compilation chain -data AnonArgFlag - = VisArg -- ^ Used for @(->)@: an ordinary non-dependent arrow. - -- The argument is visible in source code. - | InvisArg -- ^ Used for @(=>)@: a non-dependent predicate arrow. - -- The argument is invisible in source code. - deriving stock (Eq, Ord) +mkInvisFunTysMany :: [Type] -> Type -> Type +mkInvisFunTysMany = mkInvisFunTys +#else + type Pred = PredTree -mkVisFunTy, mkInvisFunTy :: Type -> Type -> Type -mkVisFunTy = mkFunTy -mkInvisFunTy = mkFunTy +mkInvisFunTyMany :: Type -> Type -> Type +mkInvisFunTyMany = mkFunTy -mkVisFunTys :: [Type] -> Type -> Type -mkVisFunTys tys ty = foldr mkFunTy ty tys +mkInvisFunTysMany :: [Type] -> Type -> Type +mkInvisFunTysMany = mkFunTys mkPiTy :: TyCoBinder -> Type -> Type mkPiTy bndr ty = mkPiTys [bndr] ty @@ -883,4 +898,5 @@ mkPrimEqPredRole Representational = mkReprPrimEqPred mkPrimEqPredRole Phantom = panic "mkPrimEqPredRole phantom" +#endif #endif
src/GHC/TcPlugin/API/Internal.hs view
@@ -319,7 +319,7 @@ #ifdef HAS_REWRITING ( GHC.runTcPluginM . tcPluginInitM ) #else - ( ( `GHC.runTcPluginM` ( error "tcPluginInit: cannot access EvBindsVar" ) ) . tcPluginInitM ) + ( ( `GHC.runTcPluginM` ( error "tcPluginInit: cannot access EvBindsVar" ) ) . tcPluginInitM ) #endif instance MonadTcPlugin ( TcPluginM Solve ) where liftTcPluginM = TcPluginSolveM