ghc-tcplugins-extra 0.2.4 → 0.2.5
raw patch · 3 files changed
+32/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ GHC.TcPluginM.Extra: flattenGivens :: [Ct] -> [Ct]
+ GHC.TcPluginM.Extra: mkSubst :: Ct -> Maybe (TcTyVar, TcType)
+ GHC.TcPluginM.Extra: mkSubst' :: [Ct] -> [(TcTyVar, TcType)]
+ GHC.TcPluginM.Extra: substCt :: [(TcTyVar, TcType)] -> Ct -> Ct
+ GHC.TcPluginM.Extra: substType :: [(TcTyVar, TcType)] -> TcType -> TcType
Files
- CHANGELOG.md +3/−0
- ghc-tcplugins-extra.cabal +3/−2
- src/GHC/TcPluginM/Extra.hs +26/−3
CHANGELOG.md view
@@ -1,3 +1,6 @@+## 0.2.5 *April 15th 2018*+* Support for GHC-8.5.20180306+ ## 0.2.4 *March 17th 2018* * Fix exports
ghc-tcplugins-extra.cabal view
@@ -1,5 +1,5 @@ name: ghc-tcplugins-extra-version: 0.2.4+version: 0.2.5 synopsis: Utilities for writing GHC type-checker plugins description: Utilities for writing GHC type-checker plugins, such as creating constraints, with a stable API covering multiple@@ -17,7 +17,8 @@ extra-source-files: README.md CHANGELOG.md cabal-version: >=1.10-tested-with: GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1+tested-with: GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1,+ GHC == 8.4.2, GHC == 8.5 source-repository head type: git
src/GHC/TcPluginM/Extra.hs view
@@ -30,7 +30,7 @@ -- * Trace state of the plugin , tracePlugin #if __GLASGOW_HASKELL__ >= 804- -- * Substitutions+ -- * Substitutions (GHC 8.4+) , flattenGivens , mkSubst , mkSubst'@@ -49,6 +49,9 @@ #if __GLASGOW_HASKELL__ < 711 import BasicTypes (TopLevelFlag (..)) #endif+#if MIN_VERSION_ghc(8,5,0)+import CoreSyn (Expr(..))+#endif import Coercion (Role (..), mkUnivCo) import FastString (FastString, fsLit) import Module (Module, ModuleName)@@ -147,7 +150,10 @@ -- | Create a new [G]iven constraint, with the supplied evidence. This must not -- be invoked from 'tcPluginInit' or 'tcPluginStop', or it will panic. newGiven :: CtLoc -> PredType -> EvTerm -> TcPluginM CtEvidence-#if __GLASGOW_HASKELL__ >= 711+#if MIN_VERSION_ghc(8,5,0)+newGiven loc pty (EvExpr ev) = TcPluginM.newGiven loc pty ev+newGiven _ _ ev = panicDoc "newGiven: not an EvExpr: " (ppr ev)+#elif __GLASGOW_HASKELL__ >= 711 newGiven = TcPluginM.newGiven #else newGiven loc pty evtm = return@@ -173,10 +179,16 @@ -> Type -- ^ The LHS of the equivalence relation (~) -> Type -- ^ The RHS of the equivalence relation (~) -> EvTerm-evByFiat name t1 t2 = EvCoercion+evByFiat name t1 t2 =+#if MIN_VERSION_ghc(8,5,0)+ EvExpr+ $ Coercion+#else+ EvCoercion #if __GLASGOW_HASKELL__ < 711 $ TcCoercion #endif+#endif $ mkUnivCo #if __GLASGOW_HASKELL__ >= 711 (PluginProv name)@@ -277,7 +289,10 @@ -- | Flattens evidence of constraints by substituting each others equalities. -- -- __NB:__ Should only be used on /[G]iven/ constraints!+-- -- __NB:__ Doesn't flatten under binders+--+-- __NB:__ Only available on GHC 8.4+ flattenGivens :: [Ct] -> [Ct]@@ -287,12 +302,16 @@ -- | Create flattened substitutions from type equalities, i.e. the substitutions -- have been applied to each others right hand sides.+--+-- __NB:__ Only available on GHC 8.4+ mkSubst' :: [Ct] -> [(TcTyVar,TcType)] mkSubst' = foldr substSubst [] . mapMaybe mkSubst where substSubst (tv,t) s = (tv,substType s t) : map (second (substType [(tv,t)])) s -- | Create simple substitution from type equalities+--+-- __NB:__ Only available on GHC 8.4+ mkSubst :: Ct -> Maybe (TcTyVar, TcType)@@ -301,6 +320,8 @@ mkSubst _ = Nothing -- | Apply substitution in the evidence of Cts+--+-- __NB:__ Only available on GHC 8.4+ substCt :: [(TcTyVar, TcType)] -> Ct@@ -312,6 +333,8 @@ -- | Apply substitutions in Types -- -- __NB:__ Doesn't substitute under binders+--+-- __NB:__ Only available on GHC 8.4+ substType :: [(TcTyVar, TcType)] -> TcType