{-# LANGUAGE CPP, ExistentialQuantification, GeneralizedNewtypeDeriving,
ViewPatterns #-}
module TcRnTypes(
TcRnIf, TcRn, TcM, RnM, IfM, IfL, IfG,
TcRef,
Env(..),
TcGblEnv(..), TcLclEnv(..),
IfGblEnv(..), IfLclEnv(..),
tcVisibleOrphanMods,
FrontendResult(..),
ErrCtxt, RecFieldEnv,
ImportAvails(..), emptyImportAvails, plusImportAvails,
WhereFrom(..), mkModDeps, modDepsElts,
TcTypeEnv, TcBinderStack, TcBinder(..),
TcTyThing(..), PromotionErr(..),
IdBindingInfo(..), ClosedTypeId, RhsNames,
IsGroupClosed(..),
SelfBootInfo(..),
pprTcTyThingCategory, pprPECategory, CompleteMatch(..),
DsM, DsLclEnv(..), DsGblEnv(..),
DsMetaEnv, DsMetaVal(..), CompleteMatchMap,
mkCompleteMatchMap, extendCompleteMatchMap,
ThStage(..), SpliceType(..), PendingStuff(..),
topStage, topAnnStage, topSpliceStage,
ThLevel, impLevel, outerLevel, thLevel,
ForeignSrcLang(..),
ArrowCtxt(..),
TcSigFun, TcSigInfo(..), TcIdSigInfo(..),
TcIdSigInst(..), TcPatSynInfo(..),
isPartialSig, hasCompleteSig,
QCInst(..), isPendingScInst,
Xi, Ct(..), Cts, emptyCts, andCts, andManyCts, pprCts,
singleCt, listToCts, ctsElts, consCts, snocCts, extendCtsList,
isEmptyCts, isCTyEqCan, isCFunEqCan,
isPendingScDict, superClassesMightHelp, getPendingWantedScs,
isCDictCan_Maybe, isCFunEqCan_maybe,
isCNonCanonical, isWantedCt, isDerivedCt,
isGivenCt, isHoleCt, isOutOfScopeCt, isExprHoleCt, isTypeHoleCt,
isUserTypeErrorCt, getUserTypeErrorMsg,
ctEvidence, ctLoc, setCtLoc, ctPred, ctFlavour, ctEqRel, ctOrigin,
ctEvId, mkTcEqPredLikeEv,
mkNonCanonical, mkNonCanonicalCt, mkGivens,
mkIrredCt, mkInsolubleCt,
ctEvPred, ctEvLoc, ctEvOrigin, ctEvEqRel,
ctEvExpr, ctEvTerm, ctEvCoercion, ctEvEvId,
tyCoVarsOfCt, tyCoVarsOfCts,
tyCoVarsOfCtList, tyCoVarsOfCtsList,
WantedConstraints(..), insolubleWC, emptyWC, isEmptyWC,
isSolvedWC, andWC, unionsWC, mkSimpleWC, mkImplicWC,
addInsols, insolublesOnly, addSimples, addImplics,
tyCoVarsOfWC, dropDerivedWC, dropDerivedSimples,
tyCoVarsOfWCList, insolubleCt, insolubleEqCt,
isDroppableCt, insolubleImplic,
arisesFromGivens,
Implication(..), newImplication, implicationPrototype,
implicLclEnv, implicDynFlags,
ImplicStatus(..), isInsolubleStatus, isSolvedStatus,
SubGoalDepth, initialSubGoalDepth, maxSubGoalDepth,
bumpSubGoalDepth, subGoalDepthExceeded,
CtLoc(..), ctLocSpan, ctLocEnv, ctLocLevel, ctLocOrigin,
ctLocTypeOrKind_maybe,
ctLocDepth, bumpCtLocDepth, isGivenLoc,
setCtLocOrigin, updateCtLocOrigin, setCtLocEnv, setCtLocSpan,
CtOrigin(..), exprCtOrigin, lexprCtOrigin, matchesCtOrigin, grhssCtOrigin,
isVisibleOrigin, toInvisibleOrigin,
TypeOrKind(..), isTypeLevel, isKindLevel,
pprCtOrigin, pprCtLoc,
pushErrCtxt, pushErrCtxtSameOrigin,
SkolemInfo(..), pprSigSkolInfo, pprSkolInfo,
CtEvidence(..), TcEvDest(..),
mkKindLoc, toKindLoc, mkGivenLoc,
isWanted, isGiven, isDerived, isGivenOrWDeriv,
ctEvRole,
wrapType, wrapTypeWithImplication,
removeBindingShadowing,
TcPlugin(..), TcPluginResult(..), TcPluginSolver,
TcPluginM, runTcPluginM, unsafeTcPluginTcM,
getEvBindsTcPluginM,
CtFlavour(..), ShadowInfo(..), ctEvFlavour,
CtFlavourRole, ctEvFlavourRole, ctFlavourRole,
eqCanRewrite, eqCanRewriteFR, eqMayRewriteFR,
eqCanDischargeFR,
funEqCanDischarge, funEqCanDischargeF,
pprEvVarTheta,
pprEvVars, pprEvVarWithType,
TcId, TcIdSet,
Hole(..), holeOcc,
NameShape(..),
RoleAnnotEnv, emptyRoleAnnotEnv, mkRoleAnnotEnv,
lookupRoleAnnot, getRoleAnnots,
) where
#include "HsVersions.h"
import GhcPrelude
import HsSyn
import CoreSyn
import HscTypes
import TcEvidence
import Type
import Class ( Class )
import TyCon ( TyCon, TyConFlavour, tyConKind )
import TyCoRep ( coHoleCoVar )
import Coercion ( Coercion, mkHoleCo )
import ConLike ( ConLike(..) )
import DataCon ( DataCon, dataConUserType, dataConOrigArgTys )
import PatSyn ( PatSyn, pprPatSynType )
import Id ( idType, idName )
import FieldLabel ( FieldLabel )
import TcType
import Annotations
import InstEnv
import FamInstEnv
import PmExpr
import IOEnv
import RdrName
import Name
import NameEnv
import NameSet
import Avail
import Var
import FV
import VarEnv
import Module
import SrcLoc
import VarSet
import ErrUtils
import UniqFM
import UniqSupply
import BasicTypes
import Bag
import DynFlags
import Outputable
import ListSetOps
import FastString
import qualified GHC.LanguageExtensions as LangExt
import Fingerprint
import Util
import PrelNames ( isUnboundName )
import CostCentreState
import Control.Monad (ap, liftM, msum)
import qualified Control.Monad.Fail as MonadFail
import Data.Set ( Set )
import qualified Data.Set as S
import Data.List ( sort )
import Data.Map ( Map )
import Data.Dynamic ( Dynamic )
import Data.Typeable ( TypeRep )
import Data.Maybe ( mapMaybe )
import GHCi.Message
import GHCi.RemoteTypes
import qualified Language.Haskell.TH as TH
data NameShape = NameShape {
NameShape -> ModuleName
ns_mod_name :: ModuleName,
NameShape -> [AvailInfo]
ns_exports :: [AvailInfo],
NameShape -> OccEnv Name
ns_map :: OccEnv Name
}
type TcRnIf a b = IOEnv (Env a b)
type TcRn = TcRnIf TcGblEnv TcLclEnv
type IfM lcl = TcRnIf IfGblEnv lcl
type IfG = IfM ()
type IfL = IfM IfLclEnv
type DsM = TcRnIf DsGblEnv DsLclEnv
type RnM = TcRn
type TcM = TcRn
data Env gbl lcl
= Env {
Env gbl lcl -> HscEnv
env_top :: !HscEnv,
Env gbl lcl -> IORef UniqSupply
env_us :: {-# UNPACK #-} !(IORef UniqSupply),
Env gbl lcl -> gbl
env_gbl :: gbl,
Env gbl lcl -> lcl
env_lcl :: lcl
}
instance ContainsDynFlags (Env gbl lcl) where
extractDynFlags :: Env gbl lcl -> DynFlags
extractDynFlags env :: Env gbl lcl
env = HscEnv -> DynFlags
hsc_dflags (Env gbl lcl -> HscEnv
forall gbl lcl. Env gbl lcl -> HscEnv
env_top Env gbl lcl
env)
instance ContainsModule gbl => ContainsModule (Env gbl lcl) where
extractModule :: Env gbl lcl -> Module
extractModule env :: Env gbl lcl
env = gbl -> Module
forall t. ContainsModule t => t -> Module
extractModule (Env gbl lcl -> gbl
forall gbl lcl. Env gbl lcl -> gbl
env_gbl Env gbl lcl
env)
data IfGblEnv
= IfGblEnv {
IfGblEnv -> SDoc
if_doc :: SDoc,
IfGblEnv -> Maybe (Module, IfG TypeEnv)
if_rec_types :: Maybe (Module, IfG TypeEnv)
}
data IfLclEnv
= IfLclEnv {
IfLclEnv -> Module
if_mod :: Module,
IfLclEnv -> Bool
if_boot :: Bool,
IfLclEnv -> SDoc
if_loc :: SDoc,
IfLclEnv -> Maybe NameShape
if_nsubst :: Maybe NameShape,
IfLclEnv -> Maybe TypeEnv
if_implicits_env :: Maybe TypeEnv,
IfLclEnv -> FastStringEnv TyVar
if_tv_env :: FastStringEnv TyVar,
IfLclEnv -> FastStringEnv TyVar
if_id_env :: FastStringEnv Id
}
data DsGblEnv
= DsGblEnv
{ DsGblEnv -> Module
ds_mod :: Module
, DsGblEnv -> FamInstEnv
ds_fam_inst_env :: FamInstEnv
, DsGblEnv -> PrintUnqualified
ds_unqual :: PrintUnqualified
, DsGblEnv -> IORef Messages
ds_msgs :: IORef Messages
, DsGblEnv -> (IfGblEnv, IfLclEnv)
ds_if_env :: (IfGblEnv, IfLclEnv)
, DsGblEnv -> CompleteMatchMap
ds_complete_matches :: CompleteMatchMap
, DsGblEnv -> IORef CostCentreState
ds_cc_st :: IORef CostCentreState
}
instance ContainsModule DsGblEnv where
extractModule :: DsGblEnv -> Module
extractModule = DsGblEnv -> Module
ds_mod
data DsLclEnv = DsLclEnv {
DsLclEnv -> DsMetaEnv
dsl_meta :: DsMetaEnv,
DsLclEnv -> RealSrcSpan
dsl_loc :: RealSrcSpan,
DsLclEnv -> Bag TyVar
dsl_dicts :: Bag EvVar,
DsLclEnv -> Bag SimpleEq
dsl_tm_cs :: Bag SimpleEq,
DsLclEnv -> IORef Int
dsl_pm_iter :: IORef Int
}
type DsMetaEnv = NameEnv DsMetaVal
data DsMetaVal
= DsBound Id
| DsSplice (HsExpr GhcTc)
data FrontendResult
= FrontendTypecheck TcGblEnv
data TcGblEnv
= TcGblEnv {
TcGblEnv -> Module
tcg_mod :: Module,
TcGblEnv -> Module
tcg_semantic_mod :: Module,
TcGblEnv -> HscSource
tcg_src :: HscSource,
TcGblEnv -> GlobalRdrEnv
tcg_rdr_env :: GlobalRdrEnv,
TcGblEnv -> Maybe [Type]
tcg_default :: Maybe [Type],
TcGblEnv -> FixityEnv
tcg_fix_env :: FixityEnv,
TcGblEnv -> RecFieldEnv
tcg_field_env :: RecFieldEnv,
TcGblEnv -> TypeEnv
tcg_type_env :: TypeEnv,
TcGblEnv -> TcRef TypeEnv
tcg_type_env_var :: TcRef TypeEnv,
TcGblEnv -> InstEnv
tcg_inst_env :: !InstEnv,
TcGblEnv -> FamInstEnv
tcg_fam_inst_env :: !FamInstEnv,
TcGblEnv -> AnnEnv
tcg_ann_env :: AnnEnv,
TcGblEnv -> [AvailInfo]
tcg_exports :: [AvailInfo],
TcGblEnv -> ImportAvails
tcg_imports :: ImportAvails,
TcGblEnv -> DefUses
tcg_dus :: DefUses,
TcGblEnv -> TcRef [GlobalRdrElt]
tcg_used_gres :: TcRef [GlobalRdrElt],
TcGblEnv -> TcRef NameSet
tcg_keep :: TcRef NameSet,
TcGblEnv -> TcRef Bool
tcg_th_used :: TcRef Bool,
TcGblEnv -> TcRef Bool
tcg_th_splice_used :: TcRef Bool,
TcGblEnv -> TcRef (Set RealSrcSpan)
tcg_th_top_level_locs :: TcRef (Set RealSrcSpan),
TcGblEnv -> TcRef OccSet
tcg_dfun_n :: TcRef OccSet,
TcGblEnv -> [(Module, Fingerprint)]
tcg_merged :: [(Module, Fingerprint)],
TcGblEnv -> Maybe [(Located (IE GhcRn), [AvailInfo])]
tcg_rn_exports :: Maybe [(Located (IE GhcRn), Avails)],
TcGblEnv -> [LImportDecl GhcRn]
tcg_rn_imports :: [LImportDecl GhcRn],
TcGblEnv -> Maybe (HsGroup GhcRn)
tcg_rn_decls :: Maybe (HsGroup GhcRn),
TcGblEnv -> TcRef [FilePath]
tcg_dependent_files :: TcRef [FilePath],
TcGblEnv -> TcRef [LHsDecl GhcPs]
tcg_th_topdecls :: TcRef [LHsDecl GhcPs],
TcGblEnv -> TcRef [(ForeignSrcLang, FilePath)]
tcg_th_foreign_files :: TcRef [(ForeignSrcLang, FilePath)],
TcGblEnv -> TcRef NameSet
tcg_th_topnames :: TcRef NameSet,
TcGblEnv -> TcRef [(TcLclEnv, ThModFinalizers)]
tcg_th_modfinalizers :: TcRef [(TcLclEnv, ThModFinalizers)],
TcGblEnv -> TcRef [FilePath]
tcg_th_coreplugins :: TcRef [String],
TcGblEnv -> TcRef (Map TypeRep Dynamic)
tcg_th_state :: TcRef (Map TypeRep Dynamic),
TcGblEnv -> TcRef (Maybe (ForeignRef (IORef QState)))
tcg_th_remote_state :: TcRef (Maybe (ForeignRef (IORef QState))),
TcGblEnv -> Bag EvBind
tcg_ev_binds :: Bag EvBind,
TcGblEnv -> Maybe TyVar
tcg_tr_module :: Maybe Id,
TcGblEnv -> LHsBinds GhcTc
tcg_binds :: LHsBinds GhcTc,
TcGblEnv -> NameSet
tcg_sigs :: NameSet,
TcGblEnv -> [LTcSpecPrag]
tcg_imp_specs :: [LTcSpecPrag],
TcGblEnv -> Warnings
tcg_warns :: Warnings,
TcGblEnv -> [Annotation]
tcg_anns :: [Annotation],
TcGblEnv -> [TyCon]
tcg_tcs :: [TyCon],
TcGblEnv -> [ClsInst]
tcg_insts :: [ClsInst],
TcGblEnv -> [FamInst]
tcg_fam_insts :: [FamInst],
TcGblEnv -> [LRuleDecl GhcTc]
tcg_rules :: [LRuleDecl GhcTc],
TcGblEnv -> [LForeignDecl GhcTc]
tcg_fords :: [LForeignDecl GhcTc],
TcGblEnv -> [PatSyn]
tcg_patsyns :: [PatSyn],
TcGblEnv -> Maybe LHsDocString
tcg_doc_hdr :: Maybe LHsDocString,
TcGblEnv -> Bool
tcg_hpc :: !AnyHpcUsage,
TcGblEnv -> SelfBootInfo
tcg_self_boot :: SelfBootInfo,
TcGblEnv -> Maybe Name
tcg_main :: Maybe Name,
TcGblEnv -> TcRef (Bool, WarningMessages)
tcg_safeInfer :: TcRef (Bool, WarningMessages),
TcGblEnv -> [TcPluginSolver]
tcg_tc_plugins :: [TcPluginSolver],
TcGblEnv -> RealSrcSpan
tcg_top_loc :: RealSrcSpan,
TcGblEnv -> TcRef WantedConstraints
tcg_static_wc :: TcRef WantedConstraints,
TcGblEnv -> [CompleteMatch]
tcg_complete_matches :: [CompleteMatch],
TcGblEnv -> IORef CostCentreState
tcg_cc_st :: TcRef CostCentreState
}
tcVisibleOrphanMods :: TcGblEnv -> ModuleSet
tcVisibleOrphanMods :: TcGblEnv -> ModuleSet
tcVisibleOrphanMods tcg_env :: TcGblEnv
tcg_env
= [Module] -> ModuleSet
mkModuleSet (TcGblEnv -> Module
tcg_mod TcGblEnv
tcg_env Module -> [Module] -> [Module]
forall a. a -> [a] -> [a]
: ImportAvails -> [Module]
imp_orphs (TcGblEnv -> ImportAvails
tcg_imports TcGblEnv
tcg_env))
instance ContainsModule TcGblEnv where
extractModule :: TcGblEnv -> Module
extractModule env :: TcGblEnv
env = TcGblEnv -> Module
tcg_semantic_mod TcGblEnv
env
type RecFieldEnv = NameEnv [FieldLabel]
data SelfBootInfo
= NoSelfBoot
| SelfBoot
{ SelfBootInfo -> ModDetails
sb_mds :: ModDetails
, SelfBootInfo -> NameSet
sb_tcs :: NameSet }
data TcLclEnv
= TcLclEnv {
TcLclEnv -> RealSrcSpan
tcl_loc :: RealSrcSpan,
TcLclEnv -> [ErrCtxt]
tcl_ctxt :: [ErrCtxt],
TcLclEnv -> TcLevel
tcl_tclvl :: TcLevel,
TcLclEnv -> ThStage
tcl_th_ctxt :: ThStage,
TcLclEnv -> ThBindEnv
tcl_th_bndrs :: ThBindEnv,
TcLclEnv -> ArrowCtxt
tcl_arrow_ctxt :: ArrowCtxt,
TcLclEnv -> LocalRdrEnv
tcl_rdr :: LocalRdrEnv,
TcLclEnv -> TcTypeEnv
tcl_env :: TcTypeEnv,
TcLclEnv -> TcBinderStack
tcl_bndrs :: TcBinderStack,
TcLclEnv -> TcRef TcTyVarSet
tcl_tyvars :: TcRef TcTyVarSet,
TcLclEnv -> TcRef WantedConstraints
tcl_lie :: TcRef WantedConstraints,
TcLclEnv -> IORef Messages
tcl_errs :: TcRef Messages
}
type ErrCtxt = (Bool, TidyEnv -> TcM (TidyEnv, MsgDoc))
type TcTypeEnv = NameEnv TcTyThing
type ThBindEnv = NameEnv (TopLevelFlag, ThLevel)
type TcRef a = IORef a
type TcId = Id
type TcIdSet = IdSet
type TcBinderStack = [TcBinder]
data TcBinder
= TcIdBndr
TcId
TopLevelFlag
| TcIdBndr_ExpType
Name
ExpType
TopLevelFlag
| TcTvBndr
Name
TyVar
instance Outputable TcBinder where
ppr :: TcBinder -> SDoc
ppr (TcIdBndr id :: TyVar
id top_lvl :: TopLevelFlag
top_lvl) = TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
id SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
brackets (TopLevelFlag -> SDoc
forall a. Outputable a => a -> SDoc
ppr TopLevelFlag
top_lvl)
ppr (TcIdBndr_ExpType id :: Name
id _ top_lvl :: TopLevelFlag
top_lvl) = Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
id SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
brackets (TopLevelFlag -> SDoc
forall a. Outputable a => a -> SDoc
ppr TopLevelFlag
top_lvl)
ppr (TcTvBndr name :: Name
name tv :: TyVar
tv) = Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name SDoc -> SDoc -> SDoc
<+> TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
tv
instance HasOccName TcBinder where
occName :: TcBinder -> OccName
occName (TcIdBndr id :: TyVar
id _) = Name -> OccName
forall name. HasOccName name => name -> OccName
occName (TyVar -> Name
idName TyVar
id)
occName (TcIdBndr_ExpType name :: Name
name _ _) = Name -> OccName
forall name. HasOccName name => name -> OccName
occName Name
name
occName (TcTvBndr name :: Name
name _) = Name -> OccName
forall name. HasOccName name => name -> OccName
occName Name
name
removeBindingShadowing :: HasOccName a => [a] -> [a]
removeBindingShadowing :: [a] -> [a]
removeBindingShadowing bindings :: [a]
bindings = [a] -> [a]
forall a. [a] -> [a]
reverse ([a] -> [a]) -> [a] -> [a]
forall a b. (a -> b) -> a -> b
$ ([a], OccSet) -> [a]
forall a b. (a, b) -> a
fst (([a], OccSet) -> [a]) -> ([a], OccSet) -> [a]
forall a b. (a -> b) -> a -> b
$ (([a], OccSet) -> a -> ([a], OccSet))
-> ([a], OccSet) -> [a] -> ([a], OccSet)
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl
(\(bindingAcc :: [a]
bindingAcc, seenNames :: OccSet
seenNames) binding :: a
binding ->
if a -> OccName
forall name. HasOccName name => name -> OccName
occName a
binding OccName -> OccSet -> Bool
`elemOccSet` OccSet
seenNames
then ([a]
bindingAcc, OccSet
seenNames)
else (a
bindinga -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bindingAcc, OccSet -> OccName -> OccSet
extendOccSet OccSet
seenNames (a -> OccName
forall name. HasOccName name => name -> OccName
occName a
binding)))
([], OccSet
emptyOccSet) [a]
bindings
data SpliceType = Typed | Untyped
data ThStage
= Splice SpliceType
| RunSplice (TcRef [ForeignRef (TH.Q ())])
| Comp
| Brack
ThStage
PendingStuff
data PendingStuff
= RnPendingUntyped
(TcRef [PendingRnSplice])
| RnPendingTyped
| TcPending
(TcRef [PendingTcSplice])
(TcRef WantedConstraints)
topStage, topAnnStage, topSpliceStage :: ThStage
topStage :: ThStage
topStage = ThStage
Comp
topAnnStage :: ThStage
topAnnStage = SpliceType -> ThStage
Splice SpliceType
Untyped
topSpliceStage :: ThStage
topSpliceStage = SpliceType -> ThStage
Splice SpliceType
Untyped
instance Outputable ThStage where
ppr :: ThStage -> SDoc
ppr (Splice _) = FilePath -> SDoc
text "Splice"
ppr (RunSplice _) = FilePath -> SDoc
text "RunSplice"
ppr Comp = FilePath -> SDoc
text "Comp"
ppr (Brack s :: ThStage
s _) = FilePath -> SDoc
text "Brack" SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
parens (ThStage -> SDoc
forall a. Outputable a => a -> SDoc
ppr ThStage
s)
type ThLevel = Int
impLevel, outerLevel :: ThLevel
impLevel :: Int
impLevel = 0
outerLevel :: Int
outerLevel = 1
thLevel :: ThStage -> ThLevel
thLevel :: ThStage -> Int
thLevel (Splice _) = 0
thLevel (RunSplice _) =
FilePath -> Int
forall a. FilePath -> a
panic "thLevel: called when running a splice"
thLevel Comp = 1
thLevel (Brack s :: ThStage
s _) = ThStage -> Int
thLevel ThStage
s Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1
data ArrowCtxt
= NoArrowCtxt
| ArrowCtxt LocalRdrEnv (TcRef WantedConstraints)
data TcTyThing
= AGlobal TyThing
| ATcId
{ TcTyThing -> TyVar
tct_id :: TcId
, TcTyThing -> IdBindingInfo
tct_info :: IdBindingInfo
}
| ATyVar Name TcTyVar
| ATcTyCon TyCon
| APromotionErr PromotionErr
data PromotionErr
= TyConPE
| ClassPE
| FamDataConPE
| ConstrainedDataConPE PredType
| PatSynPE
| PatSynExPE
| RecDataConPE
| NoDataKindsTC
| NoDataKindsDC
instance Outputable TcTyThing where
ppr :: TcTyThing -> SDoc
ppr (AGlobal g :: TyThing
g) = TyThing -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyThing
g
ppr elt :: TcTyThing
elt@(ATcId {}) = FilePath -> SDoc
text "Identifier" SDoc -> SDoc -> SDoc
<>
SDoc -> SDoc
brackets (TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr (TcTyThing -> TyVar
tct_id TcTyThing
elt) SDoc -> SDoc -> SDoc
<> SDoc
dcolon
SDoc -> SDoc -> SDoc
<> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr (TyVar -> Type
varType (TcTyThing -> TyVar
tct_id TcTyThing
elt)) SDoc -> SDoc -> SDoc
<> SDoc
comma
SDoc -> SDoc -> SDoc
<+> IdBindingInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr (TcTyThing -> IdBindingInfo
tct_info TcTyThing
elt))
ppr (ATyVar n :: Name
n tv :: TyVar
tv) = FilePath -> SDoc
text "Type variable" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
n) SDoc -> SDoc -> SDoc
<+> SDoc
equals SDoc -> SDoc -> SDoc
<+> TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
tv
SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr (TyVar -> Type
varType TyVar
tv)
ppr (ATcTyCon tc :: TyCon
tc) = FilePath -> SDoc
text "ATcTyCon" SDoc -> SDoc -> SDoc
<+> TyCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyCon
tc SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr (TyCon -> Type
tyConKind TyCon
tc)
ppr (APromotionErr err :: PromotionErr
err) = FilePath -> SDoc
text "APromotionErr" SDoc -> SDoc -> SDoc
<+> PromotionErr -> SDoc
forall a. Outputable a => a -> SDoc
ppr PromotionErr
err
data IdBindingInfo
= NotLetBound
| ClosedLet
| NonClosedLet
RhsNames
ClosedTypeId
data IsGroupClosed
= IsGroupClosed
(NameEnv RhsNames)
ClosedTypeId
type RhsNames = NameSet
type ClosedTypeId = Bool
instance Outputable IdBindingInfo where
ppr :: IdBindingInfo -> SDoc
ppr NotLetBound = FilePath -> SDoc
text "NotLetBound"
ppr ClosedLet = FilePath -> SDoc
text "TopLevelLet"
ppr (NonClosedLet fvs :: NameSet
fvs closed_type :: Bool
closed_type) =
FilePath -> SDoc
text "TopLevelLet" SDoc -> SDoc -> SDoc
<+> NameSet -> SDoc
forall a. Outputable a => a -> SDoc
ppr NameSet
fvs SDoc -> SDoc -> SDoc
<+> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
closed_type
instance Outputable PromotionErr where
ppr :: PromotionErr -> SDoc
ppr ClassPE = FilePath -> SDoc
text "ClassPE"
ppr TyConPE = FilePath -> SDoc
text "TyConPE"
ppr PatSynPE = FilePath -> SDoc
text "PatSynPE"
ppr PatSynExPE = FilePath -> SDoc
text "PatSynExPE"
ppr FamDataConPE = FilePath -> SDoc
text "FamDataConPE"
ppr (ConstrainedDataConPE pred :: Type
pred) = FilePath -> SDoc
text "ConstrainedDataConPE"
SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
pred)
ppr RecDataConPE = FilePath -> SDoc
text "RecDataConPE"
ppr NoDataKindsTC = FilePath -> SDoc
text "NoDataKindsTC"
ppr NoDataKindsDC = FilePath -> SDoc
text "NoDataKindsDC"
pprTcTyThingCategory :: TcTyThing -> SDoc
pprTcTyThingCategory :: TcTyThing -> SDoc
pprTcTyThingCategory (AGlobal thing :: TyThing
thing) = TyThing -> SDoc
pprTyThingCategory TyThing
thing
pprTcTyThingCategory (ATyVar {}) = FilePath -> SDoc
text "Type variable"
pprTcTyThingCategory (ATcId {}) = FilePath -> SDoc
text "Local identifier"
pprTcTyThingCategory (ATcTyCon {}) = FilePath -> SDoc
text "Local tycon"
pprTcTyThingCategory (APromotionErr pe :: PromotionErr
pe) = PromotionErr -> SDoc
pprPECategory PromotionErr
pe
pprPECategory :: PromotionErr -> SDoc
pprPECategory :: PromotionErr -> SDoc
pprPECategory ClassPE = FilePath -> SDoc
text "Class"
pprPECategory TyConPE = FilePath -> SDoc
text "Type constructor"
pprPECategory PatSynPE = FilePath -> SDoc
text "Pattern synonym"
pprPECategory PatSynExPE = FilePath -> SDoc
text "Pattern synonym existential"
pprPECategory FamDataConPE = FilePath -> SDoc
text "Data constructor"
pprPECategory ConstrainedDataConPE{} = FilePath -> SDoc
text "Data constructor"
pprPECategory RecDataConPE = FilePath -> SDoc
text "Data constructor"
pprPECategory NoDataKindsTC = FilePath -> SDoc
text "Type constructor"
pprPECategory NoDataKindsDC = FilePath -> SDoc
text "Data constructor"
data ImportAvails
= ImportAvails {
ImportAvails -> ImportedMods
imp_mods :: ImportedMods,
ImportAvails -> ModuleNameEnv (ModuleName, Bool)
imp_dep_mods :: ModuleNameEnv (ModuleName, IsBootInterface),
ImportAvails -> Set InstalledUnitId
imp_dep_pkgs :: Set InstalledUnitId,
ImportAvails -> Set InstalledUnitId
imp_trust_pkgs :: Set InstalledUnitId,
ImportAvails -> Bool
imp_trust_own_pkg :: Bool,
ImportAvails -> [Module]
imp_orphs :: [Module],
ImportAvails -> [Module]
imp_finsts :: [Module]
}
mkModDeps :: [(ModuleName, IsBootInterface)]
-> ModuleNameEnv (ModuleName, IsBootInterface)
mkModDeps :: [(ModuleName, Bool)] -> ModuleNameEnv (ModuleName, Bool)
mkModDeps deps :: [(ModuleName, Bool)]
deps = (ModuleNameEnv (ModuleName, Bool)
-> (ModuleName, Bool) -> ModuleNameEnv (ModuleName, Bool))
-> ModuleNameEnv (ModuleName, Bool)
-> [(ModuleName, Bool)]
-> ModuleNameEnv (ModuleName, Bool)
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ModuleNameEnv (ModuleName, Bool)
-> (ModuleName, Bool) -> ModuleNameEnv (ModuleName, Bool)
forall key b.
Uniquable key =>
UniqFM (key, b) -> (key, b) -> UniqFM (key, b)
add ModuleNameEnv (ModuleName, Bool)
forall elt. UniqFM elt
emptyUFM [(ModuleName, Bool)]
deps
where
add :: UniqFM (key, b) -> (key, b) -> UniqFM (key, b)
add env :: UniqFM (key, b)
env elt :: (key, b)
elt@(m :: key
m,_) = UniqFM (key, b) -> key -> (key, b) -> UniqFM (key, b)
forall key elt.
Uniquable key =>
UniqFM elt -> key -> elt -> UniqFM elt
addToUFM UniqFM (key, b)
env key
m (key, b)
elt
modDepsElts
:: ModuleNameEnv (ModuleName, IsBootInterface)
-> [(ModuleName, IsBootInterface)]
modDepsElts :: ModuleNameEnv (ModuleName, Bool) -> [(ModuleName, Bool)]
modDepsElts = [(ModuleName, Bool)] -> [(ModuleName, Bool)]
forall a. Ord a => [a] -> [a]
sort ([(ModuleName, Bool)] -> [(ModuleName, Bool)])
-> (ModuleNameEnv (ModuleName, Bool) -> [(ModuleName, Bool)])
-> ModuleNameEnv (ModuleName, Bool)
-> [(ModuleName, Bool)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ModuleNameEnv (ModuleName, Bool) -> [(ModuleName, Bool)]
forall elt. UniqFM elt -> [elt]
nonDetEltsUFM
emptyImportAvails :: ImportAvails
emptyImportAvails :: ImportAvails
emptyImportAvails = ImportAvails :: ImportedMods
-> ModuleNameEnv (ModuleName, Bool)
-> Set InstalledUnitId
-> Set InstalledUnitId
-> Bool
-> [Module]
-> [Module]
-> ImportAvails
ImportAvails { imp_mods :: ImportedMods
imp_mods = ImportedMods
forall a. ModuleEnv a
emptyModuleEnv,
imp_dep_mods :: ModuleNameEnv (ModuleName, Bool)
imp_dep_mods = ModuleNameEnv (ModuleName, Bool)
forall elt. UniqFM elt
emptyUFM,
imp_dep_pkgs :: Set InstalledUnitId
imp_dep_pkgs = Set InstalledUnitId
forall a. Set a
S.empty,
imp_trust_pkgs :: Set InstalledUnitId
imp_trust_pkgs = Set InstalledUnitId
forall a. Set a
S.empty,
imp_trust_own_pkg :: Bool
imp_trust_own_pkg = Bool
False,
imp_orphs :: [Module]
imp_orphs = [],
imp_finsts :: [Module]
imp_finsts = [] }
plusImportAvails :: ImportAvails -> ImportAvails -> ImportAvails
plusImportAvails :: ImportAvails -> ImportAvails -> ImportAvails
plusImportAvails
(ImportAvails { imp_mods :: ImportAvails -> ImportedMods
imp_mods = ImportedMods
mods1,
imp_dep_mods :: ImportAvails -> ModuleNameEnv (ModuleName, Bool)
imp_dep_mods = ModuleNameEnv (ModuleName, Bool)
dmods1, imp_dep_pkgs :: ImportAvails -> Set InstalledUnitId
imp_dep_pkgs = Set InstalledUnitId
dpkgs1,
imp_trust_pkgs :: ImportAvails -> Set InstalledUnitId
imp_trust_pkgs = Set InstalledUnitId
tpkgs1, imp_trust_own_pkg :: ImportAvails -> Bool
imp_trust_own_pkg = Bool
tself1,
imp_orphs :: ImportAvails -> [Module]
imp_orphs = [Module]
orphs1, imp_finsts :: ImportAvails -> [Module]
imp_finsts = [Module]
finsts1 })
(ImportAvails { imp_mods :: ImportAvails -> ImportedMods
imp_mods = ImportedMods
mods2,
imp_dep_mods :: ImportAvails -> ModuleNameEnv (ModuleName, Bool)
imp_dep_mods = ModuleNameEnv (ModuleName, Bool)
dmods2, imp_dep_pkgs :: ImportAvails -> Set InstalledUnitId
imp_dep_pkgs = Set InstalledUnitId
dpkgs2,
imp_trust_pkgs :: ImportAvails -> Set InstalledUnitId
imp_trust_pkgs = Set InstalledUnitId
tpkgs2, imp_trust_own_pkg :: ImportAvails -> Bool
imp_trust_own_pkg = Bool
tself2,
imp_orphs :: ImportAvails -> [Module]
imp_orphs = [Module]
orphs2, imp_finsts :: ImportAvails -> [Module]
imp_finsts = [Module]
finsts2 })
= ImportAvails :: ImportedMods
-> ModuleNameEnv (ModuleName, Bool)
-> Set InstalledUnitId
-> Set InstalledUnitId
-> Bool
-> [Module]
-> [Module]
-> ImportAvails
ImportAvails { imp_mods :: ImportedMods
imp_mods = ([ImportedBy] -> [ImportedBy] -> [ImportedBy])
-> ImportedMods -> ImportedMods -> ImportedMods
forall a.
(a -> a -> a) -> ModuleEnv a -> ModuleEnv a -> ModuleEnv a
plusModuleEnv_C [ImportedBy] -> [ImportedBy] -> [ImportedBy]
forall a. [a] -> [a] -> [a]
(++) ImportedMods
mods1 ImportedMods
mods2,
imp_dep_mods :: ModuleNameEnv (ModuleName, Bool)
imp_dep_mods = ((ModuleName, Bool) -> (ModuleName, Bool) -> (ModuleName, Bool))
-> ModuleNameEnv (ModuleName, Bool)
-> ModuleNameEnv (ModuleName, Bool)
-> ModuleNameEnv (ModuleName, Bool)
forall elt.
(elt -> elt -> elt) -> UniqFM elt -> UniqFM elt -> UniqFM elt
plusUFM_C (ModuleName, Bool) -> (ModuleName, Bool) -> (ModuleName, Bool)
forall a.
(Eq a, Outputable a) =>
(a, Bool) -> (a, Bool) -> (a, Bool)
plus_mod_dep ModuleNameEnv (ModuleName, Bool)
dmods1 ModuleNameEnv (ModuleName, Bool)
dmods2,
imp_dep_pkgs :: Set InstalledUnitId
imp_dep_pkgs = Set InstalledUnitId
dpkgs1 Set InstalledUnitId -> Set InstalledUnitId -> Set InstalledUnitId
forall a. Ord a => Set a -> Set a -> Set a
`S.union` Set InstalledUnitId
dpkgs2,
imp_trust_pkgs :: Set InstalledUnitId
imp_trust_pkgs = Set InstalledUnitId
tpkgs1 Set InstalledUnitId -> Set InstalledUnitId -> Set InstalledUnitId
forall a. Ord a => Set a -> Set a -> Set a
`S.union` Set InstalledUnitId
tpkgs2,
imp_trust_own_pkg :: Bool
imp_trust_own_pkg = Bool
tself1 Bool -> Bool -> Bool
|| Bool
tself2,
imp_orphs :: [Module]
imp_orphs = [Module]
orphs1 [Module] -> [Module] -> [Module]
forall a. (Outputable a, Eq a) => [a] -> [a] -> [a]
`unionLists` [Module]
orphs2,
imp_finsts :: [Module]
imp_finsts = [Module]
finsts1 [Module] -> [Module] -> [Module]
forall a. (Outputable a, Eq a) => [a] -> [a] -> [a]
`unionLists` [Module]
finsts2 }
where
plus_mod_dep :: (a, Bool) -> (a, Bool) -> (a, Bool)
plus_mod_dep r1 :: (a, Bool)
r1@(m1 :: a
m1, boot1 :: Bool
boot1) r2 :: (a, Bool)
r2@(m2 :: a
m2, boot2 :: Bool
boot2)
| ASSERT2( m1 == m2, (ppr m1 <+> ppr m2) $$ (ppr boot1 <+> ppr boot2) )
Bool
boot1 = (a, Bool)
r2
| Bool
otherwise = (a, Bool)
r1
data WhereFrom
= ImportByUser IsBootInterface
| ImportBySystem
| ImportByPlugin
instance Outputable WhereFrom where
ppr :: WhereFrom -> SDoc
ppr (ImportByUser is_boot :: Bool
is_boot) | Bool
is_boot = FilePath -> SDoc
text "{- SOURCE -}"
| Bool
otherwise = SDoc
empty
ppr ImportBySystem = FilePath -> SDoc
text "{- SYSTEM -}"
ppr ImportByPlugin = FilePath -> SDoc
text "{- PLUGIN -}"
type TcSigFun = Name -> Maybe TcSigInfo
data TcSigInfo = TcIdSig TcIdSigInfo
| TcPatSynSig TcPatSynInfo
data TcIdSigInfo
= CompleteSig
{ TcIdSigInfo -> TyVar
sig_bndr :: TcId
, TcIdSigInfo -> UserTypeCtxt
sig_ctxt :: UserTypeCtxt
, TcIdSigInfo -> SrcSpan
sig_loc :: SrcSpan
}
| PartialSig
{ TcIdSigInfo -> Name
psig_name :: Name
, TcIdSigInfo -> LHsSigWcType GhcRn
psig_hs_ty :: LHsSigWcType GhcRn
, sig_ctxt :: UserTypeCtxt
, sig_loc :: SrcSpan
}
data TcIdSigInst
= TISI { TcIdSigInst -> TcIdSigInfo
sig_inst_sig :: TcIdSigInfo
, TcIdSigInst -> [(Name, TyVar)]
sig_inst_skols :: [(Name, TcTyVar)]
, TcIdSigInst -> [Type]
sig_inst_theta :: TcThetaType
, TcIdSigInst -> Type
sig_inst_tau :: TcSigmaType
, TcIdSigInst -> [(Name, TyVar)]
sig_inst_wcs :: [(Name, TcTyVar)]
, TcIdSigInst -> Maybe Type
sig_inst_wcx :: Maybe TcType
}
data TcPatSynInfo
= TPSI {
TcPatSynInfo -> Name
patsig_name :: Name,
TcPatSynInfo -> [TyVarBinder]
patsig_implicit_bndrs :: [TyVarBinder],
TcPatSynInfo -> [TyVar]
patsig_univ_bndrs :: [TyVar],
TcPatSynInfo -> [Type]
patsig_req :: TcThetaType,
TcPatSynInfo -> [TyVar]
patsig_ex_bndrs :: [TyVar],
TcPatSynInfo -> [Type]
patsig_prov :: TcThetaType,
TcPatSynInfo -> Type
patsig_body_ty :: TcSigmaType
}
instance Outputable TcSigInfo where
ppr :: TcSigInfo -> SDoc
ppr (TcIdSig idsi :: TcIdSigInfo
idsi) = TcIdSigInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr TcIdSigInfo
idsi
ppr (TcPatSynSig tpsi :: TcPatSynInfo
tpsi) = FilePath -> SDoc
text "TcPatSynInfo" SDoc -> SDoc -> SDoc
<+> TcPatSynInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr TcPatSynInfo
tpsi
instance Outputable TcIdSigInfo where
ppr :: TcIdSigInfo -> SDoc
ppr (CompleteSig { sig_bndr :: TcIdSigInfo -> TyVar
sig_bndr = TyVar
bndr })
= TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
bndr SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr (TyVar -> Type
idType TyVar
bndr)
ppr (PartialSig { psig_name :: TcIdSigInfo -> Name
psig_name = Name
name, psig_hs_ty :: TcIdSigInfo -> LHsSigWcType GhcRn
psig_hs_ty = LHsSigWcType GhcRn
hs_ty })
= FilePath -> SDoc
text "psig" SDoc -> SDoc -> SDoc
<+> Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> LHsSigWcType GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr LHsSigWcType GhcRn
hs_ty
instance Outputable TcIdSigInst where
ppr :: TcIdSigInst -> SDoc
ppr (TISI { sig_inst_sig :: TcIdSigInst -> TcIdSigInfo
sig_inst_sig = TcIdSigInfo
sig, sig_inst_skols :: TcIdSigInst -> [(Name, TyVar)]
sig_inst_skols = [(Name, TyVar)]
skols
, sig_inst_theta :: TcIdSigInst -> [Type]
sig_inst_theta = [Type]
theta, sig_inst_tau :: TcIdSigInst -> Type
sig_inst_tau = Type
tau })
= SDoc -> Int -> SDoc -> SDoc
hang (TcIdSigInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr TcIdSigInfo
sig) 2 ([SDoc] -> SDoc
vcat [ [(Name, TyVar)] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [(Name, TyVar)]
skols, [Type] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [Type]
theta SDoc -> SDoc -> SDoc
<+> SDoc
darrow SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
tau ])
instance Outputable TcPatSynInfo where
ppr :: TcPatSynInfo -> SDoc
ppr (TPSI{ patsig_name :: TcPatSynInfo -> Name
patsig_name = Name
name}) = Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name
isPartialSig :: TcIdSigInst -> Bool
isPartialSig :: TcIdSigInst -> Bool
isPartialSig (TISI { sig_inst_sig :: TcIdSigInst -> TcIdSigInfo
sig_inst_sig = PartialSig {} }) = Bool
True
isPartialSig _ = Bool
False
hasCompleteSig :: TcSigFun -> Name -> Bool
hasCompleteSig :: TcSigFun -> Name -> Bool
hasCompleteSig sig_fn :: TcSigFun
sig_fn name :: Name
name
= case TcSigFun
sig_fn Name
name of
Just (TcIdSig (CompleteSig {})) -> Bool
True
_ -> Bool
False
type Xi = Type
type Cts = Bag Ct
data Ct
= CDictCan {
Ct -> CtEvidence
cc_ev :: CtEvidence,
Ct -> Class
cc_class :: Class,
Ct -> [Type]
cc_tyargs :: [Xi],
Ct -> Bool
cc_pend_sc :: Bool
}
| CIrredCan {
cc_ev :: CtEvidence,
Ct -> Bool
cc_insol :: Bool
}
| CTyEqCan {
cc_ev :: CtEvidence,
Ct -> TyVar
cc_tyvar :: TcTyVar,
Ct -> Type
cc_rhs :: TcType,
Ct -> EqRel
cc_eq_rel :: EqRel
}
| CFunEqCan {
cc_ev :: CtEvidence,
Ct -> TyCon
cc_fun :: TyCon,
cc_tyargs :: [Xi],
Ct -> TyVar
cc_fsk :: TcTyVar
}
| CNonCanonical {
cc_ev :: CtEvidence
}
| CHoleCan {
cc_ev :: CtEvidence,
Ct -> Hole
cc_hole :: Hole
}
| CQuantCan QCInst
data QCInst
= QCI { QCInst -> CtEvidence
qci_ev :: CtEvidence
, QCInst -> [TyVar]
qci_tvs :: [TcTyVar]
, QCInst -> Type
qci_pred :: TcPredType
, QCInst -> Bool
qci_pend_sc :: Bool
}
instance Outputable QCInst where
ppr :: QCInst -> SDoc
ppr (QCI { qci_ev :: QCInst -> CtEvidence
qci_ev = CtEvidence
ev }) = CtEvidence -> SDoc
forall a. Outputable a => a -> SDoc
ppr CtEvidence
ev
data Hole = ExprHole UnboundVar
| TypeHole OccName
instance Outputable Hole where
ppr :: Hole -> SDoc
ppr (ExprHole ub :: UnboundVar
ub) = UnboundVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr UnboundVar
ub
ppr (TypeHole occ :: OccName
occ) = FilePath -> SDoc
text "TypeHole" SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
parens (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
occ)
holeOcc :: Hole -> OccName
holeOcc :: Hole -> OccName
holeOcc (ExprHole uv :: UnboundVar
uv) = UnboundVar -> OccName
unboundVarOcc UnboundVar
uv
holeOcc (TypeHole occ :: OccName
occ) = OccName
occ
mkNonCanonical :: CtEvidence -> Ct
mkNonCanonical :: CtEvidence -> Ct
mkNonCanonical ev :: CtEvidence
ev = CNonCanonical :: CtEvidence -> Ct
CNonCanonical { cc_ev :: CtEvidence
cc_ev = CtEvidence
ev }
mkNonCanonicalCt :: Ct -> Ct
mkNonCanonicalCt :: Ct -> Ct
mkNonCanonicalCt ct :: Ct
ct = CNonCanonical :: CtEvidence -> Ct
CNonCanonical { cc_ev :: CtEvidence
cc_ev = Ct -> CtEvidence
cc_ev Ct
ct }
mkIrredCt :: CtEvidence -> Ct
mkIrredCt :: CtEvidence -> Ct
mkIrredCt ev :: CtEvidence
ev = CIrredCan :: CtEvidence -> Bool -> Ct
CIrredCan { cc_ev :: CtEvidence
cc_ev = CtEvidence
ev, cc_insol :: Bool
cc_insol = Bool
False }
mkInsolubleCt :: CtEvidence -> Ct
mkInsolubleCt :: CtEvidence -> Ct
mkInsolubleCt ev :: CtEvidence
ev = CIrredCan :: CtEvidence -> Bool -> Ct
CIrredCan { cc_ev :: CtEvidence
cc_ev = CtEvidence
ev, cc_insol :: Bool
cc_insol = Bool
True }
mkGivens :: CtLoc -> [EvId] -> [Ct]
mkGivens :: CtLoc -> [TyVar] -> [Ct]
mkGivens loc :: CtLoc
loc ev_ids :: [TyVar]
ev_ids
= (TyVar -> Ct) -> [TyVar] -> [Ct]
forall a b. (a -> b) -> [a] -> [b]
map TyVar -> Ct
mk [TyVar]
ev_ids
where
mk :: TyVar -> Ct
mk ev_id :: TyVar
ev_id = CtEvidence -> Ct
mkNonCanonical (CtGiven :: Type -> TyVar -> CtLoc -> CtEvidence
CtGiven { ctev_evar :: TyVar
ctev_evar = TyVar
ev_id
, ctev_pred :: Type
ctev_pred = TyVar -> Type
evVarPred TyVar
ev_id
, ctev_loc :: CtLoc
ctev_loc = CtLoc
loc })
ctEvidence :: Ct -> CtEvidence
ctEvidence :: Ct -> CtEvidence
ctEvidence (CQuantCan (QCI { qci_ev :: QCInst -> CtEvidence
qci_ev = CtEvidence
ev })) = CtEvidence
ev
ctEvidence ct :: Ct
ct = Ct -> CtEvidence
cc_ev Ct
ct
ctLoc :: Ct -> CtLoc
ctLoc :: Ct -> CtLoc
ctLoc = CtEvidence -> CtLoc
ctEvLoc (CtEvidence -> CtLoc) -> (Ct -> CtEvidence) -> Ct -> CtLoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> CtEvidence
ctEvidence
setCtLoc :: Ct -> CtLoc -> Ct
setCtLoc :: Ct -> CtLoc -> Ct
setCtLoc ct :: Ct
ct loc :: CtLoc
loc = Ct
ct { cc_ev :: CtEvidence
cc_ev = (Ct -> CtEvidence
cc_ev Ct
ct) { ctev_loc :: CtLoc
ctev_loc = CtLoc
loc } }
ctOrigin :: Ct -> CtOrigin
ctOrigin :: Ct -> CtOrigin
ctOrigin = CtLoc -> CtOrigin
ctLocOrigin (CtLoc -> CtOrigin) -> (Ct -> CtLoc) -> Ct -> CtOrigin
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> CtLoc
ctLoc
ctPred :: Ct -> PredType
ctPred :: Ct -> Type
ctPred ct :: Ct
ct = CtEvidence -> Type
ctEvPred (Ct -> CtEvidence
ctEvidence Ct
ct)
ctEvId :: Ct -> EvVar
ctEvId :: Ct -> TyVar
ctEvId ct :: Ct
ct = CtEvidence -> TyVar
ctEvEvId (Ct -> CtEvidence
ctEvidence Ct
ct)
mkTcEqPredLikeEv :: CtEvidence -> TcType -> TcType -> TcType
mkTcEqPredLikeEv :: CtEvidence -> Type -> Type -> Type
mkTcEqPredLikeEv ev :: CtEvidence
ev
= case Type -> EqRel
predTypeEqRel Type
pred of
NomEq -> Type -> Type -> Type
mkPrimEqPred
ReprEq -> Type -> Type -> Type
mkReprPrimEqPred
where
pred :: Type
pred = CtEvidence -> Type
ctEvPred CtEvidence
ev
ctFlavour :: Ct -> CtFlavour
ctFlavour :: Ct -> CtFlavour
ctFlavour = CtEvidence -> CtFlavour
ctEvFlavour (CtEvidence -> CtFlavour) -> (Ct -> CtEvidence) -> Ct -> CtFlavour
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> CtEvidence
ctEvidence
ctEqRel :: Ct -> EqRel
ctEqRel :: Ct -> EqRel
ctEqRel = CtEvidence -> EqRel
ctEvEqRel (CtEvidence -> EqRel) -> (Ct -> CtEvidence) -> Ct -> EqRel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> CtEvidence
ctEvidence
instance Outputable Ct where
ppr :: Ct -> SDoc
ppr ct :: Ct
ct = CtEvidence -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Ct -> CtEvidence
ctEvidence Ct
ct) SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
parens SDoc
pp_sort
where
pp_sort :: SDoc
pp_sort = case Ct
ct of
CTyEqCan {} -> FilePath -> SDoc
text "CTyEqCan"
CFunEqCan {} -> FilePath -> SDoc
text "CFunEqCan"
CNonCanonical {} -> FilePath -> SDoc
text "CNonCanonical"
CDictCan { cc_pend_sc :: Ct -> Bool
cc_pend_sc = Bool
pend_sc }
| Bool
pend_sc -> FilePath -> SDoc
text "CDictCan(psc)"
| Bool
otherwise -> FilePath -> SDoc
text "CDictCan"
CIrredCan { cc_insol :: Ct -> Bool
cc_insol = Bool
insol }
| Bool
insol -> FilePath -> SDoc
text "CIrredCan(insol)"
| Bool
otherwise -> FilePath -> SDoc
text "CIrredCan(sol)"
CHoleCan { cc_hole :: Ct -> Hole
cc_hole = Hole
hole } -> FilePath -> SDoc
text "CHoleCan:" SDoc -> SDoc -> SDoc
<+> Hole -> SDoc
forall a. Outputable a => a -> SDoc
ppr Hole
hole
CQuantCan (QCI { qci_pend_sc :: QCInst -> Bool
qci_pend_sc = Bool
pend_sc })
| Bool
pend_sc -> FilePath -> SDoc
text "CQuantCan(psc)"
| Bool
otherwise -> FilePath -> SDoc
text "CQuantCan"
tyCoVarsOfCt :: Ct -> TcTyCoVarSet
tyCoVarsOfCt :: Ct -> TcTyVarSet
tyCoVarsOfCt = FV -> TcTyVarSet
fvVarSet (FV -> TcTyVarSet) -> (Ct -> FV) -> Ct -> TcTyVarSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> FV
tyCoFVsOfCt
tyCoVarsOfCtList :: Ct -> [TcTyCoVar]
tyCoVarsOfCtList :: Ct -> [TyVar]
tyCoVarsOfCtList = FV -> [TyVar]
fvVarList (FV -> [TyVar]) -> (Ct -> FV) -> Ct -> [TyVar]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> FV
tyCoFVsOfCt
tyCoFVsOfCt :: Ct -> FV
tyCoFVsOfCt :: Ct -> FV
tyCoFVsOfCt (CTyEqCan { cc_tyvar :: Ct -> TyVar
cc_tyvar = TyVar
tv, cc_rhs :: Ct -> Type
cc_rhs = Type
xi })
= Type -> FV
tyCoFVsOfType Type
xi FV -> FV -> FV
`unionFV` TyVar -> FV
FV.unitFV TyVar
tv
FV -> FV -> FV
`unionFV` Type -> FV
tyCoFVsOfType (TyVar -> Type
tyVarKind TyVar
tv)
tyCoFVsOfCt (CFunEqCan { cc_tyargs :: Ct -> [Type]
cc_tyargs = [Type]
tys, cc_fsk :: Ct -> TyVar
cc_fsk = TyVar
fsk })
= [Type] -> FV
tyCoFVsOfTypes [Type]
tys FV -> FV -> FV
`unionFV` TyVar -> FV
FV.unitFV TyVar
fsk
FV -> FV -> FV
`unionFV` Type -> FV
tyCoFVsOfType (TyVar -> Type
tyVarKind TyVar
fsk)
tyCoFVsOfCt (CDictCan { cc_tyargs :: Ct -> [Type]
cc_tyargs = [Type]
tys }) = [Type] -> FV
tyCoFVsOfTypes [Type]
tys
tyCoFVsOfCt ct :: Ct
ct = Type -> FV
tyCoFVsOfType (Ct -> Type
ctPred Ct
ct)
tyCoVarsOfCts :: Cts -> TcTyCoVarSet
tyCoVarsOfCts :: Cts -> TcTyVarSet
tyCoVarsOfCts = FV -> TcTyVarSet
fvVarSet (FV -> TcTyVarSet) -> (Cts -> FV) -> Cts -> TcTyVarSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cts -> FV
tyCoFVsOfCts
tyCoVarsOfCtsList :: Cts -> [TcTyCoVar]
tyCoVarsOfCtsList :: Cts -> [TyVar]
tyCoVarsOfCtsList = FV -> [TyVar]
fvVarList (FV -> [TyVar]) -> (Cts -> FV) -> Cts -> [TyVar]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cts -> FV
tyCoFVsOfCts
tyCoFVsOfCts :: Cts -> FV
tyCoFVsOfCts :: Cts -> FV
tyCoFVsOfCts = (Ct -> FV -> FV) -> FV -> Cts -> FV
forall a r. (a -> r -> r) -> r -> Bag a -> r
foldrBag (FV -> FV -> FV
unionFV (FV -> FV -> FV) -> (Ct -> FV) -> Ct -> FV -> FV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> FV
tyCoFVsOfCt) FV
emptyFV
tyCoVarsOfWC :: WantedConstraints -> TyCoVarSet
tyCoVarsOfWC :: WantedConstraints -> TcTyVarSet
tyCoVarsOfWC = FV -> TcTyVarSet
fvVarSet (FV -> TcTyVarSet)
-> (WantedConstraints -> FV) -> WantedConstraints -> TcTyVarSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WantedConstraints -> FV
tyCoFVsOfWC
tyCoVarsOfWCList :: WantedConstraints -> [TyCoVar]
tyCoVarsOfWCList :: WantedConstraints -> [TyVar]
tyCoVarsOfWCList = FV -> [TyVar]
fvVarList (FV -> [TyVar])
-> (WantedConstraints -> FV) -> WantedConstraints -> [TyVar]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WantedConstraints -> FV
tyCoFVsOfWC
tyCoFVsOfWC :: WantedConstraints -> FV
tyCoFVsOfWC :: WantedConstraints -> FV
tyCoFVsOfWC (WC { wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
simple, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
implic })
= Cts -> FV
tyCoFVsOfCts Cts
simple FV -> FV -> FV
`unionFV`
(Implication -> FV) -> Bag Implication -> FV
forall a. (a -> FV) -> Bag a -> FV
tyCoFVsOfBag Implication -> FV
tyCoFVsOfImplic Bag Implication
implic
tyCoFVsOfImplic :: Implication -> FV
tyCoFVsOfImplic :: Implication -> FV
tyCoFVsOfImplic (Implic { ic_skols :: Implication -> [TyVar]
ic_skols = [TyVar]
skols
, ic_given :: Implication -> [TyVar]
ic_given = [TyVar]
givens
, ic_wanted :: Implication -> WantedConstraints
ic_wanted = WantedConstraints
wanted })
| WantedConstraints -> Bool
isEmptyWC WantedConstraints
wanted
= FV
emptyFV
| Bool
otherwise
= [TyVar] -> FV -> FV
tyCoFVsVarBndrs [TyVar]
skols (FV -> FV) -> FV -> FV
forall a b. (a -> b) -> a -> b
$
[TyVar] -> FV -> FV
tyCoFVsVarBndrs [TyVar]
givens (FV -> FV) -> FV -> FV
forall a b. (a -> b) -> a -> b
$
WantedConstraints -> FV
tyCoFVsOfWC WantedConstraints
wanted
tyCoFVsOfBag :: (a -> FV) -> Bag a -> FV
tyCoFVsOfBag :: (a -> FV) -> Bag a -> FV
tyCoFVsOfBag tvs_of :: a -> FV
tvs_of = (a -> FV -> FV) -> FV -> Bag a -> FV
forall a r. (a -> r -> r) -> r -> Bag a -> r
foldrBag (FV -> FV -> FV
unionFV (FV -> FV -> FV) -> (a -> FV) -> a -> FV -> FV
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> FV
tvs_of) FV
emptyFV
dropDerivedWC :: WantedConstraints -> WantedConstraints
dropDerivedWC :: WantedConstraints -> WantedConstraints
dropDerivedWC wc :: WantedConstraints
wc@(WC { wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
simples })
= WantedConstraints
wc { wc_simple :: Cts
wc_simple = Cts -> Cts
dropDerivedSimples Cts
simples }
dropDerivedSimples :: Cts -> Cts
dropDerivedSimples :: Cts -> Cts
dropDerivedSimples simples :: Cts
simples = (Ct -> Maybe Ct) -> Cts -> Cts
forall a b. (a -> Maybe b) -> Bag a -> Bag b
mapMaybeBag Ct -> Maybe Ct
dropDerivedCt Cts
simples
dropDerivedCt :: Ct -> Maybe Ct
dropDerivedCt :: Ct -> Maybe Ct
dropDerivedCt ct :: Ct
ct
= case CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev of
Wanted WOnly -> Ct -> Maybe Ct
forall a. a -> Maybe a
Just (Ct
ct' { cc_ev :: CtEvidence
cc_ev = CtEvidence
ev_wd })
Wanted _ -> Ct -> Maybe Ct
forall a. a -> Maybe a
Just Ct
ct'
_ | Ct -> Bool
isDroppableCt Ct
ct -> Maybe Ct
forall a. Maybe a
Nothing
| Bool
otherwise -> Ct -> Maybe Ct
forall a. a -> Maybe a
Just Ct
ct
where
ev :: CtEvidence
ev = Ct -> CtEvidence
ctEvidence Ct
ct
ev_wd :: CtEvidence
ev_wd = CtEvidence
ev { ctev_nosh :: ShadowInfo
ctev_nosh = ShadowInfo
WDeriv }
ct' :: Ct
ct' = Ct -> Ct
setPendingScDict Ct
ct
isDroppableCt :: Ct -> Bool
isDroppableCt :: Ct -> Bool
isDroppableCt ct :: Ct
ct
= CtEvidence -> Bool
isDerived CtEvidence
ev Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
keep_deriv
where
ev :: CtEvidence
ev = Ct -> CtEvidence
ctEvidence Ct
ct
loc :: CtLoc
loc = CtEvidence -> CtLoc
ctEvLoc CtEvidence
ev
orig :: CtOrigin
orig = CtLoc -> CtOrigin
ctLocOrigin CtLoc
loc
keep_deriv :: Bool
keep_deriv
= case Ct
ct of
CHoleCan {} -> Bool
True
CIrredCan { cc_insol :: Ct -> Bool
cc_insol = Bool
insoluble }
-> Bool -> Bool
keep_eq Bool
insoluble
_ -> Bool -> Bool
keep_eq Bool
False
keep_eq :: Bool -> Bool
keep_eq definitely_insoluble :: Bool
definitely_insoluble
| CtOrigin -> Bool
isGivenOrigin CtOrigin
orig
= Bool
definitely_insoluble
| Bool
otherwise
= case CtOrigin
orig of
KindEqOrigin {} -> Bool
True
FunDepOrigin2 {} -> Bool
True
FunDepOrigin1 _ loc1 :: CtLoc
loc1 _ loc2 :: CtLoc
loc2
| Bool
g1 Bool -> Bool -> Bool
|| Bool
g2 -> Bool
True
| Bool
otherwise -> Bool
False
where
g1 :: Bool
g1 = CtLoc -> Bool
isGivenLoc CtLoc
loc1
g2 :: Bool
g2 = CtLoc -> Bool
isGivenLoc CtLoc
loc2
_ -> Bool
False
arisesFromGivens :: Ct -> Bool
arisesFromGivens :: Ct -> Bool
arisesFromGivens ct :: Ct
ct
= case Ct -> CtEvidence
ctEvidence Ct
ct of
CtGiven {} -> Bool
True
CtWanted {} -> Bool
False
CtDerived { ctev_loc :: CtEvidence -> CtLoc
ctev_loc = CtLoc
loc } -> CtLoc -> Bool
isGivenLoc CtLoc
loc
isGivenLoc :: CtLoc -> Bool
isGivenLoc :: CtLoc -> Bool
isGivenLoc loc :: CtLoc
loc = CtOrigin -> Bool
isGivenOrigin (CtLoc -> CtOrigin
ctLocOrigin CtLoc
loc)
isGivenOrigin :: CtOrigin -> Bool
isGivenOrigin :: CtOrigin -> Bool
isGivenOrigin (GivenOrigin {}) = Bool
True
isGivenOrigin (FunDepOrigin1 _ l1 :: CtLoc
l1 _ l2 :: CtLoc
l2) = CtLoc -> Bool
isGivenLoc CtLoc
l1 Bool -> Bool -> Bool
&& CtLoc -> Bool
isGivenLoc CtLoc
l2
isGivenOrigin (FunDepOrigin2 _ o1 :: CtOrigin
o1 _ _) = CtOrigin -> Bool
isGivenOrigin CtOrigin
o1
isGivenOrigin _ = Bool
False
isWantedCt :: Ct -> Bool
isWantedCt :: Ct -> Bool
isWantedCt = CtEvidence -> Bool
isWanted (CtEvidence -> Bool) -> (Ct -> CtEvidence) -> Ct -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> CtEvidence
ctEvidence
isGivenCt :: Ct -> Bool
isGivenCt :: Ct -> Bool
isGivenCt = CtEvidence -> Bool
isGiven (CtEvidence -> Bool) -> (Ct -> CtEvidence) -> Ct -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> CtEvidence
ctEvidence
isDerivedCt :: Ct -> Bool
isDerivedCt :: Ct -> Bool
isDerivedCt = CtEvidence -> Bool
isDerived (CtEvidence -> Bool) -> (Ct -> CtEvidence) -> Ct -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ct -> CtEvidence
ctEvidence
isCTyEqCan :: Ct -> Bool
isCTyEqCan :: Ct -> Bool
isCTyEqCan (CTyEqCan {}) = Bool
True
isCTyEqCan (CFunEqCan {}) = Bool
False
isCTyEqCan _ = Bool
False
isCDictCan_Maybe :: Ct -> Maybe Class
isCDictCan_Maybe :: Ct -> Maybe Class
isCDictCan_Maybe (CDictCan {cc_class :: Ct -> Class
cc_class = Class
cls }) = Class -> Maybe Class
forall a. a -> Maybe a
Just Class
cls
isCDictCan_Maybe _ = Maybe Class
forall a. Maybe a
Nothing
isCFunEqCan_maybe :: Ct -> Maybe (TyCon, [Type])
isCFunEqCan_maybe :: Ct -> Maybe (TyCon, [Type])
isCFunEqCan_maybe (CFunEqCan { cc_fun :: Ct -> TyCon
cc_fun = TyCon
tc, cc_tyargs :: Ct -> [Type]
cc_tyargs = [Type]
xis }) = (TyCon, [Type]) -> Maybe (TyCon, [Type])
forall a. a -> Maybe a
Just (TyCon
tc, [Type]
xis)
isCFunEqCan_maybe _ = Maybe (TyCon, [Type])
forall a. Maybe a
Nothing
isCFunEqCan :: Ct -> Bool
isCFunEqCan :: Ct -> Bool
isCFunEqCan (CFunEqCan {}) = Bool
True
isCFunEqCan _ = Bool
False
isCNonCanonical :: Ct -> Bool
isCNonCanonical :: Ct -> Bool
isCNonCanonical (CNonCanonical {}) = Bool
True
isCNonCanonical _ = Bool
False
isHoleCt:: Ct -> Bool
isHoleCt :: Ct -> Bool
isHoleCt (CHoleCan {}) = Bool
True
isHoleCt _ = Bool
False
isOutOfScopeCt :: Ct -> Bool
isOutOfScopeCt :: Ct -> Bool
isOutOfScopeCt (CHoleCan { cc_hole :: Ct -> Hole
cc_hole = ExprHole (OutOfScope {}) }) = Bool
True
isOutOfScopeCt _ = Bool
False
isExprHoleCt :: Ct -> Bool
isExprHoleCt :: Ct -> Bool
isExprHoleCt (CHoleCan { cc_hole :: Ct -> Hole
cc_hole = ExprHole {} }) = Bool
True
isExprHoleCt _ = Bool
False
isTypeHoleCt :: Ct -> Bool
isTypeHoleCt :: Ct -> Bool
isTypeHoleCt (CHoleCan { cc_hole :: Ct -> Hole
cc_hole = TypeHole {} }) = Bool
True
isTypeHoleCt _ = Bool
False
getUserTypeErrorMsg :: Ct -> Maybe Type
getUserTypeErrorMsg :: Ct -> Maybe Type
getUserTypeErrorMsg ct :: Ct
ct = Type -> Maybe Type
findUserTypeError (Ct -> Type
ctPred Ct
ct)
where
findUserTypeError :: Type -> Maybe Type
findUserTypeError t :: Type
t = [Maybe Type] -> Maybe Type
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum ( Type -> Maybe Type
userTypeError_maybe Type
t
Maybe Type -> [Maybe Type] -> [Maybe Type]
forall a. a -> [a] -> [a]
: (Type -> Maybe Type) -> [Type] -> [Maybe Type]
forall a b. (a -> b) -> [a] -> [b]
map Type -> Maybe Type
findUserTypeError (Type -> [Type]
subTys Type
t)
)
subTys :: Type -> [Type]
subTys t :: Type
t = case Type -> (Type, [Type])
splitAppTys Type
t of
(t :: Type
t,[]) ->
case HasDebugCallStack => Type -> Maybe (TyCon, [Type])
Type -> Maybe (TyCon, [Type])
splitTyConApp_maybe Type
t of
Nothing -> []
Just (_,ts :: [Type]
ts) -> [Type]
ts
(t :: Type
t,ts :: [Type]
ts) -> Type
t Type -> [Type] -> [Type]
forall a. a -> [a] -> [a]
: [Type]
ts
isUserTypeErrorCt :: Ct -> Bool
isUserTypeErrorCt :: Ct -> Bool
isUserTypeErrorCt ct :: Ct
ct = case Ct -> Maybe Type
getUserTypeErrorMsg Ct
ct of
Just _ -> Bool
True
_ -> Bool
False
isPendingScDict :: Ct -> Maybe Ct
isPendingScDict :: Ct -> Maybe Ct
isPendingScDict ct :: Ct
ct@(CDictCan { cc_pend_sc :: Ct -> Bool
cc_pend_sc = Bool
True })
= Ct -> Maybe Ct
forall a. a -> Maybe a
Just (Ct
ct { cc_pend_sc :: Bool
cc_pend_sc = Bool
False })
isPendingScDict _ = Maybe Ct
forall a. Maybe a
Nothing
isPendingScInst :: QCInst -> Maybe QCInst
isPendingScInst :: QCInst -> Maybe QCInst
isPendingScInst qci :: QCInst
qci@(QCI { qci_pend_sc :: QCInst -> Bool
qci_pend_sc = Bool
True })
= QCInst -> Maybe QCInst
forall a. a -> Maybe a
Just (QCInst
qci { qci_pend_sc :: Bool
qci_pend_sc = Bool
False })
isPendingScInst _ = Maybe QCInst
forall a. Maybe a
Nothing
setPendingScDict :: Ct -> Ct
setPendingScDict :: Ct -> Ct
setPendingScDict ct :: Ct
ct@(CDictCan { cc_pend_sc :: Ct -> Bool
cc_pend_sc = Bool
False })
= Ct
ct { cc_pend_sc :: Bool
cc_pend_sc = Bool
True }
setPendingScDict ct :: Ct
ct = Ct
ct
superClassesMightHelp :: WantedConstraints -> Bool
superClassesMightHelp :: WantedConstraints -> Bool
superClassesMightHelp (WC { wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
simples, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
implics })
= (Ct -> Bool) -> Cts -> Bool
forall a. (a -> Bool) -> Bag a -> Bool
anyBag Ct -> Bool
might_help_ct Cts
simples Bool -> Bool -> Bool
|| (Implication -> Bool) -> Bag Implication -> Bool
forall a. (a -> Bool) -> Bag a -> Bool
anyBag Implication -> Bool
might_help_implic Bag Implication
implics
where
might_help_implic :: Implication -> Bool
might_help_implic ic :: Implication
ic
| ImplicStatus
IC_Unsolved <- Implication -> ImplicStatus
ic_status Implication
ic = WantedConstraints -> Bool
superClassesMightHelp (Implication -> WantedConstraints
ic_wanted Implication
ic)
| Bool
otherwise = Bool
False
might_help_ct :: Ct -> Bool
might_help_ct ct :: Ct
ct = Ct -> Bool
isWantedCt Ct
ct Bool -> Bool -> Bool
&& Bool -> Bool
not (Ct -> Bool
is_ip Ct
ct)
is_ip :: Ct -> Bool
is_ip (CDictCan { cc_class :: Ct -> Class
cc_class = Class
cls }) = Class -> Bool
isIPClass Class
cls
is_ip _ = Bool
False
getPendingWantedScs :: Cts -> ([Ct], Cts)
getPendingWantedScs :: Cts -> ([Ct], Cts)
getPendingWantedScs simples :: Cts
simples
= ([Ct] -> Ct -> ([Ct], Ct)) -> [Ct] -> Cts -> ([Ct], Cts)
forall acc x y.
(acc -> x -> (acc, y)) -> acc -> Bag x -> (acc, Bag y)
mapAccumBagL [Ct] -> Ct -> ([Ct], Ct)
get [] Cts
simples
where
get :: [Ct] -> Ct -> ([Ct], Ct)
get acc :: [Ct]
acc ct :: Ct
ct | Just ct' :: Ct
ct' <- Ct -> Maybe Ct
isPendingScDict Ct
ct
= (Ct
ct'Ct -> [Ct] -> [Ct]
forall a. a -> [a] -> [a]
:[Ct]
acc, Ct
ct')
| Bool
otherwise
= ([Ct]
acc, Ct
ct)
singleCt :: Ct -> Cts
singleCt :: Ct -> Cts
singleCt = Ct -> Cts
forall a. a -> Bag a
unitBag
andCts :: Cts -> Cts -> Cts
andCts :: Cts -> Cts -> Cts
andCts = Cts -> Cts -> Cts
forall a. Bag a -> Bag a -> Bag a
unionBags
listToCts :: [Ct] -> Cts
listToCts :: [Ct] -> Cts
listToCts = [Ct] -> Cts
forall a. [a] -> Bag a
listToBag
ctsElts :: Cts -> [Ct]
ctsElts :: Cts -> [Ct]
ctsElts = Cts -> [Ct]
forall a. Bag a -> [a]
bagToList
consCts :: Ct -> Cts -> Cts
consCts :: Ct -> Cts -> Cts
consCts = Ct -> Cts -> Cts
forall a. a -> Bag a -> Bag a
consBag
snocCts :: Cts -> Ct -> Cts
snocCts :: Cts -> Ct -> Cts
snocCts = Cts -> Ct -> Cts
forall a. Bag a -> a -> Bag a
snocBag
extendCtsList :: Cts -> [Ct] -> Cts
extendCtsList :: Cts -> [Ct] -> Cts
extendCtsList cts :: Cts
cts xs :: [Ct]
xs | [Ct] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Ct]
xs = Cts
cts
| Bool
otherwise = Cts
cts Cts -> Cts -> Cts
forall a. Bag a -> Bag a -> Bag a
`unionBags` [Ct] -> Cts
forall a. [a] -> Bag a
listToBag [Ct]
xs
andManyCts :: [Cts] -> Cts
andManyCts :: [Cts] -> Cts
andManyCts = [Cts] -> Cts
forall a. [Bag a] -> Bag a
unionManyBags
emptyCts :: Cts
emptyCts :: Cts
emptyCts = Cts
forall a. Bag a
emptyBag
isEmptyCts :: Cts -> Bool
isEmptyCts :: Cts -> Bool
isEmptyCts = Cts -> Bool
forall a. Bag a -> Bool
isEmptyBag
pprCts :: Cts -> SDoc
pprCts :: Cts -> SDoc
pprCts cts :: Cts
cts = [SDoc] -> SDoc
vcat ((Ct -> SDoc) -> [Ct] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map Ct -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Cts -> [Ct]
forall a. Bag a -> [a]
bagToList Cts
cts))
data WantedConstraints
= WC { WantedConstraints -> Cts
wc_simple :: Cts
, WantedConstraints -> Bag Implication
wc_impl :: Bag Implication
}
emptyWC :: WantedConstraints
emptyWC :: WantedConstraints
emptyWC = WC :: Cts -> Bag Implication -> WantedConstraints
WC { wc_simple :: Cts
wc_simple = Cts
forall a. Bag a
emptyBag, wc_impl :: Bag Implication
wc_impl = Bag Implication
forall a. Bag a
emptyBag }
mkSimpleWC :: [CtEvidence] -> WantedConstraints
mkSimpleWC :: [CtEvidence] -> WantedConstraints
mkSimpleWC cts :: [CtEvidence]
cts
= WC :: Cts -> Bag Implication -> WantedConstraints
WC { wc_simple :: Cts
wc_simple = [Ct] -> Cts
forall a. [a] -> Bag a
listToBag ((CtEvidence -> Ct) -> [CtEvidence] -> [Ct]
forall a b. (a -> b) -> [a] -> [b]
map CtEvidence -> Ct
mkNonCanonical [CtEvidence]
cts)
, wc_impl :: Bag Implication
wc_impl = Bag Implication
forall a. Bag a
emptyBag }
mkImplicWC :: Bag Implication -> WantedConstraints
mkImplicWC :: Bag Implication -> WantedConstraints
mkImplicWC implic :: Bag Implication
implic
= WC :: Cts -> Bag Implication -> WantedConstraints
WC { wc_simple :: Cts
wc_simple = Cts
forall a. Bag a
emptyBag, wc_impl :: Bag Implication
wc_impl = Bag Implication
implic }
isEmptyWC :: WantedConstraints -> Bool
isEmptyWC :: WantedConstraints -> Bool
isEmptyWC (WC { wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
f, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
i })
= Cts -> Bool
forall a. Bag a -> Bool
isEmptyBag Cts
f Bool -> Bool -> Bool
&& Bag Implication -> Bool
forall a. Bag a -> Bool
isEmptyBag Bag Implication
i
isSolvedWC :: WantedConstraints -> Bool
isSolvedWC :: WantedConstraints -> Bool
isSolvedWC WC {wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
wc_simple, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
wc_impl} =
Cts -> Bool
forall a. Bag a -> Bool
isEmptyBag Cts
wc_simple Bool -> Bool -> Bool
&& (Implication -> Bool) -> Bag Implication -> Bool
forall a. (a -> Bool) -> Bag a -> Bool
allBag (ImplicStatus -> Bool
isSolvedStatus (ImplicStatus -> Bool)
-> (Implication -> ImplicStatus) -> Implication -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Implication -> ImplicStatus
ic_status) Bag Implication
wc_impl
andWC :: WantedConstraints -> WantedConstraints -> WantedConstraints
andWC :: WantedConstraints -> WantedConstraints -> WantedConstraints
andWC (WC { wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
f1, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
i1 })
(WC { wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
f2, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
i2 })
= WC :: Cts -> Bag Implication -> WantedConstraints
WC { wc_simple :: Cts
wc_simple = Cts
f1 Cts -> Cts -> Cts
forall a. Bag a -> Bag a -> Bag a
`unionBags` Cts
f2
, wc_impl :: Bag Implication
wc_impl = Bag Implication
i1 Bag Implication -> Bag Implication -> Bag Implication
forall a. Bag a -> Bag a -> Bag a
`unionBags` Bag Implication
i2 }
unionsWC :: [WantedConstraints] -> WantedConstraints
unionsWC :: [WantedConstraints] -> WantedConstraints
unionsWC = (WantedConstraints -> WantedConstraints -> WantedConstraints)
-> WantedConstraints -> [WantedConstraints] -> WantedConstraints
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr WantedConstraints -> WantedConstraints -> WantedConstraints
andWC WantedConstraints
emptyWC
addSimples :: WantedConstraints -> Bag Ct -> WantedConstraints
addSimples :: WantedConstraints -> Cts -> WantedConstraints
addSimples wc :: WantedConstraints
wc cts :: Cts
cts
= WantedConstraints
wc { wc_simple :: Cts
wc_simple = WantedConstraints -> Cts
wc_simple WantedConstraints
wc Cts -> Cts -> Cts
forall a. Bag a -> Bag a -> Bag a
`unionBags` Cts
cts }
addImplics :: WantedConstraints -> Bag Implication -> WantedConstraints
addImplics :: WantedConstraints -> Bag Implication -> WantedConstraints
addImplics wc :: WantedConstraints
wc implic :: Bag Implication
implic = WantedConstraints
wc { wc_impl :: Bag Implication
wc_impl = WantedConstraints -> Bag Implication
wc_impl WantedConstraints
wc Bag Implication -> Bag Implication -> Bag Implication
forall a. Bag a -> Bag a -> Bag a
`unionBags` Bag Implication
implic }
addInsols :: WantedConstraints -> Bag Ct -> WantedConstraints
addInsols :: WantedConstraints -> Cts -> WantedConstraints
addInsols wc :: WantedConstraints
wc cts :: Cts
cts
= WantedConstraints
wc { wc_simple :: Cts
wc_simple = WantedConstraints -> Cts
wc_simple WantedConstraints
wc Cts -> Cts -> Cts
forall a. Bag a -> Bag a -> Bag a
`unionBags` Cts
cts }
insolublesOnly :: WantedConstraints -> WantedConstraints
insolublesOnly :: WantedConstraints -> WantedConstraints
insolublesOnly (WC { wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
simples, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
implics })
= WC :: Cts -> Bag Implication -> WantedConstraints
WC { wc_simple :: Cts
wc_simple = (Ct -> Bool) -> Cts -> Cts
forall a. (a -> Bool) -> Bag a -> Bag a
filterBag Ct -> Bool
insolubleCt Cts
simples
, wc_impl :: Bag Implication
wc_impl = (Implication -> Implication) -> Bag Implication -> Bag Implication
forall a b. (a -> b) -> Bag a -> Bag b
mapBag Implication -> Implication
implic_insols_only Bag Implication
implics }
where
implic_insols_only :: Implication -> Implication
implic_insols_only implic :: Implication
implic
= Implication
implic { ic_wanted :: WantedConstraints
ic_wanted = WantedConstraints -> WantedConstraints
insolublesOnly (Implication -> WantedConstraints
ic_wanted Implication
implic) }
isSolvedStatus :: ImplicStatus -> Bool
isSolvedStatus :: ImplicStatus -> Bool
isSolvedStatus (IC_Solved {}) = Bool
True
isSolvedStatus _ = Bool
False
isInsolubleStatus :: ImplicStatus -> Bool
isInsolubleStatus :: ImplicStatus -> Bool
isInsolubleStatus IC_Insoluble = Bool
True
isInsolubleStatus IC_BadTelescope = Bool
True
isInsolubleStatus _ = Bool
False
insolubleImplic :: Implication -> Bool
insolubleImplic :: Implication -> Bool
insolubleImplic ic :: Implication
ic = ImplicStatus -> Bool
isInsolubleStatus (Implication -> ImplicStatus
ic_status Implication
ic)
insolubleWC :: WantedConstraints -> Bool
insolubleWC :: WantedConstraints -> Bool
insolubleWC (WC { wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
implics, wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
simples })
= (Ct -> Bool) -> Cts -> Bool
forall a. (a -> Bool) -> Bag a -> Bool
anyBag Ct -> Bool
insolubleCt Cts
simples
Bool -> Bool -> Bool
|| (Implication -> Bool) -> Bag Implication -> Bool
forall a. (a -> Bool) -> Bag a -> Bool
anyBag Implication -> Bool
insolubleImplic Bag Implication
implics
insolubleCt :: Ct -> Bool
insolubleCt :: Ct -> Bool
insolubleCt ct :: Ct
ct
| Ct -> Bool
isHoleCt Ct
ct = Ct -> Bool
isOutOfScopeCt Ct
ct
| Bool -> Bool
not (Ct -> Bool
insolubleEqCt Ct
ct) = Bool
False
| Ct -> Bool
arisesFromGivens Ct
ct = Bool
False
| Bool
otherwise = Bool
True
insolubleEqCt :: Ct -> Bool
insolubleEqCt :: Ct -> Bool
insolubleEqCt (CIrredCan { cc_insol :: Ct -> Bool
cc_insol = Bool
insol }) = Bool
insol
insolubleEqCt _ = Bool
False
instance Outputable WantedConstraints where
ppr :: WantedConstraints -> SDoc
ppr (WC {wc_simple :: WantedConstraints -> Cts
wc_simple = Cts
s, wc_impl :: WantedConstraints -> Bag Implication
wc_impl = Bag Implication
i})
= FilePath -> SDoc
text "WC" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
braces ([SDoc] -> SDoc
vcat
[ SDoc -> Cts -> SDoc
forall a. Outputable a => SDoc -> Bag a -> SDoc
ppr_bag (FilePath -> SDoc
text "wc_simple") Cts
s
, SDoc -> Bag Implication -> SDoc
forall a. Outputable a => SDoc -> Bag a -> SDoc
ppr_bag (FilePath -> SDoc
text "wc_impl") Bag Implication
i ])
ppr_bag :: Outputable a => SDoc -> Bag a -> SDoc
ppr_bag :: SDoc -> Bag a -> SDoc
ppr_bag doc :: SDoc
doc bag :: Bag a
bag
| Bag a -> Bool
forall a. Bag a -> Bool
isEmptyBag Bag a
bag = SDoc
empty
| Bool
otherwise = SDoc -> Int -> SDoc -> SDoc
hang (SDoc
doc SDoc -> SDoc -> SDoc
<+> SDoc
equals)
2 ((a -> SDoc -> SDoc) -> SDoc -> Bag a -> SDoc
forall a r. (a -> r -> r) -> r -> Bag a -> r
foldrBag (SDoc -> SDoc -> SDoc
($$) (SDoc -> SDoc -> SDoc) -> (a -> SDoc) -> a -> SDoc -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> SDoc
forall a. Outputable a => a -> SDoc
ppr) SDoc
empty Bag a
bag)
data Implication
= Implic {
Implication -> TcLevel
ic_tclvl :: TcLevel,
Implication -> [TyVar]
ic_skols :: [TcTyVar],
Implication -> SkolemInfo
ic_info :: SkolemInfo,
Implication -> Maybe SDoc
ic_telescope :: Maybe SDoc,
Implication -> [TyVar]
ic_given :: [EvVar],
Implication -> Bool
ic_no_eqs :: Bool,
Implication -> Env TcGblEnv TcLclEnv
ic_env :: Env TcGblEnv TcLclEnv,
Implication -> WantedConstraints
ic_wanted :: WantedConstraints,
Implication -> EvBindsVar
ic_binds :: EvBindsVar,
Implication -> TcTyVarSet
ic_need_inner :: VarSet,
Implication -> TcTyVarSet
ic_need_outer :: VarSet,
Implication -> ImplicStatus
ic_status :: ImplicStatus
}
newImplication :: TcM Implication
newImplication :: TcM Implication
newImplication
= do Env TcGblEnv TcLclEnv
env <- IOEnv (Env TcGblEnv TcLclEnv) (Env TcGblEnv TcLclEnv)
forall env. IOEnv env env
getEnv
Implication -> TcM Implication
forall (m :: * -> *) a. Monad m => a -> m a
return (Implication
implicationPrototype { ic_env :: Env TcGblEnv TcLclEnv
ic_env = Env TcGblEnv TcLclEnv
env })
implicationPrototype :: Implication
implicationPrototype :: Implication
implicationPrototype
= Implic :: TcLevel
-> [TyVar]
-> SkolemInfo
-> Maybe SDoc
-> [TyVar]
-> Bool
-> Env TcGblEnv TcLclEnv
-> WantedConstraints
-> EvBindsVar
-> TcTyVarSet
-> TcTyVarSet
-> ImplicStatus
-> Implication
Implic {
ic_tclvl :: TcLevel
ic_tclvl = FilePath -> TcLevel
forall a. FilePath -> a
panic "newImplic:tclvl"
, ic_binds :: EvBindsVar
ic_binds = FilePath -> EvBindsVar
forall a. FilePath -> a
panic "newImplic:binds"
, ic_info :: SkolemInfo
ic_info = FilePath -> SkolemInfo
forall a. FilePath -> a
panic "newImplic:info"
, ic_env :: Env TcGblEnv TcLclEnv
ic_env = FilePath -> Env TcGblEnv TcLclEnv
forall a. FilePath -> a
panic "newImplic:env"
, ic_skols :: [TyVar]
ic_skols = []
, ic_telescope :: Maybe SDoc
ic_telescope = Maybe SDoc
forall a. Maybe a
Nothing
, ic_given :: [TyVar]
ic_given = []
, ic_wanted :: WantedConstraints
ic_wanted = WantedConstraints
emptyWC
, ic_no_eqs :: Bool
ic_no_eqs = Bool
False
, ic_status :: ImplicStatus
ic_status = ImplicStatus
IC_Unsolved
, ic_need_inner :: TcTyVarSet
ic_need_inner = TcTyVarSet
emptyVarSet
, ic_need_outer :: TcTyVarSet
ic_need_outer = TcTyVarSet
emptyVarSet }
implicLclEnv :: Implication -> TcLclEnv
implicLclEnv :: Implication -> TcLclEnv
implicLclEnv = Env TcGblEnv TcLclEnv -> TcLclEnv
forall gbl lcl. Env gbl lcl -> lcl
env_lcl (Env TcGblEnv TcLclEnv -> TcLclEnv)
-> (Implication -> Env TcGblEnv TcLclEnv)
-> Implication
-> TcLclEnv
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Implication -> Env TcGblEnv TcLclEnv
ic_env
implicDynFlags :: Implication -> DynFlags
implicDynFlags :: Implication -> DynFlags
implicDynFlags = HscEnv -> DynFlags
hsc_dflags (HscEnv -> DynFlags)
-> (Implication -> HscEnv) -> Implication -> DynFlags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Env TcGblEnv TcLclEnv -> HscEnv
forall gbl lcl. Env gbl lcl -> HscEnv
env_top (Env TcGblEnv TcLclEnv -> HscEnv)
-> (Implication -> Env TcGblEnv TcLclEnv) -> Implication -> HscEnv
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Implication -> Env TcGblEnv TcLclEnv
ic_env
data ImplicStatus
= IC_Solved
{ ImplicStatus -> [TyVar]
ics_dead :: [EvVar] }
| IC_Insoluble
| IC_BadTelescope
| IC_Unsolved
instance Outputable Implication where
ppr :: Implication -> SDoc
ppr (Implic { ic_tclvl :: Implication -> TcLevel
ic_tclvl = TcLevel
tclvl, ic_skols :: Implication -> [TyVar]
ic_skols = [TyVar]
skols
, ic_given :: Implication -> [TyVar]
ic_given = [TyVar]
given, ic_no_eqs :: Implication -> Bool
ic_no_eqs = Bool
no_eqs
, ic_wanted :: Implication -> WantedConstraints
ic_wanted = WantedConstraints
wanted, ic_status :: Implication -> ImplicStatus
ic_status = ImplicStatus
status
, ic_binds :: Implication -> EvBindsVar
ic_binds = EvBindsVar
binds
, ic_need_inner :: Implication -> TcTyVarSet
ic_need_inner = TcTyVarSet
need_in, ic_need_outer :: Implication -> TcTyVarSet
ic_need_outer = TcTyVarSet
need_out
, ic_info :: Implication -> SkolemInfo
ic_info = SkolemInfo
info })
= SDoc -> Int -> SDoc -> SDoc
hang (FilePath -> SDoc
text "Implic" SDoc -> SDoc -> SDoc
<+> SDoc
lbrace)
2 ([SDoc] -> SDoc
sep [ FilePath -> SDoc
text "TcLevel =" SDoc -> SDoc -> SDoc
<+> TcLevel -> SDoc
forall a. Outputable a => a -> SDoc
ppr TcLevel
tclvl
, FilePath -> SDoc
text "Skolems =" SDoc -> SDoc -> SDoc
<+> [TyVar] -> SDoc
pprTyVars [TyVar]
skols
, FilePath -> SDoc
text "No-eqs =" SDoc -> SDoc -> SDoc
<+> Bool -> SDoc
forall a. Outputable a => a -> SDoc
ppr Bool
no_eqs
, FilePath -> SDoc
text "Status =" SDoc -> SDoc -> SDoc
<+> ImplicStatus -> SDoc
forall a. Outputable a => a -> SDoc
ppr ImplicStatus
status
, SDoc -> Int -> SDoc -> SDoc
hang (FilePath -> SDoc
text "Given =") 2 ([TyVar] -> SDoc
pprEvVars [TyVar]
given)
, SDoc -> Int -> SDoc -> SDoc
hang (FilePath -> SDoc
text "Wanted =") 2 (WantedConstraints -> SDoc
forall a. Outputable a => a -> SDoc
ppr WantedConstraints
wanted)
, FilePath -> SDoc
text "Binds =" SDoc -> SDoc -> SDoc
<+> EvBindsVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr EvBindsVar
binds
, SDoc -> SDoc
whenPprDebug (FilePath -> SDoc
text "Needed inner =" SDoc -> SDoc -> SDoc
<+> TcTyVarSet -> SDoc
forall a. Outputable a => a -> SDoc
ppr TcTyVarSet
need_in)
, SDoc -> SDoc
whenPprDebug (FilePath -> SDoc
text "Needed outer =" SDoc -> SDoc -> SDoc
<+> TcTyVarSet -> SDoc
forall a. Outputable a => a -> SDoc
ppr TcTyVarSet
need_out)
, SkolemInfo -> SDoc
pprSkolInfo SkolemInfo
info ] SDoc -> SDoc -> SDoc
<+> SDoc
rbrace)
instance Outputable ImplicStatus where
ppr :: ImplicStatus -> SDoc
ppr IC_Insoluble = FilePath -> SDoc
text "Insoluble"
ppr IC_BadTelescope = FilePath -> SDoc
text "Bad telescope"
ppr IC_Unsolved = FilePath -> SDoc
text "Unsolved"
ppr (IC_Solved { ics_dead :: ImplicStatus -> [TyVar]
ics_dead = [TyVar]
dead })
= FilePath -> SDoc
text "Solved" SDoc -> SDoc -> SDoc
<+> (SDoc -> SDoc
braces (FilePath -> SDoc
text "Dead givens =" SDoc -> SDoc -> SDoc
<+> [TyVar] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [TyVar]
dead))
pprEvVars :: [EvVar] -> SDoc
pprEvVars :: [TyVar] -> SDoc
pprEvVars ev_vars :: [TyVar]
ev_vars = [SDoc] -> SDoc
vcat ((TyVar -> SDoc) -> [TyVar] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map TyVar -> SDoc
pprEvVarWithType [TyVar]
ev_vars)
pprEvVarTheta :: [EvVar] -> SDoc
pprEvVarTheta :: [TyVar] -> SDoc
pprEvVarTheta ev_vars :: [TyVar]
ev_vars = [Type] -> SDoc
pprTheta ((TyVar -> Type) -> [TyVar] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map TyVar -> Type
evVarPred [TyVar]
ev_vars)
pprEvVarWithType :: EvVar -> SDoc
pprEvVarWithType :: TyVar -> SDoc
pprEvVarWithType v :: TyVar
v = TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
v SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> Type -> SDoc
pprType (TyVar -> Type
evVarPred TyVar
v)
wrapTypeWithImplication :: Type -> Implication -> Type
wrapTypeWithImplication :: Type -> Implication -> Type
wrapTypeWithImplication ty :: Type
ty impl :: Implication
impl = Type -> [TyVar] -> [Type] -> Type
wrapType Type
ty [TyVar]
mentioned_skols [Type]
givens
where givens :: [Type]
givens = (TyVar -> Type) -> [TyVar] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map TyVar -> Type
idType ([TyVar] -> [Type]) -> [TyVar] -> [Type]
forall a b. (a -> b) -> a -> b
$ Implication -> [TyVar]
ic_given Implication
impl
skols :: [TyVar]
skols = Implication -> [TyVar]
ic_skols Implication
impl
freeVars :: TcTyVarSet
freeVars = FV -> TcTyVarSet
fvVarSet (FV -> TcTyVarSet) -> FV -> TcTyVarSet
forall a b. (a -> b) -> a -> b
$ [Type] -> FV
tyCoFVsOfTypes (Type
tyType -> [Type] -> [Type]
forall a. a -> [a] -> [a]
:[Type]
givens)
mentioned_skols :: [TyVar]
mentioned_skols = (TyVar -> Bool) -> [TyVar] -> [TyVar]
forall a. (a -> Bool) -> [a] -> [a]
filter (TyVar -> TcTyVarSet -> Bool
`elemVarSet` TcTyVarSet
freeVars) [TyVar]
skols
wrapType :: Type -> [TyVar] -> [PredType] -> Type
wrapType :: Type -> [TyVar] -> [Type] -> Type
wrapType ty :: Type
ty skols :: [TyVar]
skols givens :: [Type]
givens = [TyVar] -> Type -> Type
mkSpecForAllTys [TyVar]
skols (Type -> Type) -> Type -> Type
forall a b. (a -> b) -> a -> b
$ [Type] -> Type -> Type
mkFunTys [Type]
givens Type
ty
data TcEvDest
= EvVarDest EvVar
| HoleDest CoercionHole
data CtEvidence
= CtGiven
{ CtEvidence -> Type
ctev_pred :: TcPredType
, CtEvidence -> TyVar
ctev_evar :: EvVar
, CtEvidence -> CtLoc
ctev_loc :: CtLoc }
| CtWanted
{ ctev_pred :: TcPredType
, CtEvidence -> TcEvDest
ctev_dest :: TcEvDest
, CtEvidence -> ShadowInfo
ctev_nosh :: ShadowInfo
, ctev_loc :: CtLoc }
| CtDerived
{ ctev_pred :: TcPredType
, ctev_loc :: CtLoc }
ctEvPred :: CtEvidence -> TcPredType
ctEvPred :: CtEvidence -> Type
ctEvPred = CtEvidence -> Type
ctev_pred
ctEvLoc :: CtEvidence -> CtLoc
ctEvLoc :: CtEvidence -> CtLoc
ctEvLoc = CtEvidence -> CtLoc
ctev_loc
ctEvOrigin :: CtEvidence -> CtOrigin
ctEvOrigin :: CtEvidence -> CtOrigin
ctEvOrigin = CtLoc -> CtOrigin
ctLocOrigin (CtLoc -> CtOrigin)
-> (CtEvidence -> CtLoc) -> CtEvidence -> CtOrigin
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CtEvidence -> CtLoc
ctEvLoc
ctEvEqRel :: CtEvidence -> EqRel
ctEvEqRel :: CtEvidence -> EqRel
ctEvEqRel = Type -> EqRel
predTypeEqRel (Type -> EqRel) -> (CtEvidence -> Type) -> CtEvidence -> EqRel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CtEvidence -> Type
ctEvPred
ctEvRole :: CtEvidence -> Role
ctEvRole :: CtEvidence -> Role
ctEvRole = EqRel -> Role
eqRelRole (EqRel -> Role) -> (CtEvidence -> EqRel) -> CtEvidence -> Role
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CtEvidence -> EqRel
ctEvEqRel
ctEvTerm :: CtEvidence -> EvTerm
ctEvTerm :: CtEvidence -> EvTerm
ctEvTerm ev :: CtEvidence
ev = EvExpr -> EvTerm
EvExpr (CtEvidence -> EvExpr
ctEvExpr CtEvidence
ev)
ctEvExpr :: CtEvidence -> EvExpr
ctEvExpr :: CtEvidence -> EvExpr
ctEvExpr ev :: CtEvidence
ev@(CtWanted { ctev_dest :: CtEvidence -> TcEvDest
ctev_dest = HoleDest _ })
= Coercion -> EvExpr
forall b. Coercion -> Expr b
Coercion (Coercion -> EvExpr) -> Coercion -> EvExpr
forall a b. (a -> b) -> a -> b
$ HasDebugCallStack => CtEvidence -> Coercion
CtEvidence -> Coercion
ctEvCoercion CtEvidence
ev
ctEvExpr ev :: CtEvidence
ev = TyVar -> EvExpr
evId (CtEvidence -> TyVar
ctEvEvId CtEvidence
ev)
ctEvCoercion :: HasDebugCallStack => CtEvidence -> Coercion
ctEvCoercion :: CtEvidence -> Coercion
ctEvCoercion (CtGiven { ctev_evar :: CtEvidence -> TyVar
ctev_evar = TyVar
ev_id })
= TyVar -> Coercion
mkTcCoVarCo TyVar
ev_id
ctEvCoercion (CtWanted { ctev_dest :: CtEvidence -> TcEvDest
ctev_dest = TcEvDest
dest })
| HoleDest hole :: CoercionHole
hole <- TcEvDest
dest
=
CoercionHole -> Coercion
mkHoleCo CoercionHole
hole
ctEvCoercion ev :: CtEvidence
ev
= FilePath -> SDoc -> Coercion
forall a. HasCallStack => FilePath -> SDoc -> a
pprPanic "ctEvCoercion" (CtEvidence -> SDoc
forall a. Outputable a => a -> SDoc
ppr CtEvidence
ev)
ctEvEvId :: CtEvidence -> EvVar
ctEvEvId :: CtEvidence -> TyVar
ctEvEvId (CtWanted { ctev_dest :: CtEvidence -> TcEvDest
ctev_dest = EvVarDest ev :: TyVar
ev }) = TyVar
ev
ctEvEvId (CtWanted { ctev_dest :: CtEvidence -> TcEvDest
ctev_dest = HoleDest h :: CoercionHole
h }) = CoercionHole -> TyVar
coHoleCoVar CoercionHole
h
ctEvEvId (CtGiven { ctev_evar :: CtEvidence -> TyVar
ctev_evar = TyVar
ev }) = TyVar
ev
ctEvEvId ctev :: CtEvidence
ctev@(CtDerived {}) = FilePath -> SDoc -> TyVar
forall a. HasCallStack => FilePath -> SDoc -> a
pprPanic "ctEvId:" (CtEvidence -> SDoc
forall a. Outputable a => a -> SDoc
ppr CtEvidence
ctev)
instance Outputable TcEvDest where
ppr :: TcEvDest -> SDoc
ppr (HoleDest h :: CoercionHole
h) = FilePath -> SDoc
text "hole" SDoc -> SDoc -> SDoc
<> CoercionHole -> SDoc
forall a. Outputable a => a -> SDoc
ppr CoercionHole
h
ppr (EvVarDest ev :: TyVar
ev) = TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
ev
instance Outputable CtEvidence where
ppr :: CtEvidence -> SDoc
ppr ev :: CtEvidence
ev = CtFlavour -> SDoc
forall a. Outputable a => a -> SDoc
ppr (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev)
SDoc -> SDoc -> SDoc
<+> SDoc
pp_ev
SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
braces (SubGoalDepth -> SDoc
forall a. Outputable a => a -> SDoc
ppr (CtLoc -> SubGoalDepth
ctl_depth (CtEvidence -> CtLoc
ctEvLoc CtEvidence
ev))) SDoc -> SDoc -> SDoc
<> SDoc
dcolon
SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr (CtEvidence -> Type
ctEvPred CtEvidence
ev)
where
pp_ev :: SDoc
pp_ev = case CtEvidence
ev of
CtGiven { ctev_evar :: CtEvidence -> TyVar
ctev_evar = TyVar
v } -> TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
v
CtWanted {ctev_dest :: CtEvidence -> TcEvDest
ctev_dest = TcEvDest
d } -> TcEvDest -> SDoc
forall a. Outputable a => a -> SDoc
ppr TcEvDest
d
CtDerived {} -> FilePath -> SDoc
text "_"
isWanted :: CtEvidence -> Bool
isWanted :: CtEvidence -> Bool
isWanted (CtWanted {}) = Bool
True
isWanted _ = Bool
False
isGiven :: CtEvidence -> Bool
isGiven :: CtEvidence -> Bool
isGiven (CtGiven {}) = Bool
True
isGiven _ = Bool
False
isDerived :: CtEvidence -> Bool
isDerived :: CtEvidence -> Bool
isDerived (CtDerived {}) = Bool
True
isDerived _ = Bool
False
data CtFlavour
= Given
| Wanted ShadowInfo
| Derived
deriving CtFlavour -> CtFlavour -> Bool
(CtFlavour -> CtFlavour -> Bool)
-> (CtFlavour -> CtFlavour -> Bool) -> Eq CtFlavour
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CtFlavour -> CtFlavour -> Bool
$c/= :: CtFlavour -> CtFlavour -> Bool
== :: CtFlavour -> CtFlavour -> Bool
$c== :: CtFlavour -> CtFlavour -> Bool
Eq
data ShadowInfo
= WDeriv
| WOnly
deriving( ShadowInfo -> ShadowInfo -> Bool
(ShadowInfo -> ShadowInfo -> Bool)
-> (ShadowInfo -> ShadowInfo -> Bool) -> Eq ShadowInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShadowInfo -> ShadowInfo -> Bool
$c/= :: ShadowInfo -> ShadowInfo -> Bool
== :: ShadowInfo -> ShadowInfo -> Bool
$c== :: ShadowInfo -> ShadowInfo -> Bool
Eq )
isGivenOrWDeriv :: CtFlavour -> Bool
isGivenOrWDeriv :: CtFlavour -> Bool
isGivenOrWDeriv Given = Bool
True
isGivenOrWDeriv (Wanted WDeriv) = Bool
True
isGivenOrWDeriv _ = Bool
False
instance Outputable CtFlavour where
ppr :: CtFlavour -> SDoc
ppr Given = FilePath -> SDoc
text "[G]"
ppr (Wanted WDeriv) = FilePath -> SDoc
text "[WD]"
ppr (Wanted WOnly) = FilePath -> SDoc
text "[W]"
ppr Derived = FilePath -> SDoc
text "[D]"
ctEvFlavour :: CtEvidence -> CtFlavour
ctEvFlavour :: CtEvidence -> CtFlavour
ctEvFlavour (CtWanted { ctev_nosh :: CtEvidence -> ShadowInfo
ctev_nosh = ShadowInfo
nosh }) = ShadowInfo -> CtFlavour
Wanted ShadowInfo
nosh
ctEvFlavour (CtGiven {}) = CtFlavour
Given
ctEvFlavour (CtDerived {}) = CtFlavour
Derived
type CtFlavourRole = (CtFlavour, EqRel)
ctEvFlavourRole :: CtEvidence -> CtFlavourRole
ctEvFlavourRole :: CtEvidence -> CtFlavourRole
ctEvFlavourRole ev :: CtEvidence
ev = (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev, CtEvidence -> EqRel
ctEvEqRel CtEvidence
ev)
ctFlavourRole :: Ct -> CtFlavourRole
ctFlavourRole :: Ct -> CtFlavourRole
ctFlavourRole (CDictCan { cc_ev :: Ct -> CtEvidence
cc_ev = CtEvidence
ev })
= (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev, EqRel
NomEq)
ctFlavourRole (CTyEqCan { cc_ev :: Ct -> CtEvidence
cc_ev = CtEvidence
ev, cc_eq_rel :: Ct -> EqRel
cc_eq_rel = EqRel
eq_rel })
= (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev, EqRel
eq_rel)
ctFlavourRole (CFunEqCan { cc_ev :: Ct -> CtEvidence
cc_ev = CtEvidence
ev })
= (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev, EqRel
NomEq)
ctFlavourRole (CHoleCan { cc_ev :: Ct -> CtEvidence
cc_ev = CtEvidence
ev })
= (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev, EqRel
NomEq)
ctFlavourRole ct :: Ct
ct
= CtEvidence -> CtFlavourRole
ctEvFlavourRole (Ct -> CtEvidence
ctEvidence Ct
ct)
eqCanRewrite :: EqRel -> EqRel -> Bool
eqCanRewrite :: EqRel -> EqRel -> Bool
eqCanRewrite NomEq _ = Bool
True
eqCanRewrite ReprEq ReprEq = Bool
True
eqCanRewrite ReprEq NomEq = Bool
False
eqCanRewriteFR :: CtFlavourRole -> CtFlavourRole -> Bool
eqCanRewriteFR :: CtFlavourRole -> CtFlavourRole -> Bool
eqCanRewriteFR (Given, r1 :: EqRel
r1) (_, r2 :: EqRel
r2) = EqRel -> EqRel -> Bool
eqCanRewrite EqRel
r1 EqRel
r2
eqCanRewriteFR (Wanted WDeriv, NomEq) (Derived, NomEq) = Bool
True
eqCanRewriteFR (Derived, NomEq) (Derived, NomEq) = Bool
True
eqCanRewriteFR _ _ = Bool
False
eqMayRewriteFR :: CtFlavourRole -> CtFlavourRole -> Bool
eqMayRewriteFR :: CtFlavourRole -> CtFlavourRole -> Bool
eqMayRewriteFR (Wanted WDeriv, NomEq) (Wanted WDeriv, NomEq) = Bool
True
eqMayRewriteFR (Derived, NomEq) (Wanted WDeriv, NomEq) = Bool
True
eqMayRewriteFR fr1 :: CtFlavourRole
fr1 fr2 :: CtFlavourRole
fr2 = CtFlavourRole -> CtFlavourRole -> Bool
eqCanRewriteFR CtFlavourRole
fr1 CtFlavourRole
fr2
funEqCanDischarge
:: CtEvidence -> CtEvidence
-> ( SwapFlag
, Bool)
funEqCanDischarge :: CtEvidence -> CtEvidence -> (SwapFlag, Bool)
funEqCanDischarge ev1 :: CtEvidence
ev1 ev2 :: CtEvidence
ev2
= ASSERT2( ctEvEqRel ev1 == NomEq, ppr ev1 )
ASSERT2( ctEvEqRel ev2 == NomEq, ppr ev2 )
CtFlavour -> CtFlavour -> (SwapFlag, Bool)
funEqCanDischargeF (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev1) (CtEvidence -> CtFlavour
ctEvFlavour CtEvidence
ev2)
funEqCanDischargeF :: CtFlavour -> CtFlavour -> (SwapFlag, Bool)
funEqCanDischargeF :: CtFlavour -> CtFlavour -> (SwapFlag, Bool)
funEqCanDischargeF Given _ = (SwapFlag
NotSwapped, Bool
False)
funEqCanDischargeF _ Given = (SwapFlag
IsSwapped, Bool
False)
funEqCanDischargeF (Wanted WDeriv) _ = (SwapFlag
NotSwapped, Bool
False)
funEqCanDischargeF _ (Wanted WDeriv) = (SwapFlag
IsSwapped, Bool
True)
funEqCanDischargeF (Wanted WOnly) (Wanted WOnly) = (SwapFlag
NotSwapped, Bool
False)
funEqCanDischargeF (Wanted WOnly) Derived = (SwapFlag
NotSwapped, Bool
True)
funEqCanDischargeF Derived (Wanted WOnly) = (SwapFlag
IsSwapped, Bool
True)
funEqCanDischargeF Derived Derived = (SwapFlag
NotSwapped, Bool
False)
eqCanDischargeFR :: CtFlavourRole -> CtFlavourRole -> Bool
eqCanDischargeFR :: CtFlavourRole -> CtFlavourRole -> Bool
eqCanDischargeFR (f1 :: CtFlavour
f1,r1 :: EqRel
r1) (f2 :: CtFlavour
f2, r2 :: EqRel
r2) = EqRel -> EqRel -> Bool
eqCanRewrite EqRel
r1 EqRel
r2
Bool -> Bool -> Bool
&& CtFlavour -> CtFlavour -> Bool
eqCanDischargeF CtFlavour
f1 CtFlavour
f2
eqCanDischargeF :: CtFlavour -> CtFlavour -> Bool
eqCanDischargeF :: CtFlavour -> CtFlavour -> Bool
eqCanDischargeF Given _ = Bool
True
eqCanDischargeF (Wanted _) (Wanted _) = Bool
True
eqCanDischargeF (Wanted WDeriv) Derived = Bool
True
eqCanDischargeF Derived Derived = Bool
True
eqCanDischargeF _ _ = Bool
False
newtype SubGoalDepth = SubGoalDepth Int
deriving (SubGoalDepth -> SubGoalDepth -> Bool
(SubGoalDepth -> SubGoalDepth -> Bool)
-> (SubGoalDepth -> SubGoalDepth -> Bool) -> Eq SubGoalDepth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubGoalDepth -> SubGoalDepth -> Bool
$c/= :: SubGoalDepth -> SubGoalDepth -> Bool
== :: SubGoalDepth -> SubGoalDepth -> Bool
$c== :: SubGoalDepth -> SubGoalDepth -> Bool
Eq, Eq SubGoalDepth
Eq SubGoalDepth =>
(SubGoalDepth -> SubGoalDepth -> Ordering)
-> (SubGoalDepth -> SubGoalDepth -> Bool)
-> (SubGoalDepth -> SubGoalDepth -> Bool)
-> (SubGoalDepth -> SubGoalDepth -> Bool)
-> (SubGoalDepth -> SubGoalDepth -> Bool)
-> (SubGoalDepth -> SubGoalDepth -> SubGoalDepth)
-> (SubGoalDepth -> SubGoalDepth -> SubGoalDepth)
-> Ord SubGoalDepth
SubGoalDepth -> SubGoalDepth -> Bool
SubGoalDepth -> SubGoalDepth -> Ordering
SubGoalDepth -> SubGoalDepth -> SubGoalDepth
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SubGoalDepth -> SubGoalDepth -> SubGoalDepth
$cmin :: SubGoalDepth -> SubGoalDepth -> SubGoalDepth
max :: SubGoalDepth -> SubGoalDepth -> SubGoalDepth
$cmax :: SubGoalDepth -> SubGoalDepth -> SubGoalDepth
>= :: SubGoalDepth -> SubGoalDepth -> Bool
$c>= :: SubGoalDepth -> SubGoalDepth -> Bool
> :: SubGoalDepth -> SubGoalDepth -> Bool
$c> :: SubGoalDepth -> SubGoalDepth -> Bool
<= :: SubGoalDepth -> SubGoalDepth -> Bool
$c<= :: SubGoalDepth -> SubGoalDepth -> Bool
< :: SubGoalDepth -> SubGoalDepth -> Bool
$c< :: SubGoalDepth -> SubGoalDepth -> Bool
compare :: SubGoalDepth -> SubGoalDepth -> Ordering
$ccompare :: SubGoalDepth -> SubGoalDepth -> Ordering
$cp1Ord :: Eq SubGoalDepth
Ord, Rational -> SubGoalDepth -> SDoc
SubGoalDepth -> SDoc
(SubGoalDepth -> SDoc)
-> (Rational -> SubGoalDepth -> SDoc) -> Outputable SubGoalDepth
forall a. (a -> SDoc) -> (Rational -> a -> SDoc) -> Outputable a
pprPrec :: Rational -> SubGoalDepth -> SDoc
$cpprPrec :: Rational -> SubGoalDepth -> SDoc
ppr :: SubGoalDepth -> SDoc
$cppr :: SubGoalDepth -> SDoc
Outputable)
initialSubGoalDepth :: SubGoalDepth
initialSubGoalDepth :: SubGoalDepth
initialSubGoalDepth = Int -> SubGoalDepth
SubGoalDepth 0
bumpSubGoalDepth :: SubGoalDepth -> SubGoalDepth
bumpSubGoalDepth :: SubGoalDepth -> SubGoalDepth
bumpSubGoalDepth (SubGoalDepth n :: Int
n) = Int -> SubGoalDepth
SubGoalDepth (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1)
maxSubGoalDepth :: SubGoalDepth -> SubGoalDepth -> SubGoalDepth
maxSubGoalDepth :: SubGoalDepth -> SubGoalDepth -> SubGoalDepth
maxSubGoalDepth (SubGoalDepth n :: Int
n) (SubGoalDepth m :: Int
m) = Int -> SubGoalDepth
SubGoalDepth (Int
n Int -> Int -> Int
forall a. Ord a => a -> a -> a
`max` Int
m)
subGoalDepthExceeded :: DynFlags -> SubGoalDepth -> Bool
subGoalDepthExceeded :: DynFlags -> SubGoalDepth -> Bool
subGoalDepthExceeded dflags :: DynFlags
dflags (SubGoalDepth d :: Int
d)
= Int -> IntWithInf
mkIntWithInf Int
d IntWithInf -> IntWithInf -> Bool
forall a. Ord a => a -> a -> Bool
> DynFlags -> IntWithInf
reductionDepth DynFlags
dflags
data CtLoc = CtLoc { CtLoc -> CtOrigin
ctl_origin :: CtOrigin
, CtLoc -> TcLclEnv
ctl_env :: TcLclEnv
, CtLoc -> Maybe TypeOrKind
ctl_t_or_k :: Maybe TypeOrKind
, CtLoc -> SubGoalDepth
ctl_depth :: !SubGoalDepth }
mkKindLoc :: TcType -> TcType
-> CtLoc -> CtLoc
mkKindLoc :: Type -> Type -> CtLoc -> CtLoc
mkKindLoc s1 :: Type
s1 s2 :: Type
s2 loc :: CtLoc
loc = CtLoc -> CtOrigin -> CtLoc
setCtLocOrigin (CtLoc -> CtLoc
toKindLoc CtLoc
loc)
(Type -> Maybe Type -> CtOrigin -> Maybe TypeOrKind -> CtOrigin
KindEqOrigin Type
s1 (Type -> Maybe Type
forall a. a -> Maybe a
Just Type
s2) (CtLoc -> CtOrigin
ctLocOrigin CtLoc
loc)
(CtLoc -> Maybe TypeOrKind
ctLocTypeOrKind_maybe CtLoc
loc))
toKindLoc :: CtLoc -> CtLoc
toKindLoc :: CtLoc -> CtLoc
toKindLoc loc :: CtLoc
loc = CtLoc
loc { ctl_t_or_k :: Maybe TypeOrKind
ctl_t_or_k = TypeOrKind -> Maybe TypeOrKind
forall a. a -> Maybe a
Just TypeOrKind
KindLevel }
mkGivenLoc :: TcLevel -> SkolemInfo -> TcLclEnv -> CtLoc
mkGivenLoc :: TcLevel -> SkolemInfo -> TcLclEnv -> CtLoc
mkGivenLoc tclvl :: TcLevel
tclvl skol_info :: SkolemInfo
skol_info env :: TcLclEnv
env
= $WCtLoc :: CtOrigin -> TcLclEnv -> Maybe TypeOrKind -> SubGoalDepth -> CtLoc
CtLoc { ctl_origin :: CtOrigin
ctl_origin = SkolemInfo -> CtOrigin
GivenOrigin SkolemInfo
skol_info
, ctl_env :: TcLclEnv
ctl_env = TcLclEnv
env { tcl_tclvl :: TcLevel
tcl_tclvl = TcLevel
tclvl }
, ctl_t_or_k :: Maybe TypeOrKind
ctl_t_or_k = Maybe TypeOrKind
forall a. Maybe a
Nothing
, ctl_depth :: SubGoalDepth
ctl_depth = SubGoalDepth
initialSubGoalDepth }
ctLocEnv :: CtLoc -> TcLclEnv
ctLocEnv :: CtLoc -> TcLclEnv
ctLocEnv = CtLoc -> TcLclEnv
ctl_env
ctLocLevel :: CtLoc -> TcLevel
ctLocLevel :: CtLoc -> TcLevel
ctLocLevel loc :: CtLoc
loc = TcLclEnv -> TcLevel
tcl_tclvl (CtLoc -> TcLclEnv
ctLocEnv CtLoc
loc)
ctLocDepth :: CtLoc -> SubGoalDepth
ctLocDepth :: CtLoc -> SubGoalDepth
ctLocDepth = CtLoc -> SubGoalDepth
ctl_depth
ctLocOrigin :: CtLoc -> CtOrigin
ctLocOrigin :: CtLoc -> CtOrigin
ctLocOrigin = CtLoc -> CtOrigin
ctl_origin
ctLocSpan :: CtLoc -> RealSrcSpan
ctLocSpan :: CtLoc -> RealSrcSpan
ctLocSpan (CtLoc { ctl_env :: CtLoc -> TcLclEnv
ctl_env = TcLclEnv
lcl}) = TcLclEnv -> RealSrcSpan
tcl_loc TcLclEnv
lcl
ctLocTypeOrKind_maybe :: CtLoc -> Maybe TypeOrKind
ctLocTypeOrKind_maybe :: CtLoc -> Maybe TypeOrKind
ctLocTypeOrKind_maybe = CtLoc -> Maybe TypeOrKind
ctl_t_or_k
setCtLocSpan :: CtLoc -> RealSrcSpan -> CtLoc
setCtLocSpan :: CtLoc -> RealSrcSpan -> CtLoc
setCtLocSpan ctl :: CtLoc
ctl@(CtLoc { ctl_env :: CtLoc -> TcLclEnv
ctl_env = TcLclEnv
lcl }) loc :: RealSrcSpan
loc = CtLoc -> TcLclEnv -> CtLoc
setCtLocEnv CtLoc
ctl (TcLclEnv
lcl { tcl_loc :: RealSrcSpan
tcl_loc = RealSrcSpan
loc })
bumpCtLocDepth :: CtLoc -> CtLoc
bumpCtLocDepth :: CtLoc -> CtLoc
bumpCtLocDepth loc :: CtLoc
loc@(CtLoc { ctl_depth :: CtLoc -> SubGoalDepth
ctl_depth = SubGoalDepth
d }) = CtLoc
loc { ctl_depth :: SubGoalDepth
ctl_depth = SubGoalDepth -> SubGoalDepth
bumpSubGoalDepth SubGoalDepth
d }
setCtLocOrigin :: CtLoc -> CtOrigin -> CtLoc
setCtLocOrigin :: CtLoc -> CtOrigin -> CtLoc
setCtLocOrigin ctl :: CtLoc
ctl orig :: CtOrigin
orig = CtLoc
ctl { ctl_origin :: CtOrigin
ctl_origin = CtOrigin
orig }
updateCtLocOrigin :: CtLoc -> (CtOrigin -> CtOrigin) -> CtLoc
updateCtLocOrigin :: CtLoc -> (CtOrigin -> CtOrigin) -> CtLoc
updateCtLocOrigin ctl :: CtLoc
ctl@(CtLoc { ctl_origin :: CtLoc -> CtOrigin
ctl_origin = CtOrigin
orig }) upd :: CtOrigin -> CtOrigin
upd
= CtLoc
ctl { ctl_origin :: CtOrigin
ctl_origin = CtOrigin -> CtOrigin
upd CtOrigin
orig }
setCtLocEnv :: CtLoc -> TcLclEnv -> CtLoc
setCtLocEnv :: CtLoc -> TcLclEnv -> CtLoc
setCtLocEnv ctl :: CtLoc
ctl env :: TcLclEnv
env = CtLoc
ctl { ctl_env :: TcLclEnv
ctl_env = TcLclEnv
env }
pushErrCtxt :: CtOrigin -> ErrCtxt -> CtLoc -> CtLoc
pushErrCtxt :: CtOrigin -> ErrCtxt -> CtLoc -> CtLoc
pushErrCtxt o :: CtOrigin
o err :: ErrCtxt
err loc :: CtLoc
loc@(CtLoc { ctl_env :: CtLoc -> TcLclEnv
ctl_env = TcLclEnv
lcl })
= CtLoc
loc { ctl_origin :: CtOrigin
ctl_origin = CtOrigin
o, ctl_env :: TcLclEnv
ctl_env = TcLclEnv
lcl { tcl_ctxt :: [ErrCtxt]
tcl_ctxt = ErrCtxt
err ErrCtxt -> [ErrCtxt] -> [ErrCtxt]
forall a. a -> [a] -> [a]
: TcLclEnv -> [ErrCtxt]
tcl_ctxt TcLclEnv
lcl } }
pushErrCtxtSameOrigin :: ErrCtxt -> CtLoc -> CtLoc
pushErrCtxtSameOrigin :: ErrCtxt -> CtLoc -> CtLoc
pushErrCtxtSameOrigin err :: ErrCtxt
err loc :: CtLoc
loc@(CtLoc { ctl_env :: CtLoc -> TcLclEnv
ctl_env = TcLclEnv
lcl })
= CtLoc
loc { ctl_env :: TcLclEnv
ctl_env = TcLclEnv
lcl { tcl_ctxt :: [ErrCtxt]
tcl_ctxt = ErrCtxt
err ErrCtxt -> [ErrCtxt] -> [ErrCtxt]
forall a. a -> [a] -> [a]
: TcLclEnv -> [ErrCtxt]
tcl_ctxt TcLclEnv
lcl } }
data SkolemInfo
= SigSkol
UserTypeCtxt
TcType
[(Name,TcTyVar)]
| SigTypeSkol UserTypeCtxt
| ForAllSkol SDoc
| DerivSkol Type
| InstSkol
| InstSC TypeSize
| FamInstSkol
| PatSkol
ConLike
(HsMatchContext Name)
| ArrowSkol
| IPSkol [HsIPName]
| RuleSkol RuleName
| InferSkol [(Name,TcType)]
| BracketSkol
| UnifyForAllSkol
TcType
| TyConSkol TyConFlavour Name
| DataConSkol Name
| ReifySkol
| QuantCtxtSkol
| UnkSkol
instance Outputable SkolemInfo where
ppr :: SkolemInfo -> SDoc
ppr = SkolemInfo -> SDoc
pprSkolInfo
pprSkolInfo :: SkolemInfo -> SDoc
pprSkolInfo :: SkolemInfo -> SDoc
pprSkolInfo (SigSkol cx :: UserTypeCtxt
cx ty :: Type
ty _) = UserTypeCtxt -> Type -> SDoc
pprSigSkolInfo UserTypeCtxt
cx Type
ty
pprSkolInfo (SigTypeSkol cx :: UserTypeCtxt
cx) = UserTypeCtxt -> SDoc
pprUserTypeCtxt UserTypeCtxt
cx
pprSkolInfo (ForAllSkol doc :: SDoc
doc) = SDoc -> SDoc
quotes SDoc
doc
pprSkolInfo (IPSkol ips :: [HsIPName]
ips) = FilePath -> SDoc
text "the implicit-parameter binding" SDoc -> SDoc -> SDoc
<> [HsIPName] -> SDoc
forall a. [a] -> SDoc
plural [HsIPName]
ips SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "for"
SDoc -> SDoc -> SDoc
<+> (HsIPName -> SDoc) -> [HsIPName] -> SDoc
forall a. (a -> SDoc) -> [a] -> SDoc
pprWithCommas HsIPName -> SDoc
forall a. Outputable a => a -> SDoc
ppr [HsIPName]
ips
pprSkolInfo (DerivSkol pred :: Type
pred) = FilePath -> SDoc
text "the deriving clause for" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
pred)
pprSkolInfo InstSkol = FilePath -> SDoc
text "the instance declaration"
pprSkolInfo (InstSC n :: IntWithInf
n) = FilePath -> SDoc
text "the instance declaration" SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
whenPprDebug (SDoc -> SDoc
parens (IntWithInf -> SDoc
forall a. Outputable a => a -> SDoc
ppr IntWithInf
n))
pprSkolInfo FamInstSkol = FilePath -> SDoc
text "a family instance declaration"
pprSkolInfo BracketSkol = FilePath -> SDoc
text "a Template Haskell bracket"
pprSkolInfo (RuleSkol name :: RuleName
name) = FilePath -> SDoc
text "the RULE" SDoc -> SDoc -> SDoc
<+> RuleName -> SDoc
pprRuleName RuleName
name
pprSkolInfo ArrowSkol = FilePath -> SDoc
text "an arrow form"
pprSkolInfo (PatSkol cl :: ConLike
cl mc :: HsMatchContext Name
mc) = [SDoc] -> SDoc
sep [ ConLike -> SDoc
pprPatSkolInfo ConLike
cl
, FilePath -> SDoc
text "in" SDoc -> SDoc -> SDoc
<+> HsMatchContext Name -> SDoc
forall id.
(Outputable (NameOrRdrName id), Outputable id) =>
HsMatchContext id -> SDoc
pprMatchContext HsMatchContext Name
mc ]
pprSkolInfo (InferSkol ids :: [(Name, Type)]
ids) = SDoc -> Int -> SDoc -> SDoc
hang (FilePath -> SDoc
text "the inferred type" SDoc -> SDoc -> SDoc
<> [(Name, Type)] -> SDoc
forall a. [a] -> SDoc
plural [(Name, Type)]
ids SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "of")
2 ([SDoc] -> SDoc
vcat [ Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
ty
| (name :: Name
name,ty :: Type
ty) <- [(Name, Type)]
ids ])
pprSkolInfo (UnifyForAllSkol ty :: Type
ty) = FilePath -> SDoc
text "the type" SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
ty
pprSkolInfo (TyConSkol flav :: TyConFlavour
flav name :: Name
name) = FilePath -> SDoc
text "the" SDoc -> SDoc -> SDoc
<+> TyConFlavour -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyConFlavour
flav SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "declaration for" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name)
pprSkolInfo (DataConSkol name :: Name
name)= FilePath -> SDoc
text "the data constructor" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name)
pprSkolInfo ReifySkol = FilePath -> SDoc
text "the type being reified"
pprSkolInfo (QuantCtxtSkol {}) = FilePath -> SDoc
text "a quantified context"
pprSkolInfo UnkSkol = WARN( True, text "pprSkolInfo: UnkSkol" ) text "UnkSkol"
pprSigSkolInfo :: UserTypeCtxt -> TcType -> SDoc
pprSigSkolInfo :: UserTypeCtxt -> Type -> SDoc
pprSigSkolInfo ctxt :: UserTypeCtxt
ctxt ty :: Type
ty
= case UserTypeCtxt
ctxt of
FunSigCtxt f :: Name
f _ -> [SDoc] -> SDoc
vcat [ FilePath -> SDoc
text "the type signature for:"
, Int -> SDoc -> SDoc
nest 2 (Name -> SDoc
forall a. OutputableBndr a => a -> SDoc
pprPrefixOcc Name
f SDoc -> SDoc -> SDoc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
<+> Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
ty) ]
PatSynCtxt {} -> UserTypeCtxt -> SDoc
pprUserTypeCtxt UserTypeCtxt
ctxt
_ -> [SDoc] -> SDoc
vcat [ UserTypeCtxt -> SDoc
pprUserTypeCtxt UserTypeCtxt
ctxt SDoc -> SDoc -> SDoc
<> SDoc
colon
, Int -> SDoc -> SDoc
nest 2 (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
ty) ]
pprPatSkolInfo :: ConLike -> SDoc
pprPatSkolInfo :: ConLike -> SDoc
pprPatSkolInfo (RealDataCon dc :: DataCon
dc)
= [SDoc] -> SDoc
sep [ FilePath -> SDoc
text "a pattern with constructor:"
, Int -> SDoc -> SDoc
nest 2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ DataCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr DataCon
dc SDoc -> SDoc -> SDoc
<+> SDoc
dcolon
SDoc -> SDoc -> SDoc
<+> Type -> SDoc
pprType (DataCon -> Type
dataConUserType DataCon
dc) SDoc -> SDoc -> SDoc
<> SDoc
comma ]
pprPatSkolInfo (PatSynCon ps :: PatSyn
ps)
= [SDoc] -> SDoc
sep [ FilePath -> SDoc
text "a pattern with pattern synonym:"
, Int -> SDoc -> SDoc
nest 2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ PatSyn -> SDoc
forall a. Outputable a => a -> SDoc
ppr PatSyn
ps SDoc -> SDoc -> SDoc
<+> SDoc
dcolon
SDoc -> SDoc -> SDoc
<+> PatSyn -> SDoc
pprPatSynType PatSyn
ps SDoc -> SDoc -> SDoc
<> SDoc
comma ]
data CtOrigin
= GivenOrigin SkolemInfo
| OccurrenceOf Name
| OccurrenceOfRecSel RdrName
| AppOrigin
| SpecPragOrigin UserTypeCtxt
| TypeEqOrigin { CtOrigin -> Type
uo_actual :: TcType
, CtOrigin -> Type
uo_expected :: TcType
, CtOrigin -> Maybe SDoc
uo_thing :: Maybe SDoc
, CtOrigin -> Bool
uo_visible :: Bool
}
| KindEqOrigin
TcType (Maybe TcType)
CtOrigin
(Maybe TypeOrKind)
| IPOccOrigin HsIPName
| OverLabelOrigin FastString
| LiteralOrigin (HsOverLit GhcRn)
| NegateOrigin
| ArithSeqOrigin (ArithSeqInfo GhcRn)
| AssocFamPatOrigin
| SectionOrigin
| TupleOrigin
| ExprSigOrigin
| PatSigOrigin
| PatOrigin
| ProvCtxtOrigin
(PatSynBind GhcRn GhcRn)
| RecordUpdOrigin
| ViewPatOrigin
| ScOrigin TypeSize
| DerivClauseOrigin
| DerivOriginDC DataCon Int Bool
| DerivOriginCoerce Id Type Type Bool
| StandAloneDerivOrigin
| DefaultOrigin
| DoOrigin
| DoPatOrigin (LPat GhcRn)
| MCompOrigin
| MCompPatOrigin (LPat GhcRn)
| IfOrigin
| ProcOrigin
| AnnOrigin
| FunDepOrigin1
PredType CtLoc
PredType CtLoc
| FunDepOrigin2
PredType CtOrigin
PredType SrcSpan
| HoleOrigin
| UnboundOccurrenceOf OccName
| ListOrigin
| StaticOrigin
| FailablePattern (LPat GhcTcId)
| Shouldn'tHappenOrigin String
| InstProvidedOrigin Module ClsInst
data TypeOrKind = TypeLevel | KindLevel
deriving TypeOrKind -> TypeOrKind -> Bool
(TypeOrKind -> TypeOrKind -> Bool)
-> (TypeOrKind -> TypeOrKind -> Bool) -> Eq TypeOrKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypeOrKind -> TypeOrKind -> Bool
$c/= :: TypeOrKind -> TypeOrKind -> Bool
== :: TypeOrKind -> TypeOrKind -> Bool
$c== :: TypeOrKind -> TypeOrKind -> Bool
Eq
instance Outputable TypeOrKind where
ppr :: TypeOrKind -> SDoc
ppr TypeLevel = FilePath -> SDoc
text "TypeLevel"
ppr KindLevel = FilePath -> SDoc
text "KindLevel"
isTypeLevel :: TypeOrKind -> Bool
isTypeLevel :: TypeOrKind -> Bool
isTypeLevel TypeLevel = Bool
True
isTypeLevel KindLevel = Bool
False
isKindLevel :: TypeOrKind -> Bool
isKindLevel :: TypeOrKind -> Bool
isKindLevel TypeLevel = Bool
False
isKindLevel KindLevel = Bool
True
isVisibleOrigin :: CtOrigin -> Bool
isVisibleOrigin :: CtOrigin -> Bool
isVisibleOrigin (TypeEqOrigin { uo_visible :: CtOrigin -> Bool
uo_visible = Bool
vis }) = Bool
vis
isVisibleOrigin (KindEqOrigin _ _ sub_orig :: CtOrigin
sub_orig _) = CtOrigin -> Bool
isVisibleOrigin CtOrigin
sub_orig
isVisibleOrigin _ = Bool
True
toInvisibleOrigin :: CtOrigin -> CtOrigin
toInvisibleOrigin :: CtOrigin -> CtOrigin
toInvisibleOrigin orig :: CtOrigin
orig@(TypeEqOrigin {}) = CtOrigin
orig { uo_visible :: Bool
uo_visible = Bool
False }
toInvisibleOrigin orig :: CtOrigin
orig = CtOrigin
orig
instance Outputable CtOrigin where
ppr :: CtOrigin -> SDoc
ppr = CtOrigin -> SDoc
pprCtOrigin
ctoHerald :: SDoc
ctoHerald :: SDoc
ctoHerald = FilePath -> SDoc
text "arising from"
lexprCtOrigin :: LHsExpr GhcRn -> CtOrigin
lexprCtOrigin :: LHsExpr GhcRn -> CtOrigin
lexprCtOrigin (L _ e :: HsExpr GhcRn
e) = HsExpr GhcRn -> CtOrigin
exprCtOrigin HsExpr GhcRn
e
exprCtOrigin :: HsExpr GhcRn -> CtOrigin
exprCtOrigin :: HsExpr GhcRn -> CtOrigin
exprCtOrigin (HsVar _ (L _ name :: IdP GhcRn
name)) = Name -> CtOrigin
OccurrenceOf Name
IdP GhcRn
name
exprCtOrigin (HsUnboundVar _ uv :: UnboundVar
uv) = OccName -> CtOrigin
UnboundOccurrenceOf (UnboundVar -> OccName
unboundVarOcc UnboundVar
uv)
exprCtOrigin (HsConLikeOut {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin HsConLikeOut"
exprCtOrigin (HsRecFld _ f :: AmbiguousFieldOcc GhcRn
f) = RdrName -> CtOrigin
OccurrenceOfRecSel (AmbiguousFieldOcc GhcRn -> RdrName
forall (p :: Pass). AmbiguousFieldOcc (GhcPass p) -> RdrName
rdrNameAmbiguousFieldOcc AmbiguousFieldOcc GhcRn
f)
exprCtOrigin (HsOverLabel _ _ l :: RuleName
l) = RuleName -> CtOrigin
OverLabelOrigin RuleName
l
exprCtOrigin (HsIPVar _ ip :: HsIPName
ip) = HsIPName -> CtOrigin
IPOccOrigin HsIPName
ip
exprCtOrigin (HsOverLit _ lit :: HsOverLit GhcRn
lit) = HsOverLit GhcRn -> CtOrigin
LiteralOrigin HsOverLit GhcRn
lit
exprCtOrigin (HsLit {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "concrete literal"
exprCtOrigin (HsLam _ matches :: MatchGroup GhcRn (LHsExpr GhcRn)
matches) = MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin
matchesCtOrigin MatchGroup GhcRn (LHsExpr GhcRn)
matches
exprCtOrigin (HsLamCase _ ms :: MatchGroup GhcRn (LHsExpr GhcRn)
ms) = MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin
matchesCtOrigin MatchGroup GhcRn (LHsExpr GhcRn)
ms
exprCtOrigin (HsApp _ e1 :: LHsExpr GhcRn
e1 _) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e1
exprCtOrigin (HsAppType _ e1 :: LHsExpr GhcRn
e1 _) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e1
exprCtOrigin (OpApp _ _ op :: LHsExpr GhcRn
op _) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
op
exprCtOrigin (NegApp _ e :: LHsExpr GhcRn
e _) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (HsPar _ e :: LHsExpr GhcRn
e) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (SectionL _ _ _) = CtOrigin
SectionOrigin
exprCtOrigin (SectionR _ _ _) = CtOrigin
SectionOrigin
exprCtOrigin (ExplicitTuple {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "explicit tuple"
exprCtOrigin ExplicitSum{} = FilePath -> CtOrigin
Shouldn'tHappenOrigin "explicit sum"
exprCtOrigin (HsCase _ _ matches :: MatchGroup GhcRn (LHsExpr GhcRn)
matches) = MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin
matchesCtOrigin MatchGroup GhcRn (LHsExpr GhcRn)
matches
exprCtOrigin (HsIf _ (Just syn :: SyntaxExpr GhcRn
syn) _ _ _) = HsExpr GhcRn -> CtOrigin
exprCtOrigin (SyntaxExpr GhcRn -> HsExpr GhcRn
forall p. SyntaxExpr p -> HsExpr p
syn_expr SyntaxExpr GhcRn
syn)
exprCtOrigin (HsIf {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "if expression"
exprCtOrigin (HsMultiIf _ rhs :: [LGRHS GhcRn (LHsExpr GhcRn)]
rhs) = [LGRHS GhcRn (LHsExpr GhcRn)] -> CtOrigin
lGRHSCtOrigin [LGRHS GhcRn (LHsExpr GhcRn)]
rhs
exprCtOrigin (HsLet _ _ e :: LHsExpr GhcRn
e) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (HsDo {}) = CtOrigin
DoOrigin
exprCtOrigin (ExplicitList {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "list"
exprCtOrigin (RecordCon {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "record construction"
exprCtOrigin (RecordUpd {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "record update"
exprCtOrigin (ExprWithTySig {}) = CtOrigin
ExprSigOrigin
exprCtOrigin (ArithSeq {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "arithmetic sequence"
exprCtOrigin (HsSCC _ _ _ e :: LHsExpr GhcRn
e) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (HsCoreAnn _ _ _ e :: LHsExpr GhcRn
e) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (HsBracket {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "TH bracket"
exprCtOrigin (HsRnBracketOut {})= FilePath -> CtOrigin
Shouldn'tHappenOrigin "HsRnBracketOut"
exprCtOrigin (HsTcBracketOut {})= FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin HsTcBracketOut"
exprCtOrigin (HsSpliceE {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "TH splice"
exprCtOrigin (HsProc {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "proc"
exprCtOrigin (HsStatic {}) = FilePath -> CtOrigin
Shouldn'tHappenOrigin "static expression"
exprCtOrigin (HsArrApp {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin HsArrApp"
exprCtOrigin (HsArrForm {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin HsArrForm"
exprCtOrigin (HsTick _ _ e :: LHsExpr GhcRn
e) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (HsBinTick _ _ _ e :: LHsExpr GhcRn
e) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (HsTickPragma _ _ _ _ e :: LHsExpr GhcRn
e) = LHsExpr GhcRn -> CtOrigin
lexprCtOrigin LHsExpr GhcRn
e
exprCtOrigin (EWildPat {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin EWildPat"
exprCtOrigin (EAsPat {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin EAsPat"
exprCtOrigin (EViewPat {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin EViewPat"
exprCtOrigin (ELazyPat {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin ELazyPat"
exprCtOrigin (HsWrap {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin HsWrap"
exprCtOrigin (XExpr {}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "exprCtOrigin XExpr"
matchesCtOrigin :: MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin
matchesCtOrigin :: MatchGroup GhcRn (LHsExpr GhcRn) -> CtOrigin
matchesCtOrigin (MG { mg_alts :: forall p body. MatchGroup p body -> Located [LMatch p body]
mg_alts = Located [LMatch GhcRn (LHsExpr GhcRn)]
alts })
| L _ [L _ match :: Match GhcRn (LHsExpr GhcRn)
match] <- Located [LMatch GhcRn (LHsExpr GhcRn)]
alts
, Match { m_grhss :: forall p body. Match p body -> GRHSs p body
m_grhss = GRHSs GhcRn (LHsExpr GhcRn)
grhss } <- Match GhcRn (LHsExpr GhcRn)
match
= GRHSs GhcRn (LHsExpr GhcRn) -> CtOrigin
grhssCtOrigin GRHSs GhcRn (LHsExpr GhcRn)
grhss
| Bool
otherwise
= FilePath -> CtOrigin
Shouldn'tHappenOrigin "multi-way match"
matchesCtOrigin (XMatchGroup{}) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "matchesCtOrigin"
grhssCtOrigin :: GRHSs GhcRn (LHsExpr GhcRn) -> CtOrigin
grhssCtOrigin :: GRHSs GhcRn (LHsExpr GhcRn) -> CtOrigin
grhssCtOrigin (GRHSs { grhssGRHSs :: forall p body. GRHSs p body -> [LGRHS p body]
grhssGRHSs = [LGRHS GhcRn (LHsExpr GhcRn)]
lgrhss }) = [LGRHS GhcRn (LHsExpr GhcRn)] -> CtOrigin
lGRHSCtOrigin [LGRHS GhcRn (LHsExpr GhcRn)]
lgrhss
grhssCtOrigin (XGRHSs _) = FilePath -> CtOrigin
forall a. FilePath -> a
panic "grhssCtOrigin"
lGRHSCtOrigin :: [LGRHS GhcRn (LHsExpr GhcRn)] -> CtOrigin
lGRHSCtOrigin :: [LGRHS GhcRn (LHsExpr GhcRn)] -> CtOrigin
lGRHSCtOrigin [L _ (GRHS _ _ (L _ e :: HsExpr GhcRn
e))] = HsExpr GhcRn -> CtOrigin
exprCtOrigin HsExpr GhcRn
e
lGRHSCtOrigin [L _ (XGRHS _)] = FilePath -> CtOrigin
forall a. FilePath -> a
panic "lGRHSCtOrigin"
lGRHSCtOrigin _ = FilePath -> CtOrigin
Shouldn'tHappenOrigin "multi-way GRHS"
pprCtLoc :: CtLoc -> SDoc
pprCtLoc :: CtLoc -> SDoc
pprCtLoc (CtLoc { ctl_origin :: CtLoc -> CtOrigin
ctl_origin = CtOrigin
o, ctl_env :: CtLoc -> TcLclEnv
ctl_env = TcLclEnv
lcl})
= [SDoc] -> SDoc
sep [ CtOrigin -> SDoc
pprCtOrigin CtOrigin
o
, FilePath -> SDoc
text "at" SDoc -> SDoc -> SDoc
<+> RealSrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr (TcLclEnv -> RealSrcSpan
tcl_loc TcLclEnv
lcl)]
pprCtOrigin :: CtOrigin -> SDoc
pprCtOrigin :: CtOrigin -> SDoc
pprCtOrigin (GivenOrigin sk :: SkolemInfo
sk) = SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> SkolemInfo -> SDoc
forall a. Outputable a => a -> SDoc
ppr SkolemInfo
sk
pprCtOrigin (SpecPragOrigin ctxt :: UserTypeCtxt
ctxt)
= case UserTypeCtxt
ctxt of
FunSigCtxt n :: Name
n _ -> FilePath -> SDoc
text "a SPECIALISE pragma for" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
n)
SpecInstCtxt -> FilePath -> SDoc
text "a SPECIALISE INSTANCE pragma"
_ -> FilePath -> SDoc
text "a SPECIALISE pragma"
pprCtOrigin (FunDepOrigin1 pred1 :: Type
pred1 loc1 :: CtLoc
loc1 pred2 :: Type
pred2 loc2 :: CtLoc
loc2)
= SDoc -> Int -> SDoc -> SDoc
hang (SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "a functional dependency between constraints:")
2 ([SDoc] -> SDoc
vcat [ SDoc -> Int -> SDoc -> SDoc
hang (SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
pred1)) 2 (CtLoc -> SDoc
pprCtLoc CtLoc
loc1)
, SDoc -> Int -> SDoc -> SDoc
hang (SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
pred2)) 2 (CtLoc -> SDoc
pprCtLoc CtLoc
loc2) ])
pprCtOrigin (FunDepOrigin2 pred1 :: Type
pred1 orig1 :: CtOrigin
orig1 pred2 :: Type
pred2 loc2 :: SrcSpan
loc2)
= SDoc -> Int -> SDoc -> SDoc
hang (SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "a functional dependency between:")
2 ([SDoc] -> SDoc
vcat [ SDoc -> Int -> SDoc -> SDoc
hang (FilePath -> SDoc
text "constraint" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
pred1))
2 (CtOrigin -> SDoc
pprCtOrigin CtOrigin
orig1 )
, SDoc -> Int -> SDoc -> SDoc
hang (FilePath -> SDoc
text "instance" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
pred2))
2 (FilePath -> SDoc
text "at" SDoc -> SDoc -> SDoc
<+> SrcSpan -> SDoc
forall a. Outputable a => a -> SDoc
ppr SrcSpan
loc2) ])
pprCtOrigin (KindEqOrigin t1 :: Type
t1 (Just t2 :: Type
t2) _ _)
= SDoc -> Int -> SDoc -> SDoc
hang (SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "a kind equality arising from")
2 ([SDoc] -> SDoc
sep [Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
t1, Char -> SDoc
char '~', Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
t2])
pprCtOrigin AssocFamPatOrigin
= FilePath -> SDoc
text "when matching a family LHS with its class instance head"
pprCtOrigin (KindEqOrigin t1 :: Type
t1 Nothing _ _)
= SDoc -> Int -> SDoc -> SDoc
hang (SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "a kind equality when matching")
2 (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
t1)
pprCtOrigin (UnboundOccurrenceOf name :: OccName
name)
= SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "an undeclared identifier" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (OccName -> SDoc
forall a. Outputable a => a -> SDoc
ppr OccName
name)
pprCtOrigin (DerivOriginDC dc :: DataCon
dc n :: Int
n _)
= SDoc -> Int -> SDoc -> SDoc
hang (SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "the" SDoc -> SDoc -> SDoc
<+> Int -> SDoc
speakNth Int
n
SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "field of" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (DataCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr DataCon
dc))
2 (SDoc -> SDoc
parens (FilePath -> SDoc
text "type" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
ty)))
where
ty :: Type
ty = DataCon -> [Type]
dataConOrigArgTys DataCon
dc [Type] -> Int -> Type
forall a. [a] -> Int -> a
!! (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-1)
pprCtOrigin (DerivOriginCoerce meth :: TyVar
meth ty1 :: Type
ty1 ty2 :: Type
ty2 _)
= SDoc -> Int -> SDoc -> SDoc
hang (SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "the coercion of the method" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (TyVar -> SDoc
forall a. Outputable a => a -> SDoc
ppr TyVar
meth))
2 ([SDoc] -> SDoc
sep [ FilePath -> SDoc
text "from type" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
ty1)
, Int -> SDoc -> SDoc
nest 2 (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ FilePath -> SDoc
text "to type" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
ty2) ])
pprCtOrigin (DoPatOrigin pat :: LPat GhcRn
pat)
= SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "a do statement"
SDoc -> SDoc -> SDoc
$$
FilePath -> SDoc
text "with the failable pattern" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (LPat GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat GhcRn
pat)
pprCtOrigin (MCompPatOrigin pat :: LPat GhcRn
pat)
= SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
hsep [ FilePath -> SDoc
text "the failable pattern"
, SDoc -> SDoc
quotes (LPat GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat GhcRn
pat)
, FilePath -> SDoc
text "in a statement in a monad comprehension" ]
pprCtOrigin (FailablePattern pat :: LPat GhcTc
pat)
= SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "the failable pattern" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (LPat GhcTc -> SDoc
forall a. Outputable a => a -> SDoc
ppr LPat GhcTc
pat)
SDoc -> SDoc -> SDoc
$$
FilePath -> SDoc
text "(this will become an error in a future GHC release)"
pprCtOrigin (Shouldn'tHappenOrigin note :: FilePath
note)
= (DynFlags -> SDoc) -> SDoc
sdocWithDynFlags ((DynFlags -> SDoc) -> SDoc) -> (DynFlags -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \dflags :: DynFlags
dflags ->
if Extension -> DynFlags -> Bool
xopt Extension
LangExt.ImpredicativeTypes DynFlags
dflags
then FilePath -> SDoc
text "a situation created by impredicative types"
else
[SDoc] -> SDoc
vcat [ FilePath -> SDoc
text "<< This should not appear in error messages. If you see this"
, FilePath -> SDoc
text "in an error message, please report a bug mentioning" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (FilePath -> SDoc
text FilePath
note) SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "at"
, FilePath -> SDoc
text "https://ghc.haskell.org/trac/ghc/wiki/ReportABug >>" ]
pprCtOrigin (ProvCtxtOrigin PSB{ psb_id :: forall idL idR. PatSynBind idL idR -> Located (IdP idL)
psb_id = (L _ name :: IdP GhcRn
name) })
= SDoc -> Int -> SDoc -> SDoc
hang (SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> FilePath -> SDoc
text "the \"provided\" constraints claimed by")
2 (FilePath -> SDoc
text "the signature of" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
IdP GhcRn
name))
pprCtOrigin (InstProvidedOrigin mod :: Module
mod cls_inst :: ClsInst
cls_inst)
= [SDoc] -> SDoc
vcat [ FilePath -> SDoc
text "arising when attempting to show that"
, ClsInst -> SDoc
forall a. Outputable a => a -> SDoc
ppr ClsInst
cls_inst
, FilePath -> SDoc
text "is provided by" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (Module -> SDoc
forall a. Outputable a => a -> SDoc
ppr Module
mod)]
pprCtOrigin simple_origin :: CtOrigin
simple_origin
= SDoc
ctoHerald SDoc -> SDoc -> SDoc
<+> CtOrigin -> SDoc
pprCtO CtOrigin
simple_origin
pprCtO :: CtOrigin -> SDoc
pprCtO :: CtOrigin -> SDoc
pprCtO (OccurrenceOf name :: Name
name) = [SDoc] -> SDoc
hsep [FilePath -> SDoc
text "a use of", SDoc -> SDoc
quotes (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
name)]
pprCtO (OccurrenceOfRecSel name :: RdrName
name) = [SDoc] -> SDoc
hsep [FilePath -> SDoc
text "a use of", SDoc -> SDoc
quotes (RdrName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RdrName
name)]
pprCtO AppOrigin = FilePath -> SDoc
text "an application"
pprCtO (IPOccOrigin name :: HsIPName
name) = [SDoc] -> SDoc
hsep [FilePath -> SDoc
text "a use of implicit parameter", SDoc -> SDoc
quotes (HsIPName -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsIPName
name)]
pprCtO (OverLabelOrigin l :: RuleName
l) = [SDoc] -> SDoc
hsep [FilePath -> SDoc
text "the overloaded label"
,SDoc -> SDoc
quotes (Char -> SDoc
char '#' SDoc -> SDoc -> SDoc
<> RuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr RuleName
l)]
pprCtO RecordUpdOrigin = FilePath -> SDoc
text "a record update"
pprCtO ExprSigOrigin = FilePath -> SDoc
text "an expression type signature"
pprCtO PatSigOrigin = FilePath -> SDoc
text "a pattern type signature"
pprCtO PatOrigin = FilePath -> SDoc
text "a pattern"
pprCtO ViewPatOrigin = FilePath -> SDoc
text "a view pattern"
pprCtO IfOrigin = FilePath -> SDoc
text "an if expression"
pprCtO (LiteralOrigin lit :: HsOverLit GhcRn
lit) = [SDoc] -> SDoc
hsep [FilePath -> SDoc
text "the literal", SDoc -> SDoc
quotes (HsOverLit GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr HsOverLit GhcRn
lit)]
pprCtO (ArithSeqOrigin seq :: ArithSeqInfo GhcRn
seq) = [SDoc] -> SDoc
hsep [FilePath -> SDoc
text "the arithmetic sequence", SDoc -> SDoc
quotes (ArithSeqInfo GhcRn -> SDoc
forall a. Outputable a => a -> SDoc
ppr ArithSeqInfo GhcRn
seq)]
pprCtO SectionOrigin = FilePath -> SDoc
text "an operator section"
pprCtO AssocFamPatOrigin = FilePath -> SDoc
text "the LHS of a famly instance"
pprCtO TupleOrigin = FilePath -> SDoc
text "a tuple"
pprCtO NegateOrigin = FilePath -> SDoc
text "a use of syntactic negation"
pprCtO (ScOrigin n :: IntWithInf
n) = FilePath -> SDoc
text "the superclasses of an instance declaration"
SDoc -> SDoc -> SDoc
<> SDoc -> SDoc
whenPprDebug (SDoc -> SDoc
parens (IntWithInf -> SDoc
forall a. Outputable a => a -> SDoc
ppr IntWithInf
n))
pprCtO DerivClauseOrigin = FilePath -> SDoc
text "the 'deriving' clause of a data type declaration"
pprCtO StandAloneDerivOrigin = FilePath -> SDoc
text "a 'deriving' declaration"
pprCtO DefaultOrigin = FilePath -> SDoc
text "a 'default' declaration"
pprCtO DoOrigin = FilePath -> SDoc
text "a do statement"
pprCtO MCompOrigin = FilePath -> SDoc
text "a statement in a monad comprehension"
pprCtO ProcOrigin = FilePath -> SDoc
text "a proc expression"
pprCtO (TypeEqOrigin t1 :: Type
t1 t2 :: Type
t2 _ _)= FilePath -> SDoc
text "a type equality" SDoc -> SDoc -> SDoc
<+> [SDoc] -> SDoc
sep [Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
t1, Char -> SDoc
char '~', Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr Type
t2]
pprCtO AnnOrigin = FilePath -> SDoc
text "an annotation"
pprCtO HoleOrigin = FilePath -> SDoc
text "a use of" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (FilePath -> SDoc
text "_")
pprCtO ListOrigin = FilePath -> SDoc
text "an overloaded list"
pprCtO StaticOrigin = FilePath -> SDoc
text "a static form"
pprCtO _ = FilePath -> SDoc
forall a. FilePath -> a
panic "pprCtOrigin"
type TcPluginSolver = [Ct]
-> [Ct]
-> [Ct]
-> TcPluginM TcPluginResult
newtype TcPluginM a = TcPluginM (EvBindsVar -> TcM a)
instance Functor TcPluginM where
fmap :: (a -> b) -> TcPluginM a -> TcPluginM b
fmap = (a -> b) -> TcPluginM a -> TcPluginM b
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM
instance Applicative TcPluginM where
pure :: a -> TcPluginM a
pure x :: a
x = (EvBindsVar -> TcM a) -> TcPluginM a
forall a. (EvBindsVar -> TcM a) -> TcPluginM a
TcPluginM (TcM a -> EvBindsVar -> TcM a
forall a b. a -> b -> a
const (TcM a -> EvBindsVar -> TcM a) -> TcM a -> EvBindsVar -> TcM a
forall a b. (a -> b) -> a -> b
$ a -> TcM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x)
<*> :: TcPluginM (a -> b) -> TcPluginM a -> TcPluginM b
(<*>) = TcPluginM (a -> b) -> TcPluginM a -> TcPluginM b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
instance Monad TcPluginM where
#if !MIN_VERSION_base(4,13,0)
fail = MonadFail.fail
#endif
TcPluginM m :: EvBindsVar -> TcM a
m >>= :: TcPluginM a -> (a -> TcPluginM b) -> TcPluginM b
>>= k :: a -> TcPluginM b
k =
(EvBindsVar -> TcM b) -> TcPluginM b
forall a. (EvBindsVar -> TcM a) -> TcPluginM a
TcPluginM (\ ev :: EvBindsVar
ev -> do a
a <- EvBindsVar -> TcM a
m EvBindsVar
ev
TcPluginM b -> EvBindsVar -> TcM b
forall a. TcPluginM a -> EvBindsVar -> TcM a
runTcPluginM (a -> TcPluginM b
k a
a) EvBindsVar
ev)
instance MonadFail.MonadFail TcPluginM where
fail :: FilePath -> TcPluginM a
fail x :: FilePath
x = (EvBindsVar -> TcM a) -> TcPluginM a
forall a. (EvBindsVar -> TcM a) -> TcPluginM a
TcPluginM (TcM a -> EvBindsVar -> TcM a
forall a b. a -> b -> a
const (TcM a -> EvBindsVar -> TcM a) -> TcM a -> EvBindsVar -> TcM a
forall a b. (a -> b) -> a -> b
$ FilePath -> TcM a
forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail FilePath
x)
runTcPluginM :: TcPluginM a -> EvBindsVar -> TcM a
runTcPluginM :: TcPluginM a -> EvBindsVar -> TcM a
runTcPluginM (TcPluginM m :: EvBindsVar -> TcM a
m) = EvBindsVar -> TcM a
m
unsafeTcPluginTcM :: TcM a -> TcPluginM a
unsafeTcPluginTcM :: TcM a -> TcPluginM a
unsafeTcPluginTcM = (EvBindsVar -> TcM a) -> TcPluginM a
forall a. (EvBindsVar -> TcM a) -> TcPluginM a
TcPluginM ((EvBindsVar -> TcM a) -> TcPluginM a)
-> (TcM a -> EvBindsVar -> TcM a) -> TcM a -> TcPluginM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TcM a -> EvBindsVar -> TcM a
forall a b. a -> b -> a
const
getEvBindsTcPluginM :: TcPluginM EvBindsVar
getEvBindsTcPluginM :: TcPluginM EvBindsVar
getEvBindsTcPluginM = (EvBindsVar -> TcM EvBindsVar) -> TcPluginM EvBindsVar
forall a. (EvBindsVar -> TcM a) -> TcPluginM a
TcPluginM EvBindsVar -> TcM EvBindsVar
forall (m :: * -> *) a. Monad m => a -> m a
return
data TcPlugin = forall s. TcPlugin
{ ()
tcPluginInit :: TcPluginM s
, ()
tcPluginSolve :: s -> TcPluginSolver
, ()
tcPluginStop :: s -> TcPluginM ()
}
data TcPluginResult
= TcPluginContradiction [Ct]
| TcPluginOk [(EvTerm,Ct)] [Ct]
type RoleAnnotEnv = NameEnv (LRoleAnnotDecl GhcRn)
mkRoleAnnotEnv :: [LRoleAnnotDecl GhcRn] -> RoleAnnotEnv
mkRoleAnnotEnv :: [LRoleAnnotDecl GhcRn] -> RoleAnnotEnv
mkRoleAnnotEnv role_annot_decls :: [LRoleAnnotDecl GhcRn]
role_annot_decls
= [(Name, LRoleAnnotDecl GhcRn)] -> RoleAnnotEnv
forall a. [(Name, a)] -> NameEnv a
mkNameEnv [ (Name
name, LRoleAnnotDecl GhcRn
ra_decl)
| LRoleAnnotDecl GhcRn
ra_decl <- [LRoleAnnotDecl GhcRn]
role_annot_decls
, let name :: IdP GhcRn
name = RoleAnnotDecl GhcRn -> IdP GhcRn
forall pass. RoleAnnotDecl pass -> IdP pass
roleAnnotDeclName (LRoleAnnotDecl GhcRn -> SrcSpanLess (LRoleAnnotDecl GhcRn)
forall a. HasSrcSpan a => a -> SrcSpanLess a
unLoc LRoleAnnotDecl GhcRn
ra_decl)
, Bool -> Bool
not (Name -> Bool
isUnboundName Name
name) ]
emptyRoleAnnotEnv :: RoleAnnotEnv
emptyRoleAnnotEnv :: RoleAnnotEnv
emptyRoleAnnotEnv = RoleAnnotEnv
forall elt. UniqFM elt
emptyNameEnv
lookupRoleAnnot :: RoleAnnotEnv -> Name -> Maybe (LRoleAnnotDecl GhcRn)
lookupRoleAnnot :: RoleAnnotEnv -> Name -> Maybe (LRoleAnnotDecl GhcRn)
lookupRoleAnnot = RoleAnnotEnv -> Name -> Maybe (LRoleAnnotDecl GhcRn)
forall a. NameEnv a -> Name -> Maybe a
lookupNameEnv
getRoleAnnots :: [Name] -> RoleAnnotEnv
-> ([LRoleAnnotDecl GhcRn], RoleAnnotEnv)
getRoleAnnots :: [Name] -> RoleAnnotEnv -> ([LRoleAnnotDecl GhcRn], RoleAnnotEnv)
getRoleAnnots bndrs :: [Name]
bndrs role_env :: RoleAnnotEnv
role_env
= ( (Name -> Maybe (LRoleAnnotDecl GhcRn))
-> [Name] -> [LRoleAnnotDecl GhcRn]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (RoleAnnotEnv -> Name -> Maybe (LRoleAnnotDecl GhcRn)
lookupRoleAnnot RoleAnnotEnv
role_env) [Name]
bndrs
, RoleAnnotEnv -> [Name] -> RoleAnnotEnv
forall a. NameEnv a -> [Name] -> NameEnv a
delListFromNameEnv RoleAnnotEnv
role_env [Name]
bndrs )