TcHsType

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

TcHsType

Synopsis

- kcHsSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM ()
- tcClassSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM Type
- tcHsSigType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type
- tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM Type
- tcHsPartialSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], Maybe TcType, [Name], [TcTyVar], TcThetaType, TcType)
- funsSigCtxt :: [Located Name] -> UserTypeCtxt
- addSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> TcM a -> TcM a
- pprSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> SDoc
- tcHsClsInstType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM ([TyVar], ThetaType, Class, [Type])
- tcHsDeriv :: LHsSigType GhcRn -> TcM ([TyVar], (Class, [Type], [Kind]))
- tcDerivStrategy :: forall a. UserTypeCtxt -> Maybe (DerivStrategy GhcRn) -> TcM ([TyVar], a) -> TcM (Maybe (DerivStrategy GhcTc), [TyVar], a)
- tcHsTypeApp :: LHsWcType GhcRn -> Kind -> TcM Type
- 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
- tcImplicitTKBndrs :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a)
- tcImplicitQTKBndrs :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a)
- tcExplicitTKBndrs :: SkolemInfo -> [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a)
- kcExplicitTKBndrs :: [LHsTyVarBndr GhcRn] -> TcM a -> TcM a
- kcImplicitTKBndrs :: [Name] -> TcM a -> TcM ([TcTyVar], a)
- kcLookupTcTyCon :: Name -> TcM TcTyCon
- kcTyClTyVars :: Name -> TcM a -> TcM a
- tcTyClTyVars :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a
- tcDataKindSig :: [TyConBinder] -> Kind -> TcM ([TyConBinder], Kind)
- scopeTyVars :: SkolemInfo -> [TcTyVar] -> TcM a -> TcM a
- scopeTyVars2 :: SkolemInfo -> [(Name, TcTyVar)] -> TcM a -> TcM a
- kcLHsQTyVars :: Name -> TyConFlavour -> Bool -> LHsQTyVars GhcRn -> TcM Kind -> TcM TcTyCon
- tcWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a
- tcHsLiftedType :: LHsType GhcRn -> TcM TcType
- tcHsOpenType :: LHsType GhcRn -> TcM TcType
- tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType
- tcHsOpenTypeNC :: LHsType GhcRn -> TcM TcType
- tcLHsType :: LHsType GhcRn -> TcM (TcType, TcKind)
- tcLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind)
- tcCheckLHsType :: LHsType GhcRn -> Kind -> TcM TcType
- tcHsMbContext :: Maybe (LHsContext GhcRn) -> TcM [PredType]
- tcHsContext :: LHsContext GhcRn -> TcM [PredType]
- tcLHsPredType :: LHsType GhcRn -> TcM PredType
- tcInferApps :: TcTyMode -> Maybe (VarEnv Kind) -> LHsType GhcRn -> TcType -> TcKind -> [LHsType GhcRn] -> TcM (TcType, [TcType], TcKind)
- solveEqualities :: TcM a -> TcM a
- typeLevelMode :: TcTyMode
- kindLevelMode :: TcTyMode
- kindGeneralize :: TcType -> TcM [KindVar]
- checkExpectedKindX :: Maybe (VarEnv Kind) -> SDoc -> TcType -> TcKind -> TcKind -> TcM (TcType, [TcType], TcCoercionN)
- instantiateTyUntilN :: Maybe (VarEnv Kind) -> Int -> TcKind -> TcM ([TcType], TcKind)
- reportFloatingKvs :: Name -> TyConFlavour -> [TcTyVar] -> [TcTyVar] -> TcM ()
- tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind
- badKindSig :: Bool -> Kind -> SDoc
- zonkPromoteType :: TcType -> TcM TcType
- tcHsPatSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType)
- tcPatSig :: Bool -> LHsSigWcType GhcRn -> ExpSigmaType -> TcM (TcType, [(Name, TcTyVar)], [(Name, TcTyVar)], HsWrapper)
- funAppCtxt :: (Outputable fun, Outputable arg) => fun -> arg -> Int -> SDoc

# Documentation

kcHsSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM () #

tcClassSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM Type #

tcHsSigType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type #

tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM Type #

tcHsPartialSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], Maybe TcType, [Name], [TcTyVar], TcThetaType, TcType) #

