Commit 5770029a authored by Simon Peyton Jones's avatar Simon Peyton Jones

Simon's major commit to re-engineer the constraint solver

The driving change is this:

* The canonical CFunEqCan constraints now have the form
       [G] F xis ~ fsk
       [W] F xis ~ fmv
  where fsk is a flatten-skolem, and fmv is a flatten-meta-variable
  Think of them as the name of the type-function application

See Note [The flattening story] in TcFlatten.  A flatten-meta-variable
is distinguishable by its MetaInfo of FlatMetaTv

This in turn led to an enormous cascade of other changes, which simplify
and modularise the constraint solver.  In particular:

* Basic data types
    * I got rid of inert_solved_funeqs altogether. It serves no useful
      role that inert_flat_cache does not solve.

    * I added wl_implics to the WorkList, as a convenient place to
      accumulate newly-emitted implications; see Note [Residual
      implications] in TcSMonad.

    * I eliminated tcs_ty_binds altogether. These were the bindings
      for unification variables that we have now solved by
      unification.  We kept them in a finite map and did the
      side-effecting unification later.  But in cannonicalisation we
      had to look up in the side-effected mutable tyvars anyway, so
      nothing was being gained.

      Our original idea was that the solver would be pure, and would
      be a no-op if you discarded its results, but this was already
      not-true for implications since we update their evidence
      bindings in an imperative way.  So rather than the uneasy
      compromise, it's now clearly imperative!

* I split out the flatten/unflatten code into a new module, TcFlatten

* I simplified and articulated explicitly the (rather hazy) invariants
  for the inert substitution inert_eqs.  See Note [eqCanRewrite] and
  See Note [Applying the inert substitution] in TcFlatten

* Unflattening is now done (by TcFlatten.unflatten) after solveFlats,
  before solving nested implications.  This turned out to simplify a
  lot of code. Previously, unflattening was done as part of zonking, at
  the very very end.

    * Eager unflattening allowed me to remove the unpleasant ic_fsks
      field of an Implication (hurrah)

    * Eager unflattening made the TcSimplify.floatEqualities function
      much simpler (just float equalities looking like a ~ ty, where a
      is an untouchable meta-tyvar).

    * Likewise the idea of "pushing wanteds in as givens" could be
      completely eliminated.

* I radically simplified the code that determines when there are
  'given' equalities, and hence whether we can float 'wanted' equalies
  out.  See TcSMonad.getNoGivenEqs, and Note [When does an implication
  have given equalities?].

  This allowed me to get rid of the unpleasant inert_no_eqs flag in InertCans.

* As part of this given-equality stuff, I fixed Trac #9211. See Note
  [Let-bound skolems] in TcSMonad

* Orientation of tyvar/tyvar equalities (a ~ b) was partly done during
  canonicalisation, but then repeated in the spontaneous-solve stage
  (trySpontaneousSolveTwoWay). Now it is done exclusively during
  canonicalisation, which keeps all the code in one place.  See
  Note [Canonical orientation for tyvar/tyvar equality constraints]
  in TcCanonical
