diff options
Diffstat (limited to 'compiler/GHC/Core/Predicate.hs')
-rw-r--r-- | compiler/GHC/Core/Predicate.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/compiler/GHC/Core/Predicate.hs b/compiler/GHC/Core/Predicate.hs index bf6d10f0f7..3de166364b 100644 --- a/compiler/GHC/Core/Predicate.hs +++ b/compiler/GHC/Core/Predicate.hs @@ -30,6 +30,7 @@ module GHC.Core.Predicate ( -- Implicit parameters isIPLikePred, hasIPSuperClasses, isIPTyCon, isIPClass, isCallStackTy, isCallStackPred, isCallStackPredTy, + isIPPred_maybe, -- Evidence variables DictId, isEvVar, isDictId @@ -51,7 +52,9 @@ import GHC.Builtin.Types.Prim ( concretePrimTyCon ) import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic -import GHC.Data.FastString( FastString ) +import GHC.Data.FastString + +import Control.Monad ( guard ) -- | A predicate in the solver. The solver tries to prove Wanted predicates @@ -351,6 +354,15 @@ isCallStackTy ty = False +-- | Decomposes a predicate if it is an implicit parameter. Does not look in +-- superclasses. See also [Local implicit parameters]. +isIPPred_maybe :: Type -> Maybe (FastString, Type) +isIPPred_maybe ty = + do (tc,[t1,t2]) <- splitTyConApp_maybe ty + guard (isIPTyCon tc) + x <- isStrLitTy t1 + return (x,t2) + {- Note [Local implicit parameters] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The function isIPLikePred tells if this predicate, or any of its @@ -380,7 +392,7 @@ Several wrinkles instantiate and check each superclass, one by one, in hasIPSuperClasses. -* With -XRecursiveSuperClasses, the superclass hunt can go on forever, +* With -XUndecidableSuperClasses, the superclass hunt can go on forever, so we need a RecTcChecker to cut it off. * Another apparent additional complexity involves type families. For |