ghc-lib-9.6.3.20231121: The GHC API, decoupled from GHC versions
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Tc.Solver.Monad

Description

Monadic definitions for the constraint solver

Synopsis

Documentation

data TcS a Source #

Instances

Instances details
MonadFail TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

Methods

fail :: String -> TcS a #

MonadFix TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

Methods

mfix :: (a -> TcS a) -> TcS a #

MonadIO TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

Methods

liftIO :: IO a -> TcS a #

Applicative TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

Methods

pure :: a -> TcS a #

(<*>) :: TcS (a -> b) -> TcS a -> TcS b #

liftA2 :: (a -> b -> c) -> TcS a -> TcS b -> TcS c #

(*>) :: TcS a -> TcS b -> TcS b #

(<*) :: TcS a -> TcS b -> TcS a #

Functor TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

Methods

fmap :: (a -> b) -> TcS a -> TcS b #

(<$) :: a -> TcS b -> TcS a #

Monad TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

Methods

(>>=) :: TcS a -> (a -> TcS b) -> TcS b #

(>>) :: TcS a -> TcS b -> TcS b #

return :: a -> TcS a #

HasDynFlags TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

MonadThings TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

MonadUnique TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

HasModule TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

Methods

getModule :: TcS Module #

runTcSEarlyAbort :: TcS a -> TcM a Source #

This variant of runTcS will immediately fail upon encountering an insoluble ct. See Note [Speeding up valid hole-fits]. Its one usage site does not need the ev_binds, so we do not return them.

runTcSInerts :: InertSet -> TcS a -> TcM (a, InertSet) Source #

A variant of runTcS that takes and returns an InertSet for later resumption of the TcS session.

wrapTcS :: TcM a -> TcS a Source #

ctLocWarnTcS :: CtLoc -> TcRnMessage -> TcS () Source #

Emit a warning within the TcS monad at the location given by the CtLoc.

runTcSEqualities :: TcS a -> TcM a Source #

This can deal only with equality constraints.

nestTcS :: TcS a -> TcS a Source #

data ClsInstResult Source #

Instances

Instances details
Outputable ClsInstResult Source # 
Instance details

Defined in GHC.Tc.Instance.Class

Methods

ppr :: ClsInstResult -> SDoc #

data QCInst #

Constructors

QCI 

Instances

Instances details
Outputable QCInst 
Instance details

Defined in GHC.Tc.Types.Constraint

Methods

ppr :: QCInst -> SDoc #

newWantedEq :: CtLoc -> RewriterSet -> Role -> TcType -> TcType -> TcS (CtEvidence, Coercion) Source #

Create a new Wanted constraint holding a coercion hole for an equality between the two types at the given Role.

emitNewWantedEq :: CtLoc -> RewriterSet -> Role -> TcType -> TcType -> TcS Coercion Source #

Emit a new Wanted equality into the work-list

newWanted :: CtLoc -> RewriterSet -> PredType -> TcS MaybeNew Source #

Create a new Wanted constraint, potentially looking up non-equality constraints in the cache instead of creating a new one from scratch.

Deals with both equality and non-equality constraints.

newWantedNC :: CtLoc -> RewriterSet -> PredType -> TcS CtEvidence Source #

Create a new Wanted constraint.

Deals with both equality and non-equality constraints.

Does not attempt to re-use non-equality constraints that already exist in the inert set.

newWantedEvVarNC :: CtLoc -> RewriterSet -> TcPredType -> TcS CtEvidence Source #

Create a new Wanted constraint holding an evidence variable.

Don't use this for equality constraints: use newWantedEq instead.

newBoundEvVarId :: TcPredType -> EvTerm -> TcS EvVar Source #

Make a new Id of the given type, bound (in the monad's EvBinds) to the given term

touchabilityTest :: CtFlavour -> TcTyVar -> TcType -> TcS (TouchabilityTestResult, TcType) Source #

This is the key test for untouchability: See Note [Unification preconditions] in GHC.Tc.Utils.Unify and Note [Solve by unification] in GHC.Tc.Solver.Interact

Returns a new rhs type, as this function can turn make some metavariables concrete.

setWantedEq :: HasDebugCallStack => TcEvDest -> Coercion -> TcS () Source #

Equalities only

setWantedEvTerm :: TcEvDest -> EvTerm -> TcS () Source #

Good for both equalities and non-equalities

checkReductionDepth Source #

Arguments

:: CtLoc 
-> TcType

type being reduced

-> TcS () 

Checks if the depth of the given location is too much. Fails if it's too big, with an appropriate error message.

removeInertCts :: [Ct] -> InertCans -> InertCans Source #

Remove inert constraints from the InertCans, for use when a typechecker plugin wishes to discard a given.

insertFunEq :: FunEqMap a -> TyCon -> [Type] -> a -> FunEqMap a #

emitWork :: [Ct] -> TcS () Source #

lookupInertDict :: InertCans -> CtLoc -> Class -> [Type] -> Maybe Ct Source #

Look up a dictionary inert.

lookupSolvedDict :: InertSet -> CtLoc -> Class -> [Type] -> Maybe CtEvidence Source #

Look up a solved inert.

foldIrreds :: (Ct -> b -> b) -> Cts -> b -> b Source #

lookupFamAppInert :: (CtFlavourRole -> Bool) -> TyCon -> [Type] -> TcS (Maybe (Reduction, CtFlavourRole)) Source #

Looks up a family application in the inerts.

data TcLevel #

Instances

Instances details
Outputable TcLevel 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

ppr :: TcLevel -> SDoc #

Eq TcLevel 
Instance details

Defined in GHC.Tc.Utils.TcType

Methods

(==) :: TcLevel -> TcLevel -> Bool #

(/=) :: TcLevel -> TcLevel -> Bool #

Ord TcLevel 
Instance details

Defined in GHC.Tc.Utils.TcType

newTcRef :: a -> TcS (TcRef a) Source #

writeTcRef :: TcRef a -> a -> TcS () Source #

updTcRef :: TcRef a -> (a -> a) -> TcS () Source #

breakTyEqCycle_maybe :: CtEvidence -> CheckTyEqResult -> CanEqLHS -> TcType -> TcS (Maybe ReductionN) Source #

Conditionally replace all type family applications in the RHS with fresh variables, emitting givens that relate the type family application to the variable. See Note [Type equality cycles] in GHC.Tc.Solver.Canonical. This only works under conditions as described in the Note; otherwise, returns Nothing.