funsSigCtxt :: [Located Name] -> UserTypeCtxt #

addSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> TcM a -> TcM a #

pprSigCtxt :: UserTypeCtxt -> LHsType GhcRn -> SDoc #

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

tcHsDeriv :: LHsSigType GhcRn -> TcM ([TyVar], (Class, [Type], [Kind])) #

tcDerivStrategy #

Arguments

:: UserTypeCtxt |
-> Maybe (DerivStrategy GhcRn) | The deriving strategy
-> TcM ([TyVar], a) | The thing to typecheck within the context of the deriving strategy, which might quantify some type variables of its own.
-> TcM (Maybe (DerivStrategy GhcTc), [TyVar], a) | The typechecked deriving strategy, all quantified tyvars, and the payload of the typechecked thing.

Typecheck something within the context of a deriving strategy. This is of particular importance when the deriving strategy is `via`. For instance:

    deriving via (S a) instance C (T a)

We need to typecheck `S a`, and moreover, we need to extend the tyvar environment with `a` before typechecking `C (T a)`, since `S a` quantified the type variable `a`.

tcHsTypeApp :: LHsWcType GhcRn -> Kind -> TcM Type #

Type-check a visible type application

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 |

tcImplicitTKBndrs :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) #

tcImplicitQTKBndrs :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) #

tcExplicitTKBndrs :: SkolemInfo -> [LHsTyVarBndr GhcRn] -> TcM a -> TcM ([TcTyVar], a) #

kcExplicitTKBndrs :: [LHsTyVarBndr GhcRn] -> TcM a -> TcM a #

Used during the "kind-checking" pass in TcTyClsDecls only, and even then only for data-con declarations. See Note [Use SigTvs in kind-checking pass] in TcTyClsDecls

kcImplicitTKBndrs :: [Name] -> TcM a -> TcM ([TcTyVar], a) #

Bring implicitly quantified type/kind variables into scope during kind checking. Uses SigTvs, as per Note [Use SigTvs in kind-checking pass] in TcTyClsDecls.

kcLookupTcTyCon :: Name -> TcM TcTyCon #

kcTyClTyVars :: Name -> TcM a -> TcM a #

Bring tycon tyvars into scope. This is used during the "kind-checking" pass in TcTyClsDecls. (Never in getInitialKind, never in the "type-checking"/desugaring pass.) Never emits constraints, though the thing_inside might.

tcTyClTyVars :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a #

Used for the type variables of a type or class decl on the second full pass (type-checking/desugaring) in TcTyClDecls. This is *not* used in the initial-kind run, nor in the "kind-checking" pass. Accordingly, everything passed to the continuation is fully zonked.

(tcTyClTyVars T [a,b] thing_inside) where T : forall k1 k2 (a:k1 -> *) (b:k1). k2 -> * calls thing_inside with arguments [k1,k2,a,b] [k1:*, k2:*, Anon (k1 -> *), Anon k1] (k2 -> *) having also extended the type environment with bindings for k1,k2,a,b

Never emits constraints.

The LHsTyVarBndrs is always user-written, and the full, generalised kind of the tycon is available in the local env.

tcDataKindSig :: [TyConBinder] -> Kind -> TcM ([TyConBinder], Kind) #

scopeTyVars :: SkolemInfo -> [TcTyVar] -> TcM a -> TcM a #

Bring tyvars into scope, wrapping the thing_inside in an implication constraint. The implication constraint is necessary to provide SkolemInfo for the tyvars and to ensure that no unification variables made outside the scope of these tyvars (i.e. lower TcLevel) unify with the locally-scoped tyvars (i.e. higher TcLevel).

INVARIANT: The thing_inside must check only types, never terms.

Use this (not tcExtendTyVarEnv) wherever you expect a Λ or ∀ in Core. Use tcExtendTyVarEnv otherwise.

scopeTyVars2 :: SkolemInfo -> [(Name, TcTyVar)] -> TcM a -> TcM a #

Like `scopeTyVars`, but allows you to specify different scoped names than the Names stored within the tyvars.

kcLHsQTyVars #

Arguments

