ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Tc.Solver.InertSet

Contents

- The work list
- The inert set
- Inert equalities
- Kick-out
- Cycle breaker vars

Synopsis

- data WorkList = WL {
  - wl_eqs :: [Ct]
  - wl_rest :: [Ct]
  - wl_implics :: Bag Implication
  }
- isEmptyWorkList :: WorkList -> Bool
- emptyWorkList :: WorkList
- extendWorkListNonEq :: Ct -> WorkList -> WorkList
- extendWorkListCt :: Ct -> WorkList -> WorkList
- extendWorkListCts :: [Ct] -> WorkList -> WorkList
- extendWorkListEq :: 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 CtEvidence
  }
- data InertCans = IC {
  - inert_eqs :: InertEqs
  - inert_funeqs :: FunEqMap EqualCtList
  - inert_dicts :: DictMap Ct
  - inert_insts :: [QCInst]
  - inert_safehask :: DictMap Ct
  - inert_irreds :: Cts
  - inert_given_eq_lvl :: TcLevel
  - inert_given_eqs :: Bool
  }
- type InertEqs = DTyVarEnv EqualCtList
- emptyInert :: InertSet
- addInertItem :: TcLevel -> InertCans -> Ct -> InertCans
- noMatchableGivenDicts :: InertSet -> CtLoc -> Class -> [TcType] -> Bool
- noGivenNewtypeReprEqs :: TyCon -> InertSet -> Bool
- mightEqualLater :: InertSet -> TcPredType -> CtLoc -> TcPredType -> CtLoc -> Maybe Subst
- prohibitedSuperClassSolve :: CtLoc -> CtLoc -> Bool
- foldTyEqs :: (Ct -> b -> b) -> InertEqs -> b -> b
- delEq :: InertCans -> CanEqLHS -> TcType -> InertCans
- findEq :: InertCans -> CanEqLHS -> [Ct]
- partitionInertEqs :: (Ct -> Bool) -> InertEqs -> ([Ct], InertEqs)
- partitionFunEqs :: (Ct -> Bool) -> FunEqMap EqualCtList -> ([Ct], FunEqMap EqualCtList)
- kickOutRewritableLHS :: CtFlavourRole -> CanEqLHS -> InertCans -> (WorkList, InertCans)
- type CycleBreakerVarStack = NonEmpty [(TcTyVar, TcType)]
- pushCycleBreakerVarStack :: CycleBreakerVarStack -> CycleBreakerVarStack
- insertCycleBreakerBinding :: TcTyVar -> TcType -> CycleBreakerVarStack -> CycleBreakerVarStack
- forAllCycleBreakerBindings_ :: Monad m => CycleBreakerVarStack -> (TcTyVar -> TcType -> m ()) -> m ()

# The work list

data WorkList Source #

Constructors

WL |

Fields

- wl_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 :: [Ct] -> WorkList -> WorkList Source #

extendWorkListEq :: 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 CtEvidence

#### 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 :: FunEqMap EqualCtList
- inert_dicts :: DictMap Ct
- inert_insts :: [QCInst]
- inert_safehask :: DictMap Ct

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

- inert_irreds :: Cts
- 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 #

type InertEqs = DTyVarEnv EqualCtList Source #

emptyInert :: InertSet Source #

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

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

Returns True iff there are no Given constraints that might, potentially, match the given class consraint. 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.Interact

noGivenNewtypeReprEqs :: TyCon -> InertSet -> Bool 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

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

delEq :: InertCans -> CanEqLHS -> TcType -> InertCans Source #

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

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

partitionFunEqs :: (Ct -> Bool) -> FunEqMap EqualCtList -> ([Ct], FunEqMap EqualCtList) Source #

# Kick-out

kickOutRewritableLHS :: CtFlavourRole -> CanEqLHS -> InertCans -> (WorkList, InertCans) Source #

# Cycle breaker vars

type CycleBreakerVarStack Source #

Arguments

= NonEmpty [(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.Canonical Why store the outer implications? For the use in mightEqualLater (only)

pushCycleBreakerVarStack :: CycleBreakerVarStack -> CycleBreakerVarStack Source #

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

insertCycleBreakerBinding Source #

Arguments

:: TcTyVar | cbv, must be a CycleBreakerTv
-> TcType | cbv's expansion
-> CycleBreakerVarStack |
-> CycleBreakerVarStack |

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.