GHC.Tc.Utils.Unify

ghc-9.0.0.20201227: The GHC API

Safe Haskell | None
Language | Haskell2010

GHC.Tc.Utils.Unify

Description

Type subsumption and unification

Synopsis

- tcWrapResult :: HsExpr GhcRn -> HsExpr GhcTc -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTc)
- tcWrapResultO :: CtOrigin -> HsExpr GhcRn -> HsExpr GhcTc -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTc)
- tcWrapResultMono :: HsExpr GhcRn -> HsExpr GhcTc -> TcRhoType -> ExpRhoType -> TcM (HsExpr GhcTc)
- tcSkolemise :: UserTypeCtxt -> TcSigmaType -> (TcType -> TcM result) -> TcM (HsWrapper, result)
- tcSkolemiseScoped :: UserTypeCtxt -> TcSigmaType -> (TcType -> TcM result) -> TcM (HsWrapper, result)
- tcSkolemiseET :: UserTypeCtxt -> ExpSigmaType -> (ExpRhoType -> TcM result) -> TcM (HsWrapper, result)
- tcSubType :: CtOrigin -> UserTypeCtxt -> TcSigmaType -> ExpRhoType -> TcM HsWrapper
- tcSubTypeSigma :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper
- tcSubTypePat :: CtOrigin -> UserTypeCtxt -> ExpSigmaType -> TcSigmaType -> TcM HsWrapper
- tcSubMult :: CtOrigin -> Mult -> Mult -> TcM HsWrapper
- checkConstraints :: SkolemInfo -> [TcTyVar] -> [EvVar] -> TcM result -> TcM (TcEvBinds, result)
- checkTvConstraints :: SkolemInfo -> [TcTyVar] -> TcM result -> TcM result
- buildImplicationFor :: TcLevel -> SkolemInfo -> [TcTyVar] -> [EvVar] -> WantedConstraints -> TcM (Bag Implication, TcEvBinds)
- buildTvImplication :: SkolemInfo -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM Implication
- emitResidualTvConstraint :: SkolemInfo -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM ()
- unifyType :: Maybe (HsExpr GhcRn) -> TcTauType -> TcTauType -> TcM TcCoercionN
- unifyKind :: Maybe (HsType GhcRn) -> TcKind -> TcKind -> TcM CoercionN
- uType :: TypeOrKind -> CtOrigin -> TcType -> TcType -> TcM CoercionN
- promoteTcType :: TcLevel -> TcType -> TcM (TcCoercionN, TcType)
- swapOverTyVars :: Bool -> TcTyVar -> TcTyVar -> Bool
- canSolveByUnification :: TcLevel -> TcTyVar -> TcType -> Bool
- tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType)
- matchExpectedListTy :: TcRhoType -> TcM (TcCoercionN, TcRhoType)
- matchExpectedTyConApp :: TyCon -> TcRhoType -> TcM (TcCoercionN, [TcSigmaType])
- matchExpectedAppTy :: TcRhoType -> TcM (TcCoercion, (TcSigmaType, TcSigmaType))
- matchExpectedFunTys :: forall a. SDoc -> UserTypeCtxt -> Arity -> ExpRhoType -> ([Scaled ExpSigmaType] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a)
- matchActualFunTysRho :: SDoc -> CtOrigin -> Maybe (HsExpr GhcRn) -> Arity -> TcSigmaType -> TcM (HsWrapper, [Scaled TcSigmaType], TcRhoType)
- matchActualFunTySigma :: SDoc -> CtOrigin -> Maybe (HsExpr GhcRn) -> (Arity, [Scaled TcSigmaType]) -> TcSigmaType -> TcM (HsWrapper, Scaled TcSigmaType, TcSigmaType)
- matchExpectedFunKind :: Outputable fun => fun -> Arity -> TcKind -> TcM Coercion
- metaTyVarUpdateOK :: DynFlags -> TcTyVar -> TcType -> MetaTyVarUpdateResult TcType
- occCheckForErrors :: DynFlags -> TcTyVar -> Type -> MetaTyVarUpdateResult ()
- data MetaTyVarUpdateResult a
  - = MTVU_OK a
  - | MTVU_Bad
  - | MTVU_HoleBlocker
  - | MTVU_Occurs

# Documentation

tcWrapResult :: HsExpr GhcRn -> HsExpr GhcTc -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTc) Source #

tcWrapResultO :: CtOrigin -> HsExpr GhcRn -> HsExpr GhcTc -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTc) Source #

tcWrapResultMono :: HsExpr GhcRn -> HsExpr GhcTc -> TcRhoType -> ExpRhoType -> TcM (HsExpr GhcTc) Source #

tcSkolemise Source #

Arguments

:: UserTypeCtxt |
-> TcSigmaType |
-> (TcType -> TcM result) |
-> TcM (HsWrapper, result) | The wrapper has type: spec_ty ~> expected_ty

tcSkolemiseScoped Source #

Arguments

:: UserTypeCtxt |
-> TcSigmaType |
-> (TcType -> TcM result) |
-> TcM (HsWrapper, result) | The wrapper has type: spec_ty ~> expected_ty

tcSkolemiseET :: UserTypeCtxt -> ExpSigmaType -> (ExpRhoType -> TcM result) -> TcM (HsWrapper, result) Source #

