ghc-8.2.2: The GHC API

Safe Haskell | None
Language | Haskell2010

TcHsType

Synopsis

- kcHsSigType :: [Located Name] -> LHsSigType Name -> TcM ()
- tcClassSigType :: [Located Name] -> LHsSigType Name -> TcM Type
- tcHsSigType :: UserTypeCtxt -> LHsSigType Name -> TcM Type
- tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType Name -> TcM Type
- tcHsPartialSigType :: UserTypeCtxt -> LHsSigWcType Name -> TcM ([(Name, TcTyVar)], Maybe TcTyVar, [TcTyVar], TcThetaType, TcType)
- funsSigCtxt :: [Located Name] -> UserTypeCtxt
- addSigCtxt :: UserTypeCtxt -> LHsType Name -> TcM a -> TcM a
- pprSigCtxt :: UserTypeCtxt -> LHsType Name -> SDoc
- tcHsClsInstType :: UserTypeCtxt -> LHsSigType Name -> TcM ([TyVar], ThetaType, Class, [Type])
- tcHsDeriv :: LHsSigType Name -> TcM ([TyVar], Class, [Type], [Kind])
- tcHsVectInst :: LHsSigType Name -> TcM (Class, [Type])
- tcHsTypeApp :: LHsWcType Name -> Kind -> TcM Type
- data UserTypeCtxt
  - = FunSigCtxt Name Bool
  - | InfSigCtxt Name
  - | ExprSigCtxt
  - | TypeAppCtxt
  - | ConArgCtxt Name
  - | TySynCtxt Name
  - | PatSynCtxt Name
  - | PatSigCtxt
  - | RuleSigCtxt Name
  - | ResSigCtxt
  - | ForSigCtxt Name
  - | DefaultDeclCtxt
  - | InstDeclCtxt
  - | SpecInstCtxt
  - | ThBrackCtxt
  - | GenSigCtxt
  - | GhciCtxt
  - | ClassSCCtxt Name
  - | SigmaCtxt
  - | DataTyCtxt Name
- tcImplicitTKBndrs :: [Name] -> TcM (a, TyVarSet) -> TcM ([TcTyVar], a)
- tcImplicitTKBndrsType :: [Name] -> TcM Type -> TcM ([TcTyVar], Type)
- tcExplicitTKBndrs :: [LHsTyVarBndr Name] -> ([TyVar] -> TcM (a, TyVarSet)) -> TcM (a, TyVarSet)
- kcLookupTcTyCon :: Name -> TcM TcTyCon
- kcTyClTyVars :: Name -> TcM a -> TcM a
- tcTyClTyVars :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a
- tcDataKindSig :: Kind -> TcM ([TyConBinder], Kind)
- tcWildCardBinders :: [Name] -> ([(Name, TcTyVar)] -> TcM a) -> TcM a
- kcHsTyVarBndrs :: Name -> Bool -> Bool -> Bool -> Bool -> LHsQTyVars Name -> TcM (Kind, r) -> TcM (TcTyCon, r)
- tcHsLiftedType :: LHsType Name -> TcM TcType
- tcHsOpenType :: LHsType Name -> TcM TcType
- tcHsLiftedTypeNC :: LHsType Name -> TcM TcType
- tcHsOpenTypeNC :: LHsType Name -> TcM TcType
- tcLHsType :: LHsType Name -> TcM (TcType, TcKind)
- tcCheckLHsType :: LHsType Name -> Kind -> TcM Type
- tcHsContext :: LHsContext Name -> TcM [PredType]
- tcLHsPredType :: LHsType Name -> TcM PredType
- tcInferApps :: Outputable fun => TcTyMode -> fun -> TcType -> TcKind -> [LHsType Name] -> TcM (TcType, TcKind)
- tcInferArgs :: Outputable fun => fun -> [TyConBinder] -> Maybe (VarEnv Kind) -> [LHsType Name] -> TcM (TCvSubst, [TyBinder], [TcType], [LHsType Name], Int)
- solveEqualities :: TcM a -> TcM a
- kindGeneralize :: TcType -> TcM [KindVar]
- tcLHsKindSig :: LHsKind Name -> TcM Kind
- tcHsPatSigType :: UserTypeCtxt -> LHsSigWcType Name -> TcM ([(Name, TcTyVar)], [(Name, TcTyVar)], TcType)
- tcPatSig :: Bool -> LHsSigWcType Name -> ExpSigmaType -> TcM (TcType, [(Name, TcTyVar)], [(Name, TcTyVar)], HsWrapper)
- funAppCtxt :: (Outputable fun, Outputable arg) => fun -> arg -> Int -> SDoc