:: Name | of the thing being checked
-> TyConFlavour | What sort of `TyCon` is being checked
-> Bool | True = the decl being checked has a CUSK
-> LHsQTyVars GhcRn |
-> TcM Kind | The result kind
-> TcM TcTyCon | A suitably-kinded TcTyCon

Kind-check a `LHsQTyVars`. If the decl under consideration has a complete, user-supplied kind signature (CUSK), generalise the result. Used in `getInitialKind` (for tycon kinds and other kinds) and in kind-checking (but not for tycon kinds, which are checked with tcTyClDecls). See also Note [Complete user-supplied kind signatures] in HsDecls.

This function does not do telescope checking.

tcWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a #

tcHsLiftedType :: LHsType GhcRn -> TcM TcType #

tcHsOpenType :: LHsType GhcRn -> TcM TcType #

tcHsLiftedTypeNC :: LHsType GhcRn -> TcM TcType #

tcHsOpenTypeNC :: LHsType GhcRn -> TcM TcType #

tcLHsType :: LHsType GhcRn -> TcM (TcType, TcKind) #

tcLHsTypeUnsaturated :: LHsType GhcRn -> TcM (TcType, TcKind) #

tcCheckLHsType :: LHsType GhcRn -> Kind -> TcM TcType #

tcHsMbContext :: Maybe (LHsContext GhcRn) -> TcM [PredType] #

tcHsContext :: LHsContext GhcRn -> TcM [PredType] #

tcLHsPredType :: LHsType GhcRn -> TcM PredType #

tcInferApps #

Arguments

:: TcTyMode |
-> Maybe (VarEnv Kind) | Possibly, kind info (see above)
-> LHsType GhcRn | Function (for printing only)
-> TcType | Function
-> TcKind | Function kind (zonked)
-> [LHsType GhcRn] | Args
-> TcM (TcType, [TcType], TcKind) | (f args, args, result kind) Precondition: typeKind fun_ty = fun_ki Reason: we will return a type application like (fun_ty arg1 ... argn), and that type must be well-kinded See Note [The tcType invariant] Postcondition: Result kind is zonked.

Apply a type of a given kind to a list of arguments. This instantiates invisible parameters as necessary. Always consumes all the arguments, using matchExpectedFunKind as necessary. This takes an optional `VarEnv Kind` which maps kind variables to kinds. These kinds should be used to instantiate invisible kind variables; they come from an enclosing class for an associated type/data family.

solveEqualities :: TcM a -> TcM a #

Type-check a thing that emits only equality constraints, then solve those constraints. Fails outright if there is trouble. Use this if you're not going to get another crack at solving (because, e.g., you're checking a datatype declaration)

typeLevelMode :: TcTyMode #

kindLevelMode :: TcTyMode #

kindGeneralize :: TcType -> TcM [KindVar] #

checkExpectedKindX :: Maybe (VarEnv Kind) -> SDoc -> TcType -> TcKind -> TcKind -> TcM (TcType, [TcType], TcCoercionN) #

instantiateTyUntilN #

Arguments

:: Maybe (VarEnv Kind) | Possibly, instantiations for vars
-> Int |
    n
-> TcKind | its kind
-> TcM ([TcType], TcKind) | The new args, final kind

Instantiate a type to have at most `n` invisible arguments.

reportFloatingKvs :: Name -> TyConFlavour -> [TcTyVar] -> [TcTyVar] -> TcM () #

tcLHsKindSig :: UserTypeCtxt -> LHsKind GhcRn -> TcM Kind #

badKindSig :: Bool -> Kind -> SDoc #

zonkPromoteType :: TcType -> TcM TcType #

Whenever a type is about to be added to the environment, it's necessary to make sure that any free meta-tyvars in the type are promoted to the current TcLevel. (They might be at a higher level due to the level-bumping in tcExplicitTKBndrs, for example.) This function both zonks *and* promotes.

tcHsPatSigType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType) #

tcPatSig :: Bool -> LHsSigWcType GhcRn -> ExpSigmaType -> TcM (TcType, [(Name, TcTyVar)], [(Name, TcTyVar)], HsWrapper) #

funAppCtxt :: (Outputable fun, Outputable arg) => fun -> arg -> Int -> SDoc #

Make an appropriate message for an error in a function argument. Used for both expressions and types.