TcUnify

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

TcUnify

Synopsis

- tcWrapResult :: HsExpr GhcRn -> HsExpr GhcTcId -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTcId)
- tcWrapResultO :: CtOrigin -> HsExpr GhcRn -> HsExpr GhcTcId -> TcSigmaType -> ExpRhoType -> TcM (HsExpr GhcTcId)
- tcSkolemise :: UserTypeCtxt -> TcSigmaType -> ([TcTyVar] -> TcType -> TcM result) -> TcM (HsWrapper, result)
- tcSkolemiseET :: UserTypeCtxt -> ExpSigmaType -> (ExpRhoType -> TcM result) -> TcM (HsWrapper, result)
- tcSubTypeHR :: CtOrigin -> Maybe (HsExpr GhcRn) -> TcSigmaType -> ExpRhoType -> TcM HsWrapper
- tcSubTypeO :: CtOrigin -> UserTypeCtxt -> TcSigmaType -> ExpRhoType -> TcM HsWrapper
- tcSubType_NC :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper
- tcSubTypeDS :: CtOrigin -> UserTypeCtxt -> TcSigmaType -> ExpRhoType -> TcM HsWrapper
- tcSubTypeDS_NC_O :: CtOrigin -> UserTypeCtxt -> Maybe (HsExpr GhcRn) -> TcSigmaType -> ExpRhoType -> TcM HsWrapper
- tcSubTypeET :: CtOrigin -> UserTypeCtxt -> ExpSigmaType -> TcSigmaType -> TcM HsWrapper
- checkConstraints :: SkolemInfo -> [TcTyVar] -> [EvVar] -> TcM result -> TcM (TcEvBinds, result)
- checkTvConstraints :: SkolemInfo -> Maybe SDoc -> TcM ([TcTyVar], result) -> TcM ([TcTyVar], result)
- buildImplicationFor :: TcLevel -> SkolemInfo -> [TcTyVar] -> [EvVar] -> WantedConstraints -> TcM (Bag Implication, TcEvBinds)
- unifyType :: Maybe (HsExpr GhcRn) -> TcTauType -> TcTauType -> TcM TcCoercionN
- unifyTheta :: TcThetaType -> TcThetaType -> TcM [TcCoercionN]
- unifyKind :: Maybe (HsType GhcRn) -> TcKind -> TcKind -> TcM CoercionN
- uType :: TypeOrKind -> CtOrigin -> TcType -> TcType -> TcM Coercion
- promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType)
- swapOverTyVars :: TcTyVar -> TcTyVar -> Bool
- canSolveByUnification :: TcLevel -> TcTyVar -> TcType -> Bool
- tcInferInst :: (ExpRhoType -> TcM a) -> TcM (a, TcRhoType)
- tcInferNoInst :: (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 -> Arity -> ExpRhoType -> ([ExpSigmaType] -> ExpRhoType -> TcM a) -> TcM (a, HsWrapper)
- matchActualFunTys :: SDoc -> CtOrigin -> Maybe (HsExpr GhcRn) -> Arity -> TcSigmaType -> TcM (HsWrapper, [TcSigmaType], TcSigmaType)
- matchActualFunTysPart :: SDoc -> CtOrigin -> Maybe (HsExpr GhcRn) -> Arity -> TcSigmaType -> [TcSigmaType] -> Arity -> TcM (HsWrapper, [TcSigmaType], TcSigmaType)
- matchExpectedFunKind :: Outputable fun => fun -> TcKind -> TcM (Coercion, TcKind, TcKind)
- metaTyVarUpdateOK :: DynFlags -> TcTyVar -> TcType -> Maybe TcType
- occCheckForErrors :: DynFlags -> TcTyVar -> Type -> OccCheckResult ()
- data OccCheckResult a
  - = OC_OK a
  - | OC_Bad
  - | OC_Occurs

# Documentation

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

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

Sometimes we don't have a `HsExpr Name` to hand, and this is more convenient.

tcSkolemise #

Arguments

:: UserTypeCtxt |
-> TcSigmaType |
-> ([TcTyVar] -> TcType -> TcM result) | These are only ever used for scoped type variables.
-> TcM (HsWrapper, result) | The expression has type: spec_ty -> expected_ty

Take an "expected type" and strip off quantifiers to expose the type underneath, binding the new skolems for the `thing_inside`. The returned `HsWrapper` has type `specific_ty -> expected_ty`.

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

Variant of `tcSkolemise` that takes an ExpType

tcSubTypeHR #

Arguments

:: CtOrigin | of the actual type
-> Maybe (HsExpr GhcRn) | If present, it has type ty_actual
-> TcSigmaType |
-> ExpRhoType |
-> TcM HsWrapper |

Call this variant when you are in a higher-rank situation and you know the right-hand type is deeply skolemised.

tcSubTypeO #

Arguments

:: CtOrigin | of the actual type
-> UserTypeCtxt | of the expected type
-> TcSigmaType |
-> ExpRhoType |
-> TcM HsWrapper |

tcSubType_NC :: UserTypeCtxt -> TcSigmaType -> TcSigmaType -> TcM HsWrapper #

tcSubTypeDS :: CtOrigin -> UserTypeCtxt -> TcSigmaType -> ExpRhoType -> TcM HsWrapper #

tcSubTypeDS_NC_O :: CtOrigin -> UserTypeCtxt -> Maybe (HsExpr GhcRn) -> TcSigmaType -> ExpRhoType -> TcM HsWrapper #

tcSubTypeET :: CtOrigin -> UserTypeCtxt -> ExpSigmaType -> TcSigmaType -> TcM HsWrapper #

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

checkTvConstraints :: SkolemInfo -> Maybe SDoc -> TcM ([TcTyVar], result) -> TcM ([TcTyVar], result) #

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

unifyType #

Arguments

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

unifyTheta :: TcThetaType -> TcThetaType -> TcM [TcCoercionN] #

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

uType :: TypeOrKind -> CtOrigin -> TcType -> TcType -> TcM Coercion #

promoteTcType :: TcLevel -> TcType -> TcM (TcCoercion, TcType) #

swapOverTyVars :: TcTyVar -> TcTyVar -> Bool #

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

tcInferInst :: (ExpRhoType -> TcM a) -> TcM (a, TcRhoType) #

tcInferNoInst :: (ExpSigmaType -> TcM a) -> TcM (a, TcSigmaType) #

Infer a type using a fresh ExpType See also Note [ExpType] in TcMType Does not attempt to instantiate the inferred type

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

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

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

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

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

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

Variant of `matchActualFunTys` that works when supplied only part (that is, to the right of some arrows) of the full function type

matchExpectedFunKind #

Arguments

:: Outputable fun |
=> fun | type, only for errors
-> TcKind | function kind
-> TcM (Coercion, TcKind, TcKind) | co :: old_kind ~ arg -> res

Breaks apart a function kind into its pieces.

metaTyVarUpdateOK :: DynFlags -> TcTyVar -> TcType -> Maybe TcType #

occCheckForErrors :: DynFlags -> TcTyVar -> Type -> OccCheckResult () #

data OccCheckResult a #

Constructors

OC_OK a |
OC_Bad |
OC_Occurs |

Instances

Monad OccCheckResult # |
Instance details Defined in TcUnify Methods (>>=) :: OccCheckResult a -> (a -> OccCheckResult b) -> OccCheckResult b Source # (>>) :: OccCheckResult a -> OccCheckResult b -> OccCheckResult b Source # return :: a -> OccCheckResult a Source # fail :: String -> OccCheckResult a Source #
Functor OccCheckResult # |
Instance details Defined in TcUnify Methods fmap :: (a -> b) -> OccCheckResult a -> OccCheckResult b Source # (<$) :: a -> OccCheckResult b -> OccCheckResult a Source #
Applicative OccCheckResult # |
Instance details Defined in TcUnify Methods pure :: a -> OccCheckResult a Source # (<*>) :: OccCheckResult (a -> b) -> OccCheckResult a -> OccCheckResult b Source # liftA2 :: (a -> b -> c) -> OccCheckResult a -> OccCheckResult b -> OccCheckResult c Source # (*>) :: OccCheckResult a -> OccCheckResult b -> OccCheckResult b Source # (<*) :: OccCheckResult a -> OccCheckResult b -> OccCheckResult a Source #