# Documentation

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

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

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

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

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

funsSigCtxt :: [Located Name] -> UserTypeCtxt #

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

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

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

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

tcHsVectInst :: LHsSigType Name -> TcM (Class, [Type]) #

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

Type-check a visible type application

data UserTypeCtxt #

Constructors

FunSigCtxt Name Bool |
InfSigCtxt Name |
ExprSigCtxt |
TypeAppCtxt |
ConArgCtxt Name |
TySynCtxt Name |
PatSynCtxt Name |
PatSigCtxt |
RuleSigCtxt Name |
ResSigCtxt |
ForSigCtxt Name |
DefaultDeclCtxt |
InstDeclCtxt |
SpecInstCtxt |
ThBrackCtxt |
GenSigCtxt |
GhciCtxt |
ClassSCCtxt Name |
SigmaCtxt |
DataTyCtxt Name |

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

tcImplicitTKBndrsType :: [Name] -> TcM Type -> TcM ([TcTyVar], Type) #

Convenient specialization

tcExplicitTKBndrs #

Arguments

:: [LHsTyVarBndr Name] |
-> ([TyVar] -> TcM (a, TyVarSet)) | Thing inside returns the set of variables bound in the scope. See Note [Scope-check inferred kinds]
-> TcM (a, TyVarSet) | returns augmented bound vars No cloning: returned TyVars have the same Name as the incoming LHsTyVarBndrs

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 :: Kind -> TcM ([TyConBinder], Kind) #

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

kcHsTyVarBndrs #

Arguments

:: Name | of the thing being checked
-> Bool | True = the TyCon being kind-checked can be unsaturated
-> Bool | True = the decl being checked has a CUSK
-> Bool | True = the decl is an open type/data family
-> Bool | True = all the hsq_implicit are *kind* vars (will give these kind * if -XNoTypeInType)
-> LHsQTyVars Name |
-> TcM (Kind, r) | The result kind, possibly with other info
-> TcM (TcTyCon, r) | 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.

tcHsLiftedType :: LHsType Name -> TcM TcType #

tcHsOpenType :: LHsType Name -> TcM TcType #

tcHsLiftedTypeNC :: LHsType Name -> TcM TcType #

tcHsOpenTypeNC :: LHsType Name -> TcM TcType #

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

tcCheckLHsType :: LHsType Name -> Kind -> TcM Type #

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

tcLHsPredType :: LHsType Name -> TcM PredType #

tcInferApps #

Arguments

:: Outputable fun |
=> TcTyMode |
-> fun | Function (for printing only)
-> TcType | Function (could be knot-tied)
-> TcKind | Function kind (zonked)
-> [LHsType Name] | Args
-> TcM (TcType, TcKind) | (f args, result kind)

Applies a type to a list of arguments. Always consumes all the arguments, using `matchExpectedFunKind` as necessary. If you wish to apply a type to a list of HsTypes, this is your function. Used for type-checking types only.

tcInferArgs #

Arguments

:: Outputable fun |
=> fun | the function
-> [TyConBinder] | function kind's binders
-> Maybe (VarEnv Kind) | possibly, kind info (see above)
-> [LHsType Name] | args
-> TcM (TCvSubst, [TyBinder], [TcType], [LHsType Name], Int) | (instantiating subst, un-insted leftover binders, typechecked args, untypechecked args, n)

Apply a type of a given kind to a list of arguments. This instantiates invisible parameters as necessary. However, it does *not* necessarily apply all the arguments, if the kind runs out of binders. Never calls `matchExpectedFunKind`; when the kind runs out of binders, this stops processing. 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. This version will instantiate all invisible arguments left over after the visible ones. Used only when typechecking type/data family patterns (where we need to instantiate all remaining invisible parameters; for example, consider `type family F :: k where F = Int; F = Maybe`. We need to instantiate the `k`.)

solveEqualities :: TcM a -> TcM a #

Type-check a thing that emits only equality constraints, then solve those constraints. Fails outright if there is trouble.

kindGeneralize :: TcType -> TcM [KindVar] #

tcLHsKindSig :: LHsKind Name -> TcM Kind #

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

tcPatSig :: Bool -> LHsSigWcType Name -> 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.