Variant of `tcSkolemise` that takes an ExpType

tcSubType :: CtOrigin -> UserTypeCtxt -> TcSigmaType -> ExpRhoType -> TcM HsWrapper Source #

tcSubTypeSigma :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper Source #

tcSubTypePat :: CtOrigin -> UserTypeCtxt -> ExpSigmaType -> TcSigmaType -> TcM HsWrapper Source #

tcSubMult :: CtOrigin -> Mult -> Mult -> TcM HsWrapper Source #

checkConstraints :: SkolemInfo -> [TcTyVar] -> [EvVar] -> TcM result -> TcM (TcEvBinds, result) Source #

checkTvConstraints :: SkolemInfo -> [TcTyVar] -> TcM result -> TcM result Source #

buildImplicationFor :: TcLevel -> SkolemInfo -> [TcTyVar] -> [EvVar] -> WantedConstraints -> TcM (Bag Implication, TcEvBinds) Source #

buildTvImplication :: SkolemInfo -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM Implication Source #

emitResidualTvConstraint :: SkolemInfo -> [TcTyVar] -> TcLevel -> WantedConstraints -> TcM () Source #

unifyType Source #

Arguments

:: Maybe (HsExpr GhcRn) | If present, has type `ty1`
-> TcTauType |
-> TcTauType |
-> TcM TcCoercionN |

unifyKind :: Maybe (HsType GhcRn) -> TcKind -> TcKind -> TcM CoercionN Source #

uType :: TypeOrKind -> CtOrigin -> TcType -> TcType -> TcM CoercionN Source #

promoteTcType :: TcLevel -> TcType -> TcM (TcCoercionN, TcType) Source #

swapOverTyVars :: Bool -> TcTyVar -> TcTyVar -> Bool Source #

canSolveByUnification :: TcLevel -> TcTyVar -> TcType -> Bool Source #

tcInfer :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) Source #

Infer a type using a fresh ExpType See also Note [ExpType] in GHC.Tc.Utils.TcMType

matchExpectedListTy :: TcRhoType -> TcM (TcCoercionN, TcRhoType) Source #

matchExpectedTyConApp :: TyCon -> TcRhoType -> TcM (TcCoercionN, [TcSigmaType]) Source #

matchExpectedAppTy :: TcRhoType -> TcM (TcCoercion, (TcSigmaType, TcSigmaType)) Source #

matchExpectedFunTys :: forall a. SDoc -> UserTypeCtxt -> Arity -> ExpRhoType -> ([Scaled ExpSigmaType] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a) Source #

matchActualFunTysRho :: SDoc -> CtOrigin -> Maybe (HsExpr GhcRn) -> Arity -> TcSigmaType -> TcM (HsWrapper, [Scaled TcSigmaType], TcRhoType) Source #

matchActualFunTySigma :: SDoc -> CtOrigin -> Maybe (HsExpr GhcRn) -> (Arity, [Scaled TcSigmaType]) -> TcSigmaType -> TcM (HsWrapper, Scaled TcSigmaType, TcSigmaType) Source #

matchActualFunTySigm does looks for just one function arrow returning an uninstantiated sigma-type

matchExpectedFunKind Source #

Arguments

:: Outputable fun |
=> fun | type, only for errors
-> Arity | n: number of desired arrows
-> TcKind | fun_ kind
-> TcM Coercion | co :: fun_kind ~ (arg1 -> ... -> argn -> res)

Breaks apart a function kind into its pieces.

metaTyVarUpdateOK :: DynFlags -> TcTyVar -> TcType -> MetaTyVarUpdateResult TcType Source #

occCheckForErrors :: DynFlags -> TcTyVar -> Type -> MetaTyVarUpdateResult () Source #

data MetaTyVarUpdateResult a Source #

Constructors

MTVU_OK a |
MTVU_Bad |
MTVU_HoleBlocker |
MTVU_Occurs |

#### Instances

Instances details

Monad MetaTyVarUpdateResult # |
Instance details Defined in GHC.Tc.Utils.Unify Methods (>>=) :: MetaTyVarUpdateResult a -> (a -> MetaTyVarUpdateResult b) -> MetaTyVarUpdateResult b Source # (>>) :: MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult b Source # return :: a -> MetaTyVarUpdateResult a Source #
Functor MetaTyVarUpdateResult # |
Instance details Defined in GHC.Tc.Utils.Unify Methods fmap :: (a -> b) -> MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b Source # (<$) :: a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult a Source #
Applicative MetaTyVarUpdateResult # |
Instance details Defined in GHC.Tc.Utils.Unify Methods pure :: a -> MetaTyVarUpdateResult a Source # (<*>) :: MetaTyVarUpdateResult (a -> b) -> MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b Source # liftA2 :: (a -> b -> c) -> MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult c Source # (*>) :: MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult b Source # (<*) :: MetaTyVarUpdateResult a -> MetaTyVarUpdateResult b -> MetaTyVarUpdateResult a Source #
Outputable a => Outputable (MetaTyVarUpdateResult a) # |
Instance details Defined in GHC.Tc.Utils.Unify Methods ppr :: MetaTyVarUpdateResult a -> SDoc Source # pprPrec :: Rational -> MetaTyVarUpdateResult a -> SDoc Source #