MetaDetails(Flexi, Indirect), MetaInfo(..),
SkolemInfo(..), pprSkolTvBinding, pprSkolInfo,
isImmutableTyVar, isSkolemTyVar, isMetaTyVar, isMetaTyVarTy,
- isSigTyVar, isExistentialTyVar, isTyConableTyVar,
+ isSigTyVar, isOverlappableTyVar, isTyConableTyVar,
metaTvRef,
isFlexi, isIndirect, isUnkSkol, isRuntimeUnkSkol,
| RuntimeUnkSkol -- a type variable used to represent an unknown
-- runtime type (used in the GHCi debugger)
- | NoScSkol -- Used for the "self" superclass when solving
- -- superclasses; don't generate superclasses of me
-
| UnkSkol -- Unhelpful info (until I improve it)
-------------------------------------
sep [pprSkolInfo info,
nest 2 (ptext (sLit "at") <+> ppr (getSrcLoc tv))]]
+instance Outputable SkolemInfo where
+ ppr = pprSkolInfo
+
pprSkolInfo :: SkolemInfo -> SDoc
-- Complete the sentence "is a rigid type variable bound by..."
pprSkolInfo (SigSkol ctxt) = pprUserTypeCtxt ctxt
<+> pprWithCommas ppr ips
pprSkolInfo (ClsSkol cls) = ptext (sLit "the class declaration for") <+> quotes (ppr cls)
pprSkolInfo InstSkol = ptext (sLit "the instance declaration")
-pprSkolInfo NoScSkol = ptext (sLit "the instance declaration (self)")
pprSkolInfo FamInstSkol = ptext (sLit "the family instance declaration")
pprSkolInfo (RuleSkol name) = ptext (sLit "the RULE") <+> doubleQuotes (ftext name)
pprSkolInfo ArrowSkol = ptext (sLit "the arrow form")
| isTcTyVar tv = isSkolemTyVar tv
| otherwise = True
-isTyConableTyVar, isSkolemTyVar, isExistentialTyVar,
+isTyConableTyVar, isSkolemTyVar, isOverlappableTyVar,
isMetaTyVar :: TcTyVar -> Bool
isTyConableTyVar tv
FlatSkol {} -> True
MetaTv {} -> False
-isExistentialTyVar tv -- Existential type variable, bound by a pattern
+-- isOverlappableTyVar has a unique purpose.
+-- See Note [Binding when looking up instances] in InstEnv.
+isOverlappableTyVar tv
= ASSERT( isTcTyVar tv )
case tcTyVarDetails tv of
- SkolemTv (PatSkol {}) -> True
- _ -> False
+ SkolemTv (PatSkol {}) -> True
+ SkolemTv (InstSkol {}) -> True
+ _ -> False
isMetaTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
-- Used in Haskell-98 mode, for the argument types of an instance head
-- These must be a constructor applied to type variable arguments
tcInstHeadTyAppAllTyVars ty
+ | Just ty' <- tcView ty -- Look through synonyms
+ = tcInstHeadTyAppAllTyVars ty'
+ | otherwise
= case ty of
TyConApp _ tys -> ok tys
FunTy arg res -> ok [arg, res]
mkDictTy :: Class -> [Type] -> Type
mkDictTy clas tys = mkPredTy (ClassP clas tys)
-
-
isDictLikeTy :: Type -> Bool
-- Note [Dictionary-like types]
isDictLikeTy ty | Just ty' <- tcView ty = isDictTy ty'