ghc-9.10.3: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Tc.Validity

Synopsis

- data Rank
  - = ArbitraryRank
  - | LimitedRank Bool Rank
  - | MonoTypeRankZero
  - | MonoTypeTyConArg
  - | MonoTypeSynArg
  - | MonoTypeConstraint
  - | MustBeMonoType
- data UserTypeCtxt
  - = FunSigCtxt Name ReportRedundantConstraints
  - | InfSigCtxt Name
  - | ExprSigCtxt ReportRedundantConstraints
  - | KindSigCtxt
  - | StandaloneKindSigCtxt Name
  - | TypeAppCtxt
  - | ConArgCtxt Name
  - | TySynCtxt Name
  - | PatSynCtxt Name
  - | PatSigCtxt
  - | RuleSigCtxt FastString Name
  - | ForSigCtxt Name
  - | DefaultDeclCtxt
  - | InstDeclCtxt Bool
  - | SpecInstCtxt
  - | GenSigCtxt
  - | GhciCtxt Bool
  - | ClassSCCtxt Name
  - | SigmaCtxt
  - | DataTyCtxt Name
  - | DerivClauseCtxt
  - | TyVarBndrKindCtxt Name
  - | DataKindCtxt Name
  - | TySynKindCtxt Name
  - | TyFamResKindCtxt Name
- checkValidType :: UserTypeCtxt -> Type -> TcM ()
- checkValidMonoType :: Type -> TcM ()
- checkValidTheta :: UserTypeCtxt -> ThetaType -> TcM ()
- checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM ()
- checkValidInstHead :: UserTypeCtxt -> Class -> [Type] -> TcM ()
- validDerivPred :: PatersonSize -> PredType -> Bool
- checkTySynRhs :: UserTypeCtxt -> TcType -> TcM ()
- checkEscapingKind :: Type -> TcM ()
- checkValidCoAxiom :: CoAxiom Branched -> TcM ()
- checkValidCoAxBranch :: TyCon -> CoAxBranch -> TcM ()
- checkFamPatBinders :: TyCon -> [TcTyVar] -> TyVarSet -> [TcType] -> TcType -> TcM ()
- checkTyFamEqnValidityInfo :: TyCon -> TyFamEqnValidityInfo -> TcM ()
- checkValidTyFamEqn :: TyCon -> [Type] -> Type -> TcM ()
- checkValidAssocTyFamDeflt :: TyCon -> [Type] -> TcM ()
- checkConsistentFamInst :: AssocInstInfo -> TyCon -> CoAxBranch -> TcM ()
- checkTyConTelescope :: TyCon -> TcM ()

# Documentation

data Rank Source #

Constructors

ArbitraryRank |
LimitedRank Bool Rank |
MonoTypeRankZero |
MonoTypeTyConArg |
MonoTypeSynArg |
MonoTypeConstraint |
MustBeMonoType |

#### Instances

Instances details

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

data UserTypeCtxt Source #

UserTypeCtxt describes the origin of the polymorphic type in the places where we need an expression to have that type

Constructors

FunSigCtxt Name ReportRedundantConstraints |
InfSigCtxt Name |
ExprSigCtxt ReportRedundantConstraints |
KindSigCtxt |
StandaloneKindSigCtxt Name |
TypeAppCtxt |
ConArgCtxt Name |
TySynCtxt Name |
PatSynCtxt Name |
PatSigCtxt |
RuleSigCtxt FastString Name |
ForSigCtxt Name |
DefaultDeclCtxt |
InstDeclCtxt Bool |
SpecInstCtxt |
GenSigCtxt |
GhciCtxt Bool |
ClassSCCtxt Name |
SigmaCtxt |
DataTyCtxt Name |
DerivClauseCtxt |
TyVarBndrKindCtxt Name |
DataKindCtxt Name |
TySynKindCtxt Name |
TyFamResKindCtxt Name |

#### Instances

Instances details

Eq UserTypeCtxt Source # |
Instance details Defined in GHC.Tc.Types.Origin Methods (==) :: UserTypeCtxt -> UserTypeCtxt -> Bool # (/=) :: UserTypeCtxt -> UserTypeCtxt -> Bool #

checkValidType :: UserTypeCtxt -> Type -> TcM () Source #

checkValidMonoType :: Type -> TcM () Source #

checkValidTheta :: UserTypeCtxt -> ThetaType -> TcM () Source #

checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () Source #

checkValidInstHead :: UserTypeCtxt -> Class -> [Type] -> TcM () Source #

validDerivPred :: PatersonSize -> PredType -> Bool Source #

checkTySynRhs :: UserTypeCtxt -> TcType -> TcM () Source #

checkEscapingKind :: Type -> TcM () Source #

checkValidCoAxiom :: CoAxiom Branched -> TcM () Source #

checkValidCoAxBranch :: TyCon -> CoAxBranch -> TcM () Source #

checkFamPatBinders Source #

Arguments

:: TyCon |
-> [TcTyVar] | Bound on LHS of family instance
-> TyVarSet | non-user-written tyvars
-> [TcType] | LHS patterns
-> TcType | RHS
-> TcM () |

Check binders for a type or data family declaration.

Specifically, this function checks for:

- type variables used on the RHS but not bound (explicitly or implicitly) in the LHS,
- variables bound by a forall in the LHS but not used in the RHS.

See Note [Check type family instance binders].

checkTyFamEqnValidityInfo :: TyCon -> TyFamEqnValidityInfo -> TcM () Source #

Perform scoping check on a type family equation.

See `TyFamEqnValidityInfo`.

checkValidTyFamEqn Source #

Arguments

:: TyCon | of the type family
-> [Type] | Type patterns
-> Type | Rhs
-> TcM () |

Do validity checks on a type family equation, including consistency with any enclosing class instance head, termination, and lack of polytypes.

See also the separate `checkFamPatBinders` which performs scoping checks on a type family equation. (It's separate because it expects `TyFamEqnValidityInfo`, which comes from a separate place e.g. for associated type defaults.)

checkValidAssocTyFamDeflt Source #

Arguments

:: TyCon | of the type family
-> [Type] | Type patterns
-> TcM () |

Checks that an associated type family default:

1. Only consists of arguments that are bare type variables, and
2. Has a distinct type variable in each argument.

See `Note [Type-checking default assoc decls]` in GHC.Tc.TyCl.

checkConsistentFamInst Source #

Arguments

:: AssocInstInfo |
-> TyCon | Family tycon
-> CoAxBranch |
-> TcM () |

checkTyConTelescope :: TyCon -> TcM () Source #