parent ce9d6f25
......@@ -406,6 +406,7 @@ Library
TcUnify
TcInteract
TcCanonical
TcFlatten
TcSMonad
TcTypeNats
TcSplice
......
......@@ -2,22 +2,13 @@ ToDo:
* get rid of getEvTerm?
* Float only CTyEqCans. kind-incompatible things should be CNonCanonical,
so they won't float and generate a duplicate kind-unify message
Then we can stop disabling floating when there are insolubles,
and that will improve mc21 etc
* Note [Do not add duplicate derived isols]
This mostly doesn't apply now, except for the fundeps
* inert_funeqs, inert_eqs: keep only the CtEvidence.
They are all CFunEqCans, CTyEqCans
* remove/rewrite TcMType Note [Unflattening while zonking]
* Consider individual data tpyes for CFunEqCan etc
* Collapes CNonCanonical and CIrredCan
Remaining errors
============================
Unexpected failures:
......
......@@ -590,13 +590,12 @@ addClsInstsErr herald ispecs
\begin{code}
---------------- Getting free tyvars -------------------------
tyVarsOfCt :: Ct -> TcTyVarSet
-- NB: the
tyVarsOfCt (CTyEqCan { cc_tyvar = tv, cc_rhs = xi }) = extendVarSet (tyVarsOfType xi) tv
tyVarsOfCt (CFunEqCan { cc_tyargs = tys, cc_rhs = xi }) = tyVarsOfTypes (xi:tys)
tyVarsOfCt (CDictCan { cc_tyargs = tys }) = tyVarsOfTypes tys
tyVarsOfCt (CIrredEvCan { cc_ev = ev }) = tyVarsOfType (ctEvPred ev)
tyVarsOfCt (CHoleCan { cc_ev = ev }) = tyVarsOfType (ctEvPred ev)
tyVarsOfCt (CNonCanonical { cc_ev = ev }) = tyVarsOfType (ctEvPred ev)
tyVarsOfCt (CTyEqCan { cc_tyvar = tv, cc_rhs = xi }) = extendVarSet (tyVarsOfType xi) tv
tyVarsOfCt (CFunEqCan { cc_tyargs = tys, cc_fsk = fsk }) = extendVarSet (tyVarsOfTypes tys) fsk
tyVarsOfCt (CDictCan { cc_tyargs = tys }) = tyVarsOfTypes tys
tyVarsOfCt (CIrredEvCan { cc_ev = ev }) = tyVarsOfType (ctEvPred ev)
tyVarsOfCt (CHoleCan { cc_ev = ev }) = tyVarsOfType (ctEvPred ev)
tyVarsOfCt (CNonCanonical { cc_ev = ev }) = tyVarsOfType (ctEvPred ev)
tyVarsOfCts :: Cts -> TcTyVarSet
tyVarsOfCts = foldrBag (unionVarSet . tyVarsOfCt) emptyVarSet
......@@ -610,10 +609,10 @@ tyVarsOfWC (WC { wc_flat = flat, wc_impl = implic, wc_insol = insol })
tyVarsOfImplic :: Implication -> TyVarSet
-- Only called on *zonked* things, hence no need to worry about flatten-skolems
tyVarsOfImplic (Implic { ic_skols = skols, ic_fsks = fsks
, ic_given = givens, ic_wanted = wanted })
tyVarsOfImplic (Implic { ic_skols = skols
, ic_given = givens, ic_wanted = wanted })
= (tyVarsOfWC wanted `unionVarSet` tyVarsOfTypes (map evVarPred givens))
`delVarSetList` skols `delVarSetList` fsks
`delVarSetList` skols
tyVarsOfBag :: (a -> TyVarSet) -> Bag a -> TyVarSet
tyVarsOfBag tvs_of = foldrBag (unionVarSet . tvs_of) emptyVarSet
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
o%
%
% (c) The University of Glasgow 2006
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
......@@ -53,7 +53,7 @@ module TcMType (
zonkTcTyVarBndr, zonkTcType, zonkTcTypes, zonkTcThetaType,
zonkTcKind, defaultKindVarToStar,
zonkEvVar, zonkWC, zonkFlats, zonkId, zonkCt, zonkCts, zonkSkolemInfo,
zonkEvVar, zonkWC, zonkFlats, zonkId, zonkCt, zonkSkolemInfo,
tcGetGlobalTyVars,
) where
......@@ -63,10 +63,8 @@ module TcMType (
-- friends:
import TypeRep
import TcType
import TcEvidence
import Type
import Class
import TyCon
import Var
-- others:
......@@ -313,9 +311,10 @@ newMetaTyVar meta_info kind
= do { uniq <- newUnique
; let name = mkTcTyVarName uniq s
s = case meta_info of
PolyTv -> fsLit "s"
TauTv -> fsLit "t"
SigTv -> fsLit "a"
PolyTv -> fsLit "s"
TauTv -> fsLit "t"
FlatMetaTv -> fsLit "fmv"
SigTv -> fsLit "a"
; details <- newMetaDetails meta_info
; return (mkTcTyVar name kind details) }
......@@ -595,6 +594,7 @@ skolemiseUnboundMetaTyVar tv details
final_name = mkInternalName uniq (getOccName tv) span
final_tv = mkTcTyVar final_name final_kind details
; traceTc "Skolemising" (ppr tv <+> ptext (sLit ":=") <+> ppr final_tv)
; writeMetaTyVar tv (mkTyVarTy final_tv)
; return final_tv }
\end{code}
......@@ -667,7 +667,7 @@ a \/\a in the final result but all the occurrences of a will be zonked to ()
%************************************************************************
%* *
Zonking
Zonking types
%* *
%************************************************************************
......@@ -686,8 +686,6 @@ tcGetGlobalTyVars
where
\end{code}
----------------- Type variables
\begin{code}
zonkTcTypeAndFV :: TcType -> TcM TyVarSet
-- Zonk a type and take its free variables
......@@ -728,13 +726,15 @@ zonkTcPredType :: TcPredType -> TcM TcPredType
zonkTcPredType = zonkTcType
\end{code}
--------------- Constraints
%************************************************************************
%* *
Zonking constraints
%* *
%************************************************************************
\begin{code}
zonkImplication :: Implication -> TcM (Bag Implication)
zonkImplication implic@(Implic { ic_untch = untch
, ic_binds = binds_var
, ic_skols = skols
zonkImplication implic@(Implic { ic_skols = skols
, ic_given = given
, ic_wanted = wanted
, ic_info = info })
......@@ -742,12 +742,11 @@ zonkImplication implic@(Implic { ic_untch = untch
-- as Trac #7230 showed
; given' <- mapM zonkEvVar given
; info' <- zonkSkolemInfo info
; wanted' <- zonkWCRec binds_var untch wanted
; wanted' <- zonkWCRec wanted
; if isEmptyWC wanted'
then return emptyBag
else return $ unitBag $
implic { ic_fsks = [] -- Zonking removes all FlatSkol tyvars
, ic_skols = skols'
implic { ic_skols = skols'
, ic_given = given'
, ic_wanted = wanted'
, ic_info = info' } }
......@@ -757,105 +756,25 @@ zonkEvVar var = do { ty' <- zonkTcType (varType var)
; return (setVarType var ty') }
zonkWC :: EvBindsVar -- May add new bindings for wanted family equalities in here
-> WantedConstraints -> TcM WantedConstraints
zonkWC binds_var wc
= do { untch <- getUntouchables
; zonkWCRec binds_var untch wc }
zonkWC :: WantedConstraints -> TcM WantedConstraints
zonkWC wc = zonkWCRec wc
zonkWCRec :: EvBindsVar
-> Untouchables
-> WantedConstraints -> TcM WantedConstraints
zonkWCRec binds_var untch (WC { wc_flat = flat, wc_impl = implic, wc_insol = insol })
= do { flat' <- zonkFlats binds_var untch flat
zonkWCRec :: WantedConstraints -> TcM WantedConstraints
zonkWCRec (WC { wc_flat = flat, wc_impl = implic, wc_insol = insol })
= do { flat' <- zonkFlats flat
; implic' <- flatMapBagM zonkImplication implic
; insol' <- zonkCts insol -- No need to do the more elaborate zonkFlats thing
; insol' <- zonkFlats insol
; return (WC { wc_flat = flat', wc_impl = implic', wc_insol = insol' }) }
zonkFlats :: EvBindsVar -> Untouchables -> Cts -> TcM Cts
-- This zonks and unflattens a bunch of flat constraints
-- See Note [Unflattening while zonking]
zonkFlats binds_var untch cts
= do { -- See Note [How to unflatten]
cts <- foldrBagM unflatten_one emptyCts cts
; zonkCts cts }
where
unflatten_one orig_ct cts
= do { zct <- zonkCt orig_ct -- First we need to fully zonk
; mct <- try_zonk_fun_eq orig_ct zct -- Then try to solve if family equation
; return $ maybe cts (`consBag` cts) mct }
try_zonk_fun_eq orig_ct zct -- See Note [How to unflatten]
| EqPred ty_lhs ty_rhs <- classifyPredType (ctPred zct)
-- NB: zonking de-classifies the constraint,
-- so we can't look for CFunEqCan
, Just tv <- getTyVar_maybe ty_rhs
, ASSERT2( not (isFloatedTouchableMetaTyVar untch tv), ppr tv )
isTouchableMetaTyVar untch tv
, not (isSigTyVar tv) || isTyVarTy ty_lhs -- Never unify a SigTyVar with a non-tyvar
, typeKind ty_lhs `tcIsSubKind` tyVarKind tv -- c.f. TcInteract.trySpontaneousEqOneWay
, not (tv `elemVarSet` tyVarsOfType ty_lhs) -- Do not construct an infinite type
= ASSERT2( case tcSplitTyConApp_maybe ty_lhs of { Just (tc,_) -> isSynFamilyTyCon tc; _ -> False }, ppr orig_ct )
do { writeMetaTyVar tv ty_lhs
; let evterm = EvCoercion (mkTcNomReflCo ty_lhs)
evvar = ctev_evar (cc_ev zct)
; when (isWantedCt orig_ct) $ -- Can be derived (Trac #8129)
addTcEvBind binds_var evvar evterm
; traceTc "zonkFlats/unflattening" $
vcat [ text "zct = " <+> ppr zct,
text "binds_var = " <+> ppr binds_var ]
; return Nothing }
| otherwise
= return (Just zct)
\end{code}
Note [Unflattening while zonking]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A bunch of wanted constraints could contain wanted equations of the form
(F taus ~ alpha) where alpha is either an ordinary unification variable, or
a flatten unification variable.
These are ordinary wanted constraints and can/should be solved by
ordinary unification alpha := F taus. However the constraint solving
algorithm does not do that, as their 'inert' form is F taus ~ alpha.
Hence, we need an extra step to 'unflatten' these equations by
performing unification. This unification, if it happens at the end of
constraint solving, cannot produce any more interactions in the
constraint solver so it is safe to do it as the very very last step.
We choose therefore to do it during zonking, in the function
zonkFlats. This is in analogy to the zonking of given "flatten skolems"
which are eliminated in favor of the underlying type that they are
equal to.
Note that, because we now have to affect *evidence* while zonking
(setting some evidence binds to identities), we have to pass to the
zonkWC function an evidence variable to collect all the extra
variables.
Note [How to unflatten]
~~~~~~~~~~~~~~~~~~~~~~~
How do we unflatten during zonking. Consider a bunch of flat constraints.
Consider them one by one. For each such constraint C
* Zonk C (to apply current substitution)
* If C is of form F tys ~ alpha,
where alpha is touchable
and alpha is not mentioned in tys
then unify alpha := F tys
and discard C
After processing all the flat constraints, zonk them again to propagate
the inforamtion from later ones to earlier ones. Eg
Start: (F alpha ~ beta, G Int ~ alpha)
Then we get beta := F alpha
alpha := G Int
but we must apply the second unification to the first constraint.
\begin{code}
zonkCts :: Cts -> TcM Cts
zonkCts = mapBagM zonkCt
zonkFlats :: Cts -> TcM Cts
zonkFlats cts = do { cts' <- mapBagM zonkCt' cts
; traceTc "zonkFlats done:" (ppr cts')
; return cts' }
zonkCt' :: Ct -> TcM Ct
zonkCt' ct = zonkCt ct
zonkCt :: Ct -> TcM Ct
zonkCt ct@(CHoleCan { cc_ev = ev })
......
This diff is collapsed.
......@@ -168,7 +168,6 @@ tcRule (HsRule name act hs_bndrs lhs fv_lhs rhs fv_rhs)
; rhs_binds_var <- newTcEvBinds
; emitImplication $ Implic { ic_untch = noUntouchables
, ic_skols = qtkvs
, ic_fsks = []
, ic_no_eqs = False
, ic_given = lhs_evs
, ic_wanted = rhs_wanted
......@@ -183,7 +182,6 @@ tcRule (HsRule name act hs_bndrs lhs fv_lhs rhs fv_rhs)
; lhs_binds_var <- newTcEvBinds
; emitImplication $ Implic { ic_untch = noUntouchables
, ic_skols = qtkvs
, ic_fsks = []
, ic_no_eqs = False
, ic_given = lhs_evs
, ic_wanted = other_lhs_wanted
......
This diff is collapsed.
This diff is collapsed.
......@@ -24,7 +24,8 @@ module TcType (
TcTyVar, TcTyVarSet, TcKind, TcCoVar,
-- Untouchables
Untouchables(..), noUntouchables, pushUntouchables, isTouchable,
Untouchables(..), noUntouchables, pushUntouchables,
strictlyDeeperThan, sameDepthAs, fskUntouchables,
--------------------------------
-- MetaDetails
......@@ -32,12 +33,14 @@ module TcType (
TcTyVarDetails(..), pprTcTyVarDetails, vanillaSkolemTv, superSkolemTv,
MetaDetails(Flexi, Indirect), MetaInfo(..),
isImmutableTyVar, isSkolemTyVar, isMetaTyVar, isMetaTyVarTy, isTyVarTy,
isSigTyVar, isOverlappableTyVar, isTyConableTyVar, isFlatSkolTyVar,
isSigTyVar, isOverlappableTyVar, isTyConableTyVar,
isFskTyVar, isFmvTyVar, isFlattenTyVar,
isAmbiguousTyVar, metaTvRef, metaTyVarInfo,
isFlexi, isIndirect, isRuntimeUnkSkol,
isTypeVar, isKindVar,
metaTyVarUntouchables, setMetaTyVarUntouchables,
isTouchableMetaTyVar, isFloatedTouchableMetaTyVar,
metaTyVarUntouchables, setMetaTyVarUntouchables, metaTyVarUntouchables_maybe,
isTouchableMetaTyVar, isTouchableOrFmv,
isFloatedTouchableMetaTyVar,
--------------------------------
-- Builders
......@@ -274,17 +277,13 @@ data TcTyVarDetails
-- when looking up instances
-- See Note [Binding when looking up instances] in InstEnv
| FlatSkol -- A flatten-skolem. It stands for the TcType, and zonking
TcType -- will replace it by that type.
-- See Note [The flattening story] in TcFlatten
| RuntimeUnk -- Stands for an as-yet-unknown type in the GHCi
-- interactive context
| FlatSkol TcType
-- The "skolem" obtained by flattening during
-- constraint simplification
-- In comments we will use the notation alpha[flat = ty]
-- to represent a flattening skolem variable alpha
-- identified with type ty.
| MetaTv { mtv_info :: MetaInfo
, mtv_ref :: IORef MetaDetails
, mtv_untch :: Untouchables } -- See Note [Untouchable type variables]
......@@ -317,6 +316,10 @@ data MetaInfo
-- The MetaDetails, if filled in, will
-- always be another SigTv or a SkolemTv
| FlatMetaTv -- A flatten meta-tyvar
-- It is a meta-tyvar, but it is always untouchable, with level 0
-- See Note [The flattening story] in TcFlatten
-------------------------------------
-- UserTypeCtxt describes the origin of the polymorphic type
-- in the places where we need to an expression has that type
......@@ -420,30 +423,34 @@ The same idea of only unifying touchables solves another problem.
Suppose we had
(F Int ~ uf[0]) /\ [1](forall a. C a => F Int ~ beta[1])
In this example, beta is touchable inside the implication. The
first solveInteract step leaves 'uf' un-unified. Then we move inside
first solveFlatWanteds step leaves 'uf' un-unified. Then we move inside
the implication where a new constraint
uf ~ beta
emerges. If we (wrongly) spontaneously solved it to get uf := beta,
the whole implication disappears but when we pop out again we are left with
(F Int ~ uf) which will be unified by our final solveCTyFunEqs stage and
(F Int ~ uf) which will be unified by our final zonking stage and
uf will get unified *once more* to (F Int).
\begin{code}
newtype Untouchables = Untouchables Int
newtype Untouchables = Untouchables Int deriving( Eq )
-- See Note [Untouchable type variables] for what this Int is
fskUntouchables :: Untouchables
fskUntouchables = Untouchables 0 -- 0 = Outside the outermost level:
-- flatten skolems
noUntouchables :: Untouchables
noUntouchables = Untouchables 0 -- 0 = outermost level
noUntouchables = Untouchables 1 -- 1 = outermost level
pushUntouchables :: Untouchables -> Untouchables
pushUntouchables (Untouchables us) = Untouchables (us+1)
isFloatedTouchable :: Untouchables -> Untouchables -> Bool
isFloatedTouchable (Untouchables ctxt_untch) (Untouchables tv_untch)
= ctxt_untch < tv_untch
strictlyDeeperThan :: Untouchables -> Untouchables -> Bool
strictlyDeeperThan (Untouchables tv_untch) (Untouchables ctxt_untch)
= tv_untch > ctxt_untch
isTouchable :: Untouchables -> Untouchables -> Bool
isTouchable (Untouchables ctxt_untch) (Untouchables tv_untch)
sameDepthAs :: Untouchables -> Untouchables -> Bool
sameDepthAs (Untouchables ctxt_untch) (Untouchables tv_untch)
= ctxt_untch == tv_untch -- NB: invariant ctxt_untch >= tv_untch
-- So <= would be equivalent
......@@ -471,12 +478,13 @@ pprTcTyVarDetails (SkolemTv False) = ptext (sLit "sk")
pprTcTyVarDetails (RuntimeUnk {}) = ptext (sLit "rt")
pprTcTyVarDetails (FlatSkol {}) = ptext (sLit "fsk")
pprTcTyVarDetails (MetaTv { mtv_info = info, mtv_untch = untch })
= pp_info <> brackets (ppr untch)
= pp_info <> colon <> ppr untch
where
pp_info = case info of
PolyTv -> ptext (sLit "poly")
TauTv -> ptext (sLit "tau")
SigTv -> ptext (sLit "sig")
PolyTv -> ptext (sLit "poly")
TauTv -> ptext (sLit "tau")
SigTv -> ptext (sLit "sig")
FlatMetaTv -> ptext (sLit "fuv")
pprUserTypeCtxt :: UserTypeCtxt -> SDoc
pprUserTypeCtxt (InfSigCtxt n) = ptext (sLit "the inferred type for") <+> quotes (ppr n)
......@@ -583,6 +591,18 @@ exactTyVarsOfTypes = mapUnionVarSet exactTyVarsOfType
%************************************************************************
\begin{code}
isTouchableOrFmv :: Untouchables -> TcTyVar -> Bool
isTouchableOrFmv ctxt_untch tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
MetaTv { mtv_untch = tv_untch, mtv_info = info }
-> ASSERT2( checkTouchableInvariant ctxt_untch tv_untch,
ppr tv $$ ppr tv_untch $$ ppr ctxt_untch )
case info of
FlatMetaTv -> True
_ -> tv_untch `sameDepthAs` ctxt_untch
_ -> False
isTouchableMetaTyVar :: Untouchables -> TcTyVar -> Bool
isTouchableMetaTyVar ctxt_untch tv
= ASSERT2( isTcTyVar tv, ppr tv )
......@@ -590,14 +610,14 @@ isTouchableMetaTyVar ctxt_untch tv
MetaTv { mtv_untch = tv_untch }
-> ASSERT2( checkTouchableInvariant ctxt_untch tv_untch,
ppr tv $$ ppr tv_untch $$ ppr ctxt_untch )
isTouchable ctxt_untch tv_untch
tv_untch `sameDepthAs` ctxt_untch
_ -> False
isFloatedTouchableMetaTyVar :: Untouchables -> TcTyVar -> Bool
isFloatedTouchableMetaTyVar ctxt_untch tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
MetaTv { mtv_untch = tv_untch } -> isFloatedTouchable ctxt_untch tv_untch
MetaTv { mtv_untch = tv_untch } -> tv_untch `strictlyDeeperThan` ctxt_untch
_ -> False
isImmutableTyVar :: TyVar -> Bool
......@@ -606,7 +626,8 @@ isImmutableTyVar tv
| otherwise = True
isTyConableTyVar, isSkolemTyVar, isOverlappableTyVar,
isMetaTyVar, isAmbiguousTyVar, isFlatSkolTyVar :: TcTyVar -> Bool
isMetaTyVar, isAmbiguousTyVar,
isFmvTyVar, isFskTyVar, isFlattenTyVar :: TcTyVar -> Bool
isTyConableTyVar tv
-- True of a meta-type variable that can be filled in
......@@ -617,7 +638,22 @@ isTyConableTyVar tv
MetaTv { mtv_info = SigTv } -> False
_ -> True
isFlatSkolTyVar tv
isFmvTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
MetaTv { mtv_info = FlatMetaTv } -> True
_ -> False
-- | True of both given and wanted flatten-skolems (fak and usk)
isFlattenTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
FlatSkol {} -> True
MetaTv { mtv_info = FlatMetaTv } -> True
_ -> False
-- | True of FlatSkol skolems only
isFskTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
FlatSkol {} -> True
......@@ -626,10 +662,8 @@ isFlatSkolTyVar tv
isSkolemTyVar tv
= ASSERT2( isTcTyVar tv, ppr tv )
case tcTyVarDetails tv of
SkolemTv {} -> True
FlatSkol {} -> True
RuntimeUnk {} -> True
MetaTv {} -> False
MetaTv {} -> False
_other -> True
isOverlappableTyVar tv
= ASSERT( isTcTyVar tv )
......@@ -673,6 +707,13 @@ metaTyVarUntouchables tv
MetaTv { mtv_untch = untch } -> untch
_ -> pprPanic "metaTyVarUntouchables" (ppr tv)
metaTyVarUntouchables_maybe :: TcTyVar -> Maybe Untouchables
metaTyVarUntouchables_maybe tv
= ASSERT( isTcTyVar tv )
case tcTyVarDetails tv of
MetaTv { mtv_untch = untch } -> Just untch
_ -> Nothing
setMetaTyVarUntouchables :: TcTyVar -> Untouchables -> TcTyVar
setMetaTyVarUntouchables tv untch
= ASSERT( isTcTyVar tv )
......
......@@ -451,7 +451,6 @@ newImplication skol_info skol_tvs given thing_inside
; env <- getLclEnv
; emitImplication $ Implic { ic_untch = untch
, ic_skols = skol_tvs
, ic_fsks = []
, ic_no_eqs = False
, ic_given = given
, ic_wanted = wanted
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment