ghc-9.10.3: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Tc.Solver.InertSet

Contents

- The work list
- The inert set
- Inert equalities
- Inert Dicts
- Inert Irreds
- Kick-out
- Cycle breaker vars
- Solving one from another

Synopsis

- data WorkList = WL {
  - wl_eqs :: [Ct]
  - wl_rw_eqs :: [Ct]
  - wl_rest :: [Ct]
  - wl_implics :: Bag Implication
  }
- isEmptyWorkList :: WorkList -> Bool
- emptyWorkList :: WorkList
- extendWorkListNonEq :: Ct -> WorkList -> WorkList
- extendWorkListCt :: Ct -> WorkList -> WorkList
- extendWorkListCts :: Cts -> WorkList -> WorkList
- extendWorkListCtList :: [Ct] -> WorkList -> WorkList
- extendWorkListEq :: RewriterSet -> Ct -> WorkList -> WorkList
- extendWorkListEqs :: RewriterSet -> Bag Ct -> WorkList -> WorkList
- appendWorkList :: WorkList -> WorkList -> WorkList
- extendWorkListImplic :: Implication -> WorkList -> WorkList
- workListSize :: WorkList -> Int
- selectWorkItem :: WorkList -> Maybe (Ct, WorkList)
- data InertSet = IS {
  - inert_cans :: InertCans
  - inert_cycle_breakers :: CycleBreakerVarStack
  - inert_famapp_cache :: FunEqMap Reduction
  - inert_solved_dicts :: DictMap DictCt
  }
- data InertCans = IC {
  - inert_eqs :: InertEqs
  - inert_funeqs :: InertFunEqs
  - inert_dicts :: DictMap DictCt
  - inert_insts :: [QCInst]
  - inert_safehask :: DictMap DictCt
  - inert_irreds :: InertIrreds
  - inert_given_eq_lvl :: TcLevel
  - inert_given_eqs :: Bool
  }
- emptyInert :: InertSet
- noMatchableGivenDicts :: InertSet -> CtLoc -> Class -> [TcType] -> Bool
- noGivenNewtypeReprEqs :: TyCon -> InertSet -> Bool
- updGivenEqs :: TcLevel -> Ct -> InertCans -> InertCans
- mightEqualLater :: InertSet -> TcPredType -> CtLoc -> TcPredType -> CtLoc -> Maybe Subst
- prohibitedSuperClassSolve :: CtLoc -> CtLoc -> Bool
- type InertEqs = DTyVarEnv EqualCtList
- foldTyEqs :: (EqCt -> b -> b) -> InertEqs -> b -> b
- delEq :: EqCt -> InertCans -> InertCans
- findEq :: InertCans -> CanEqLHS -> [EqCt]
- partitionInertEqs :: (EqCt -> Bool) -> InertEqs -> ([EqCt], InertEqs)
- partitionFunEqs :: (EqCt -> Bool) -> InertFunEqs -> ([EqCt], InertFunEqs)
- foldFunEqs :: (EqCt -> b -> b) -> FunEqMap EqualCtList -> b -> b
- addEqToCans :: TcLevel -> EqCt -> InertCans -> InertCans
- updDicts :: (DictMap DictCt -> DictMap DictCt) -> InertCans -> InertCans
- delDict :: DictCt -> DictMap a -> DictMap a
- addDict :: DictCt -> DictMap DictCt -> DictMap DictCt
- filterDicts :: (DictCt -> Bool) -> DictMap DictCt -> DictMap DictCt
- partitionDicts :: (DictCt -> Bool) -> DictMap DictCt -> (Bag DictCt, DictMap DictCt)
- addSolvedDict :: DictCt -> DictMap DictCt -> DictMap DictCt
- type InertIrreds = Bag IrredCt
- delIrred :: IrredCt -> InertCans -> InertCans
- addIrreds :: [IrredCt] -> InertIrreds -> InertIrreds
- addIrred :: IrredCt -> InertIrreds -> InertIrreds
- foldIrreds :: (IrredCt -> b -> b) -> InertIrreds -> b -> b
- findMatchingIrreds :: InertIrreds -> CtEvidence -> (Bag (IrredCt, SwapFlag), InertIrreds)
- updIrreds :: (InertIrreds -> InertIrreds) -> InertCans -> InertCans
- addIrredToCans :: TcLevel -> IrredCt -> InertCans -> InertCans
- data KickOutSpec
  - = KOAfterUnify TcTyVarSet
  - | KOAfterAdding CanEqLHS
- kickOutRewritableLHS :: KickOutSpec -> CtFlavourRole -> InertCans -> (Cts, InertCans)
- type CycleBreakerVarStack = NonEmpty (Bag (TcTyVar, TcType))
- pushCycleBreakerVarStack :: CycleBreakerVarStack -> CycleBreakerVarStack
- addCycleBreakerBindings :: Bag (TcTyVar, Type) -> InertSet -> InertSet
- forAllCycleBreakerBindings_ :: Monad m => CycleBreakerVarStack -> (TcTyVar -> TcType -> m ()) -> m ()
- data InteractResult
  - = KeepInert
  - | KeepWork
- solveOneFromTheOther :: Ct -> Ct -> InteractResult

# The work list

data WorkList Source #

Constructors

WL |

Fields

- wl_eqs :: [Ct]
- wl_rw_eqs :: [Ct]
- wl_rest :: [Ct]
- wl_implics :: Bag Implication

#### Instances

Instances details

Outputable WorkList Source # |
Instance details Defined in GHC.Tc.Solver.InertSet Methods ppr :: WorkList -> SDoc Source #

isEmptyWorkList :: WorkList -> Bool Source #

emptyWorkList :: WorkList Source #

extendWorkListNonEq :: Ct -> WorkList -> WorkList Source #

extendWorkListCt :: Ct -> WorkList -> WorkList Source #

extendWorkListCts :: Cts -> WorkList -> WorkList Source #

extendWorkListCtList :: [Ct] -> WorkList -> WorkList Source #

extendWorkListEq :: RewriterSet -> Ct -> WorkList -> WorkList Source #

extendWorkListEqs :: RewriterSet -> Bag Ct -> WorkList -> WorkList Source #

appendWorkList :: WorkList -> WorkList -> WorkList Source #

extendWorkListImplic :: Implication -> WorkList -> WorkList Source #

workListSize :: WorkList -> Int Source #

selectWorkItem :: WorkList -> Maybe (Ct, WorkList) Source #

# The inert set

data InertSet Source #

Constructors

IS |

Fields

- inert_cans :: InertCans
- inert_cycle_breakers :: CycleBreakerVarStack
- inert_famapp_cache :: FunEqMap Reduction
- inert_solved_dicts :: DictMap DictCt

#### Instances

Instances details

Outputable InertSet Source # |
Instance details Defined in GHC.Tc.Solver.InertSet Methods ppr :: InertSet -> SDoc Source #

data InertCans Source #

Constructors

IC |

Fields

- inert_eqs :: InertEqs
- inert_funeqs :: InertFunEqs
- inert_dicts :: DictMap DictCt
- inert_insts :: [QCInst]
- inert_safehask :: DictMap DictCt

  See Note [Safe Haskell Overlapping Instances Implementation] in GHC.Tc.Solver

- inert_irreds :: InertIrreds
- inert_given_eq_lvl :: TcLevel
- inert_given_eqs :: Bool

#### Instances

Instances details

Outputable InertCans Source # |
Instance details Defined in GHC.Tc.Solver.InertSet Methods ppr :: InertCans -> SDoc Source #

emptyInert :: InertSet Source #

noMatchableGivenDicts :: InertSet -> CtLoc -> Class -> [TcType] -> Bool Source #

Returns True iff there are no Given constraints that might, potentially, match the given class constraint. This is used when checking to see if a Given might overlap with an instance. See Note [Instance and Given overlap] in GHC.Tc.Solver.Dict

noGivenNewtypeReprEqs :: TyCon -> InertSet -> Bool Source #

updGivenEqs :: TcLevel -> Ct -> InertCans -> InertCans Source #

mightEqualLater :: InertSet -> TcPredType -> CtLoc -> TcPredType -> CtLoc -> Maybe Subst Source #

prohibitedSuperClassSolve Source #

Arguments

:: CtLoc | is it loopy to use this one ...
-> CtLoc | ... to solve this one?
-> Bool | True ==> don't solve it

