TcValidity

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

TcValidity

Synopsis

- data Rank
- data UserTypeCtxt
  - = FunSigCtxt Name Bool
  - | InfSigCtxt Name
  - | ExprSigCtxt
  - | KindSigCtxt
  - | TypeAppCtxt
  - | ConArgCtxt Name
  - | TySynCtxt Name
  - | PatSynCtxt Name
  - | PatSigCtxt
  - | RuleSigCtxt Name
  - | ResSigCtxt
  - | ForSigCtxt Name
  - | DefaultDeclCtxt
  - | InstDeclCtxt
  - | SpecInstCtxt
  - | ThBrackCtxt
  - | GenSigCtxt
  - | GhciCtxt
  - | ClassSCCtxt Name
  - | SigmaCtxt
  - | DataTyCtxt Name
  - | DerivClauseCtxt
  - | TyVarBndrKindCtxt Name
  - | DataKindCtxt Name
  - | TySynKindCtxt Name
  - | TyFamResKindCtxt Name
- checkValidType :: UserTypeCtxt -> Type -> TcM ()
- checkValidMonoType :: Type -> TcM ()
- data ContextKind
  - = TheKind Kind
  - | AnythingKind
  - | OpenKind
- expectedKindInCtxt :: UserTypeCtxt -> ContextKind
- checkValidTheta :: UserTypeCtxt -> ThetaType -> TcM ()
- checkValidFamPats :: Maybe ClsInstInfo -> TyCon -> [TyVar] -> [CoVar] -> [Type] -> [Type] -> SDoc -> TcM ()
- checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM ([TyVar], ThetaType, Class, [Type])
- checkValidInstHead :: UserTypeCtxt -> Class -> [Type] -> TcM ()
- validDerivPred :: TyVarSet -> PredType -> Bool
- checkTySynRhs :: UserTypeCtxt -> TcType -> TcM ()
- type ClsInstInfo = (Class, [TyVar], VarEnv Type)
- checkValidCoAxiom :: CoAxiom Branched -> TcM ()
- checkValidCoAxBranch :: Maybe ClsInstInfo -> TyCon -> CoAxBranch -> TcM ()
- checkValidTyFamEqn :: Maybe ClsInstInfo -> TyCon -> [TyVar] -> [CoVar] -> [Type] -> Type -> SDoc -> SrcSpan -> TcM ()
- arityErr :: Outputable a => SDoc -> a -> Int -> Int -> SDoc
- badATErr :: Name -> Name -> SDoc
- checkValidTelescope :: [TyConBinder] -> SDoc -> SDoc -> TcM ()
- allDistinctTyVars :: TyVarSet -> [KindOrType] -> Bool

# Documentation

data Rank #

data UserTypeCtxt #

Constructors

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

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

checkValidMonoType :: Type -> TcM () #

data ContextKind #

The kind expected in a certain context.

Constructors

TheKind Kind | a specific kind
AnythingKind | any kind will do
OpenKind | something of the form `TYPE _`

expectedKindInCtxt :: UserTypeCtxt -> ContextKind #

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

checkValidFamPats #

Arguments

:: Maybe ClsInstInfo |
-> TyCon |
-> [TyVar] |
-> [CoVar] |
-> [Type] | patterns the user wrote
-> [Type] | "extra" patterns from a data instance kind sig
-> SDoc | pretty-printed user-written instance head
-> TcM () |

checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM ([TyVar], ThetaType, Class, [Type]) #

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

validDerivPred :: TyVarSet -> PredType -> Bool #

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

type ClsInstInfo = (Class, [TyVar], VarEnv Type) #

Extra information about the parent instance declaration, needed when type-checking associated types. The `Class` is the enclosing class, the [TyVar] are the type variable of the instance decl, and and the `VarEnv Type` maps class variables to their instance types.

checkValidCoAxiom :: CoAxiom Branched -> TcM () #

checkValidCoAxBranch :: Maybe ClsInstInfo -> TyCon -> CoAxBranch -> TcM () #

checkValidTyFamEqn #

Arguments

:: Maybe ClsInstInfo |
-> TyCon | of the type family
-> [TyVar] | bound tyvars in the equation
-> [CoVar] | bound covars in the equation
-> [Type] | type patterns
-> Type | rhs
-> SDoc | user-written LHS
-> SrcSpan |
-> TcM () |

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

arityErr :: Outputable a => SDoc -> a -> Int -> Int -> SDoc #

badATErr :: Name -> Name -> SDoc #

checkValidTelescope :: [TyConBinder] -> SDoc -> SDoc -> TcM () #

Check a list of binders to see if they make a valid telescope. The key property we're checking for is scoping. For example: > data SameKind :: k -> k -> * > data X a k (b :: k) (c :: SameKind a b) Kind inference says that a's kind should be k. But that's impossible, because k isn't in scope when a is bound. This check has to come before general validity checking, because once we kind-generalise, this sort of problem is harder to spot (as we'll generalise over the unbound k in a's type.) See also Note [Bad telescopes].

allDistinctTyVars :: TyVarSet -> [KindOrType] -> Bool #