Type variable that might be a metavariable
Moduleghc-9.10.3GHC2021
GHC.Tc.Utils.TcMType
Monadic type operations
This module contains monadic operations over types that contain mutable type variables.
- 10 types
- 109 values
- Packageghc-9.10.3
- Exports119
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceTcMType.hs
Create a new flexi ty var with a specific name
Create a tyvar that can be a lifted or unlifted type.
Returns alpha :: TYPE kappa, where both alpha and kappa are fresh.
Note: you should use newOpenFlexiFRRTyVarTy if you also need to ensure that the representation is concrete, in the sense of Note [Concrete types] in GHC.Tc.Utils.Concrete.
Like newOpenFlexiTyVar, but ensures the type variable has a syntactically fixed RuntimeRep in the sense of Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.
See newOpenFlexiFRRTyVar.
Create a new metavariable, of the given kind, which can only be unified with a concrete type.
Invariant: the kind must be concrete, as per Note [ConcreteTv]. This is checked with an assertion.
writeMetaTyVar :: HasDebugCallStack=> TcTyVarthe type varfiable to write to
-> TcTypethe type to write into the mutable reference
-> ZonkM ()
Write into a currently-empty MetaTyVar.
Works with both type and kind variables.
writeMetaTyVarRef :: HasDebugCallStack=> TcTyVarfor debug assertions only;
-> TcRef MetaDetailsref cell must be for the same tyvar
-> TcTypethe type to write to the mutable reference
-> ZonkM ()
Write into the MetaDetails mutable references of a MetaTv.
Create a new Wanted constraint with the given CtLoc.
Emits a new Wanted. Deals with both equalities and non-equalities.
Emits a new equality constraint
Creates a new EvVar and immediately emits it as a Wanted. No equality predicates here.
Creates an EvBindsVar incapable of holding any bindings. It still tracks covar usages (see comments on ebv_tcvs in GHC.Tc.Types.Evidence), thus must be made monadically
Emit a new wanted expression hole
Put a value in a coercion hole
Is a coercion hole filled in?
Retrieve the contents of a coercion hole. Panics if the hole is unfilled
Retrieve the contents of a coercion hole, if it is filled
Check that a coercion is appropriate for filling a hole. (The hole itself is needed only for printing.) Always returns the checked coercion, but this return value is necessary so that the input coercion is forced only when the output is forced.
Create a new Implication with as many sensible defaults for its fields as possible. Note that the ic_tclvl, ic_binds, and ic_info fields do not have sensible defaults, so they are initialized with lazy thunks that will panic if forced, so one should take care to initialize these fields after creation.
This is monadic to look up the TcLclEnv, which is used to initialize ic_env, and to set the -Winaccessible-code flag. See Note [Avoid -Winaccessible-code when deriving] in GHC.Tc.TyCl.Instance.
Like newMetaTyVarX, but for concrete type variables.
An expected type to check against during type-checking. See Note [ExpType] in GHC.Tc.Utils.TcMType, where you'll also find manipulators.
Constructors
Instances1Outputable
Outputable ExpTypeDefined in ghc-9.10.3 · GHC.Tc.Utils.TcType
Make an ExpType suitable for checking.
Infer a type using a fresh ExpType See also Note [ExpType] in GHC.Tc.Utils.TcMType
Use tcInferFRR if you require the type to have a fixed runtime representation.
Like tcInfer, except it ensures that the resulting type has a syntactically fixed RuntimeRep as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.
Extract a type out of an ExpType. Otherwise, panics.
Extract a type out of an ExpType, if one exists. But one should always exist. Unless you're quite sure you know what you're doing.
Same as readExpType, but for Scaled ExpTypes
Extracts the expected type if there is one, or generates a new TauTv if there isn't.
Returns the expected type when in checking mode.
Returns the expected type when in checking mode. Panics if in inference mode.
tcCheckUsage name mult thing_inside runs thing_inside, checks that the
usage of name is a submultiplicity of mult, and removes name from the
usage environment. See also Note [Wrapper returned from tcSubMult] in
GHC.Tc.Utils.Unify, which applies to the wrapper returned from this function.
Default a type variable using the given defaulting strategy.
See Note [Type variable defaulting options] in GHC.Types.Basic.
doNotQuantifyTyVars :: CandidatesQTvs-> (TidyEnv -> ZonkM (TidyEnv, UninferrableTyVarCtx))like "the class context (D a b, E foogle)"
-> TcM ()
Gathers free variables to use as quantification candidates (in quantifyTyVars). This might output the same var in both sets, if it's used in both a type and a kind. The variables to quantify must have a TcLevel strictly greater than the ambient level. (See Wrinkle in Note [Naughty quantification candidates]) See Note [CandidatesQTvs determinism and order] See Note [Dependent type variables]
Like candidateQTyVarsOfType, but consider every free variable to be dependent. This is appropriate when generalizing a *kind*, instead of a type. (That way, -XNoPolyKinds will default the variables to Type.)
Like candidateQTyVarsOfType, but over a list of types The variables to quantify must have a TcLevel strictly greater than the ambient level. (See Wrinkle in Note [Naughty quantification candidates])
Instances3Semigroup, Monoid, Outputable
Semigroup CandidatesQTvsDefined in ghc-9.10.3 · GHC.Tc.Utils.TcMTypeMonoid CandidatesQTvsDefined in ghc-9.10.3 · GHC.Tc.Utils.TcMTypeOutputable CandidatesQTvsDefined in ghc-9.10.3 · GHC.Tc.Utils.TcMType
Check that the specified type has a fixed runtime representation.
If it isn't, throw a representation-polymorphism error appropriate for the context (as specified by the FixedRuntimeRepProvenance).
Unlike the other representation polymorphism checks, which can emit new Wanted constraints to be solved by the constraint solver, this function does not emit any constraints: it has enough information to immediately make a decision.
See (1) in Note [Representation polymorphism checking] in GHC.Tc.Utils.Concrete
Other HsSyn functions
8 declarationsA simple case alternative with a single pattern, no binds, no guards; pre-typechecking
Returns the type of the whole pattern