Is it (potentially) loopy to use the first `ct1` to solve `ct2`?

Necessary (but not sufficient) conditions for this function to return `True`:

- `ct1` and `ct2` both arise from superclass expansion,
- `ct1` is a Given and `ct2` is a Wanted.

See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance, (sc2).

# Inert equalities

type InertEqs = DTyVarEnv EqualCtList Source #

foldTyEqs :: (EqCt -> b -> b) -> InertEqs -> b -> b Source #

delEq :: EqCt -> InertCans -> InertCans Source #

findEq :: InertCans -> CanEqLHS -> [EqCt] Source #

partitionInertEqs :: (EqCt -> Bool) -> InertEqs -> ([EqCt], InertEqs) Source #

partitionFunEqs :: (EqCt -> Bool) -> InertFunEqs -> ([EqCt], InertFunEqs) Source #

foldFunEqs :: (EqCt -> b -> b) -> FunEqMap EqualCtList -> b -> b Source #

addEqToCans :: TcLevel -> EqCt -> InertCans -> InertCans Source #

# Inert Dicts

updDicts :: (DictMap DictCt -> DictMap DictCt) -> InertCans -> InertCans Source #

delDict :: DictCt -> DictMap a -> DictMap a Source #

addDict :: DictCt -> DictMap DictCt -> DictMap DictCt Source #

filterDicts :: (DictCt -> Bool) -> DictMap DictCt -> DictMap DictCt Source #

partitionDicts :: (DictCt -> Bool) -> DictMap DictCt -> (Bag DictCt, DictMap DictCt) Source #

addSolvedDict :: DictCt -> DictMap DictCt -> DictMap DictCt Source #

# Inert Irreds

type InertIrreds = Bag IrredCt Source #

delIrred :: IrredCt -> InertCans -> InertCans Source #

addIrreds :: [IrredCt] -> InertIrreds -> InertIrreds Source #

addIrred :: IrredCt -> InertIrreds -> InertIrreds Source #

foldIrreds :: (IrredCt -> b -> b) -> InertIrreds -> b -> b Source #

findMatchingIrreds :: InertIrreds -> CtEvidence -> (Bag (IrredCt, SwapFlag), InertIrreds) Source #

updIrreds :: (InertIrreds -> InertIrreds) -> InertCans -> InertCans Source #

addIrredToCans :: TcLevel -> IrredCt -> InertCans -> InertCans Source #

# Kick-out

data KickOutSpec Source #

Constructors

KOAfterUnify TcTyVarSet |
KOAfterAdding CanEqLHS |

kickOutRewritableLHS :: KickOutSpec -> CtFlavourRole -> InertCans -> (Cts, InertCans) Source #

# Cycle breaker vars

type CycleBreakerVarStack Source #

Arguments

= NonEmpty (Bag (TcTyVar, TcType))

a stack of (CycleBreakerTv, original family applications) lists first element in the stack corresponds to current implication; later elements correspond to outer implications used to undo the cycle-breaking needed to handle Note [Type equality cycles] in GHC.Tc.Solver.Equality Why store the outer implications? For the use in mightEqualLater (only)

Why NonEmpty? So there is always a top element to add to

pushCycleBreakerVarStack :: CycleBreakerVarStack -> CycleBreakerVarStack Source #

Push a fresh environment onto the cycle-breaker var stack. Useful when entering a nested implication.

addCycleBreakerBindings Source #

Arguments

:: Bag (TcTyVar, Type) | (cbv,expansion) pairs
-> InertSet |
-> InertSet |

Add a new cycle-breaker binding to the top environment on the stack.

forAllCycleBreakerBindings_ :: Monad m => CycleBreakerVarStack -> (TcTyVar -> TcType -> m ()) -> m () Source #

Perform a monadic operation on all pairs in the top environment in the stack.

# Solving one from another

data InteractResult Source #

Constructors

KeepInert |
KeepWork |

#### Instances

Instances details

Outputable InteractResult Source # |
Instance details Defined in GHC.Tc.Solver.InertSet Methods ppr :: InteractResult -> SDoc Source #

solveOneFromTheOther :: Ct -> Ct -> InteractResult Source #