Moduleghc-10.0.0.20260917GHC2024
GHC.Plugins
This module is not used by GHC itself. Rather, it exports all of the functions and types you are likely to need when writing a plugin for GHC. So authors of plugins can probably get away simply with saying "import GHC.Plugins".
Particularly interesting modules for plugin writers include GHC.Core and GHC.Core.Opt.Monad.
- 79 types
- 4 classes
- 1005 values
- Packageghc-10.0.0.20260917
- Exports1092
- LanguageGHC2024
- LicenceBSD-3-Clause
- SourcePlugins.hs
module GHC.Driver.Plugins
module GHC.Types.Name.Reader
Alter an OccEnv, adding or removing an element at the given key.
Delete one element from an OccEnv.
Delete multiple elements from an OccEnv.
Compute whether there is a value keyed by the given OccName.
The empty OccEnv.
Add a single element to an OccEnv.
extendOccEnv_Acc Filter out all elements in an OccEnv using a predicate.
Force an OccEnv with the provided function.
Test if the OccName is a data constructor that starts with
a symbol (e.g. :, or [])
Test for definitions internally generated by GHC. This predicate is used to suppress printing of internal definitions in some debug prints
Test if the OccName is that for any operator (whether it is a data constructor or variable or whatever)
Is this a term variable or field name namespace?
Is an OccName one of a Typeable TyCon or Module binding?
This is needed as these bindings are renamed differently.
See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable.
Value OccNamess are those that are either in
the variable, field name or data constructor namespaces
Look up all the record fields that match with the given FastString in an OccEnv.
Look an element up in an OccEnv.
Lookup an element in an OccEnv, looking in the record field namespace for a variable.
mapMaybe for b OccEnv.
Derive a name for the representation type constructor of a
data/newtype instance.
mkSuperDictSelOcc Fold over an OccEnv. Non-deterministic, unless the folding function
is commutative (i.e. a1 for all f ( a2 f b ) == a2 f ( a1 f b )a1, a2, b).
Obtain the elements of an OccEnv.
The resulting order is non-deterministic.
Mangle field names to avoid duplicate symbols.
See Note [Mangling OccNames].
Wrap parens around an operator
Union of two OccEnvs, right-biased.
Union of two OccEnvs with a combining function.
Haskell 98 encourages compilers to suppress warnings about unused
names in a pattern if they start with _: this implements that test
Map over an OccEnv strictly.
A singleton OccEnv.
A non-deterministic set of FastStrings. See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM for explanation why it's not deterministic and why it matters. Use DFastStringEnv if the set eventually gets converted into a list or folded over in a way where the order changes the generated code.
Other names in the compiler add additional information to an OccName. This class provides a consistent way to access the underlying OccName.
Instances12HasOccName, …
HasOccName IfaceClassOpDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxHasOccName IfaceConDeclDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxHasOccName IfaceDeclDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxHasOccName HoleFitCandidateDefined in ghc-10.0.0.20260917 · GHC.Tc.Errors.Hole.FitTypesHasOccName TcBinderDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.BasicTypesHasOccName FieldLabelDefined in ghc-10.0.0.20260917 · GHC.Types.FieldLabelHasOccName NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameHasOccName OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceHasOccName RdrNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.ReaderHasOccName VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarHasOccName (GlobalRdrEltX info)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.Reader(HasOccName (IdP (GhcPass p)), OutputableBndrId p) => HasOccName (IEWrappedName (GhcPass p))Defined in ghc-10.0.0.20260917 · GHC.Hs.ImpExp · orphan
Instances5Eq, Ord, NFData, Uniquable, Binary
Eq NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOrd NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceNFData NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceUniquable NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceBinary NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.Occurrence
A map keyed on OccName. See Note [OccEnv].
Instances3Functor, NFData, Outputable
Functor OccEnvDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceNFData a => NFData (OccEnv a)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOutputable a => Outputable (OccEnv a)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.Occurrence
Occurrence Name
In this context that means: "classified (i.e. as a type name, value name, etc) but not qualified and not yet resolved"
Instances8Eq, Data, Ord, NFData, Outputable, Binary, …
Eq OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceData OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOrd OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceNFData OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOutputable OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceBinary OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOutputableBndr OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceHasOccName OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.Occurrence
Will the Name come from a dynamically linked package?
This matches a datacon as well as its worker and promoted tycon.
Make the Name into an internal name, regardless of what it was to begin with
Create a name which definitely originates in the given module
Make a name for a foreign call
Create a name brought into being by the compiler
Create a name which is actually defined by the compiler itself
Returns True if the name is external or from the interactive package
See documentation of nameIsLocalOrFrom function
Returns True if the Name comes from some other package: neither this package nor the interactive package.
Returns True if the name is
(a) Internal
(b) External but from the specified module
(c) External but from the interactive package
The key idea is that False means: the entity is defined in some other module you can find the details (type, fixity, instances) in some interface file those details will be stored in the EPT or HPT
True means: the entity is defined in this module or earlier in the GHCi session you can find details (type, fixity, instances) in the TcGblEnv or TcLclEnv
The isInteractiveModule part is because successive interactions of a GHCi session
each give rise to a fresh module (Ghci1, Ghci2, etc), but they all come
from the magic interactive package; and all the details are kept in the
TcLclEnv, TcGblEnv, NOT in the HPT or EPT.
See Note [The interactive package] in GHC.Runtime.Context
Get a string representation of a Name that's unique and stable across recompilations. Used for deterministic generation of binds for derived instances. eg. "$aeson_70dylHtv1FFGeai1IoxcQr$Data.Aeson.Types.Internal$String"
Print fully qualified name (with unit-id and module, but no unique)
Print fully qualified name (with unit-id and module, with the unique)
Print the string of Name unqualifiedly directly.
Print a ticky ticky styled name
Module argument is the module to use for internal and system names. When printing the name in a ticky profile, the module name is included even for local things. However, ticky uses the format "x (M)" rather than "M.x". Hence, this function provides a separation from normal styling.
Compare Names lexicographically This only works for Names that originate in the source code or have been tidied.
Alter an OccEnv, adding or removing an element at the given key.
Delete one element from an OccEnv.
Delete multiple elements from an OccEnv.
Compute whether there is a value keyed by the given OccName.
The empty OccEnv.
Add a single element to an OccEnv.
extendOccEnv_Acc Filter out all elements in an OccEnv using a predicate.
Force an OccEnv with the provided function.
Test if the OccName is a data constructor that starts with
a symbol (e.g. :, or [])
Test for definitions internally generated by GHC. This predicate is used to suppress printing of internal definitions in some debug prints
Test if the OccName is that for any operator (whether it is a data constructor or variable or whatever)
Is this a term variable or field name namespace?
Is an OccName one of a Typeable TyCon or Module binding?
This is needed as these bindings are renamed differently.
See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable.
Value OccNamess are those that are either in
the variable, field name or data constructor namespaces
Look up all the record fields that match with the given FastString in an OccEnv.
Look an element up in an OccEnv.
Lookup an element in an OccEnv, looking in the record field namespace for a variable.
mapMaybe for b OccEnv.
Derive a name for the representation type constructor of a
data/newtype instance.
mkSuperDictSelOcc Fold over an OccEnv. Non-deterministic, unless the folding function
is commutative (i.e. a1 for all f ( a2 f b ) == a2 f ( a1 f b )a1, a2, b).
Obtain the elements of an OccEnv.
The resulting order is non-deterministic.
Mangle field names to avoid duplicate symbols.
See Note [Mangling OccNames].
Wrap parens around an operator
Union of two OccEnvs, right-biased.
Union of two OccEnvs with a combining function.
Haskell 98 encourages compilers to suppress warnings about unused
names in a pattern if they start with _: this implements that test
Map over an OccEnv strictly.
A singleton OccEnv.
A non-deterministic set of FastStrings. See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM for explanation why it's not deterministic and why it matters. Use DFastStringEnv if the set eventually gets converted into a list or folded over in a way where the order changes the generated code.
BuiltInSyntax is for things like (:), [] and tuples,
which have special syntactic forms. They aren't in scope
as such.
A unique, unambiguous name for something, containing information about where that thing originated.
Instances16Eq, Data, Ord, NFData, NamedThing, Uniquable, …
Eq NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameData NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameOrd NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameCaution: This instance is implemented via nonDetCmpUnique, which means that the ordering is not stable across deserialization or rebuilds.
See nonDetCmpUnique for further information, and #15240 for a bug caused by improper use of this instance.
NFData NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameNamedThing NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameOutputable NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameUniquable NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameBinary NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameAssumes that the Name is a non-binding one. See putIfaceTopBndr and getIfaceTopBndr for serializing binding Names. See
UserDatafor the rationale for this distinction.OutputableBndr NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameHasOccName NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameModifyState NameDefined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstOutputable (WithUserRdr Name)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.ReaderOutputableBndr (WithUserRdr Name)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.ReaderToHie (Context (Located Name))Defined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstToHie (Context (Located (WithUserRdr Name)))Defined in ghc-10.0.0.20260917 · GHC.Iface.Ext.Asttype Anno Name = SrcSpanAnnNDefined in ghc-10.0.0.20260917 · GHC.Hs.Extension · orphan
A class allowing convenient access to the Name of various datatypes
Methods
getOccName :: a -> OccNamegetName :: a -> Name
Instances21NamedThing, …
NamedThing ClassDefined in ghc-10.0.0.20260917 · GHC.Core.ClassNamedThing ConLikeDefined in ghc-10.0.0.20260917 · GHC.Core.ConLikeNamedThing DataConDefined in ghc-10.0.0.20260917 · GHC.Core.DataConNamedThing FamInstDefined in ghc-10.0.0.20260917 · GHC.Core.FamInstEnvNamedThing ClsInstDefined in ghc-10.0.0.20260917 · GHC.Core.InstEnvNamedThing PatSynDefined in ghc-10.0.0.20260917 · GHC.Core.PatSynNamedThing TyConDefined in ghc-10.0.0.20260917 · GHC.Core.TyConNamedThing IfaceClassOpDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxNamedThing IfaceConDeclDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxNamedThing IfaceDeclDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxNamedThing HoleFitCandidateDefined in ghc-10.0.0.20260917 · GHC.Tc.Errors.Hole.FitTypesNamedThing InvalidFamInstQTvDefined in ghc-10.0.0.20260917 · GHC.Tc.Errors.TypesNamedThing ConLikeNameDefined in ghc-10.0.0.20260917 · GHC.Types.GREInfoNamedThing NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameNamedThing TyThingDefined in ghc-10.0.0.20260917 · GHC.Types.TyThingNamedThing VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarNamedThing (CoAxiom br)Defined in ghc-10.0.0.20260917 · GHC.Core.Coercion.AxiomNamedThing a => NamedThing (WithUserRdr a)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.ReaderNamedThing e => NamedThing (Located e)Defined in ghc-10.0.0.20260917 · GHC.Types.NameNamedThing (Located a) => NamedThing (LocatedAn an a)Defined in ghc-10.0.0.20260917 · GHC.Parser.AnnotationNamedThing tv => NamedThing (VarBndr tv flag)Defined in ghc-10.0.0.20260917 · GHC.Types.Var
Other names in the compiler add additional information to an OccName. This class provides a consistent way to access the underlying OccName.
Instances12HasOccName, …
HasOccName IfaceClassOpDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxHasOccName IfaceConDeclDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxHasOccName IfaceDeclDefined in ghc-10.0.0.20260917 · GHC.Iface.SyntaxHasOccName HoleFitCandidateDefined in ghc-10.0.0.20260917 · GHC.Tc.Errors.Hole.FitTypesHasOccName TcBinderDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.BasicTypesHasOccName FieldLabelDefined in ghc-10.0.0.20260917 · GHC.Types.FieldLabelHasOccName NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameHasOccName OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceHasOccName RdrNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.ReaderHasOccName VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarHasOccName (GlobalRdrEltX info)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.Reader(HasOccName (IdP (GhcPass p)), OutputableBndrId p) => HasOccName (IEWrappedName (GhcPass p))Defined in ghc-10.0.0.20260917 · GHC.Hs.ImpExp · orphan
Instances5Eq, Ord, NFData, Uniquable, Binary
Eq NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOrd NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceNFData NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceUniquable NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceBinary NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.Occurrence
A map keyed on OccName. See Note [OccEnv].
Instances3Functor, NFData, Outputable
Functor OccEnvDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceNFData a => NFData (OccEnv a)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOutputable a => Outputable (OccEnv a)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.Occurrence
Occurrence Name
In this context that means: "classified (i.e. as a type name, value name, etc) but not qualified and not yet resolved"
Instances8Eq, Data, Ord, NFData, Outputable, Binary, …
Eq OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceData OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOrd OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceNFData OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOutputable OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceBinary OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceOutputableBndr OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceHasOccName OccNameDefined in ghc-10.0.0.20260917 · GHC.Types.Name.Occurrence
module GHC.Types.Var
Returns an unfolding only if (a) not a strong loop breaker and (b) always active
Returns True of an Id which may not have a
binding, even though it is defined in this module.
Get from either the worker or the wrapper Id to the DataCon. Currently used only in the desugarer.
INVARIANT: idDataCon (dataConWrapId d) = d: remember, dataConWrapId can return either the wrapper or the worker
Accesses the Id's dmdSigInfo.
This function counts all arguments post-unarisation, which includes arguments with no runtime representation -- see Note [Unarisation and arity]
Doesn't return strictness marks
Returns the Ids unfolding, but does not expose the unfolding of a strong loop breaker. See unfoldingInfo.
If you really want the unfolding of a strong loopbreaker, call realIdUnfolding.
Returns true if an application to n args diverges or throws an exception See Note [Dead ends] in GHC.Types.Demand.
isImplicitId tells whether an Ids info is implied by other declarations, so we don't need to put its signature in an interface file, even if it's mentioned in some other interface unfolding.
isStrictId says whether either (a) the Id has a strict demand placed on it or (b) definitely has a "strict type", such that it can always be evaluated strictly (i.e an unlifted type) We need to check (b) as well as (a), because when the demand for the given id hasn't been computed yet but id has a strict type, we still want `isStrictId id` to be True. Returns False if the type is levity polymorphic; False is always safe.
An Id for which we might require all callers to pass strict arguments properly tagged + evaluated.
See Note [CBV Function Ids: overview]
Create a local Id that is marked as exported. This prevents things attached to it from being removed as dead code. See Note [Exported LocalIds]
For an explanation of global vs. local Ids, see GHC.Types.Var.Var#globalvslocal
Make a local CoVar
For an explanation of global vs. local Ids, see GHC.Types.Var#globalvslocal
Like mkLocalId, but checks the type to see if it should make a covar
Like mkSysLocal, but checks to see if we have a covar type
Create a template local: a family of system local Ids in bijection with Ints, typically used in unfoldings
Create a template local for a series of types
Create a template local for a series of type, but start from a specified template local
Like mkUserLocal, but checks if we have a coercion type
Make a global Id without any extra information at all
Workers get local names. CoreTidy will externalise these if necessary
Expose the unfolding if there is one, including for loop breakers
Remove any CBV-candidate info from a given Id. See Note [CBV Function Ids: overview] in GHC.Types.Id.Info
Like scaleIdBy, but skips non-Ids. Useful for scaling a mixed list of ids and tyvars.
Make this Id into a candidate for CBV treatment, if possible. See Note [CBV Function Ids: overview] in GHC.Types.Id.Info
If all marks are NotMarkedStrict we just set nothing.
Returns an unfolding only if (a) not a strong loop breaker and (b) active in according to is_active
Similar to trimUnfolding, but also removes evaldness info.
If it's a local, make it global
isExportedIdVar means "don't throw this away"
Is this a value-level (i.e., computationally relevant) Identifier?
Satisfies isId = not . isTyVar.
Identifier
Instances15Data, Ord, NamedThing, Outputable, Uniquable, HasOccName, …
Eq VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarData VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOrd VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarNamedThing VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputable VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarUniquable VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputableBndr VarDefined in ghc-10.0.0.20260917 · GHC.Core.Ppr · orphanHasOccName VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarModifyState IdDefined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstEq (DeBruijn CoreAlt)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.Expr · orphanEq (DeBruijn CoreExpr)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.Expr · orphanEq (DeBruijn Var)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.TypeToHie (Context (Located Var))Defined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstOutputableBndr (Id, TagSig)Defined in ghc-10.0.0.20260917 · GHC.Stg.EnforceEpt.TagSigtype Anno Id = SrcSpanAnnNDefined in ghc-10.0.0.20260917 · GHC.Hs.Extension · orphan
Instances4Eq, NFData, Outputable, Binary
Eq JoinPointHoodDefined in ghc-10.0.0.20260917 · GHC.Utils.OutputableNFData JoinPointHoodDefined in ghc-10.0.0.20260917 · GHC.Utils.OutputableOutputable JoinPointHoodDefined in ghc-10.0.0.20260917 · GHC.Utils.OutputableBinary JoinPointHoodDefined in ghc-10.0.0.20260917 · GHC.Utils.Binary
module GHC.Types.Id.Info
module GHC.Types.PkgQual
module GHC.Core.Opt.Monad
module GHC.Core.Opt.Pipeline.Types
module GHC.Core.Opt.Stats
module GHC.Core
module GHC.Types.Literal
module GHC.Core.DataCon
module GHC.Core.Utils
module GHC.Core.Make
module GHC.Core.FVs
Applies cloneIdBndr to a number of Ids, accumulating a final substitution from left to right Discards non-Stable unfoldings
Clone a mutually recursive group of Ids
Clone a mutually recursive group of Ids
De-shadowing the program is sometimes a useful pre-pass. It can be done simply by running over the bindings with an empty substitution, because substitution returns a result that has no-shadowing guaranteed.
(Actually, within a single type there might still be shadowing, because
substTy is a no-op for the empty substitution, but that's probably OK.)
- Aug 09
This function is not used in GHC at the moment, but seems so short and simple that I'm going to leave it here
Adds multiple Id substitutions to the Subst: see also extendIdSubst
Add a substitution appropriate to the thing being substituted (whether an expression, type, or coercion). See also extendIdSubst, extendTvSubst, extendCvSubst
Add a substitution as appropriate to each of the terms being substituted (whether expressions, types, or coercions). See also extendSubst.
Simultaneously substitute for a bunch of variables No left-right shadowing ie the substitution for (x y. e) a1 a2 so neither x nor y scope over a1 a2
substExpr applies a substitution to an entire CoreExpr. Remember, you may only apply the substitution once: See Note [Substitutions apply only once] in GHC.Core.TyCo.Subst
Do *not* attempt to short-cut in the case of an empty substitution! See Note [Extending the IdSubstEnv]
Substitute in a mutually recursive group of Ids
Drop free vars from the breakpoint if they have a non-variable substitution.
Substitutes for the Ids within an unfolding NB: substUnfolding discards any unfolding without without a Stable source. This is usually what we want, but it may be a bit unexpected
Substitutes for the Ids within an unfolding NB: substUnfolding discards any unfolding without without a Stable source. This is usually what we want, but it may be a bit unexpected
Add the Var to the in-scope set
Add the Vars to the in-scope set: see also extendInScope
Adds multiple TyVar substitutions to the Subst: see also extendTvSubst
Substitute within a Coercion The substitution has to satisfy the invariants described in Note [The substitution invariant].
Find the in-scope set: see Note [The substitution invariant]
Substitute within a Type disabling the sanity checks. The problems that the sanity checks in substTy catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTyUnchecked to substTy and remove this function. Please don't use in new code.
Remove all substitutions that might have been built up while preserving the in-scope set originally called zapSubstEnv
A substitution of Exprs for non-coercion Ids
Type & coercion & id substitution
The Subst data type defined in this module contains substitution
for tyvar, covar and id. However, operations on IdSubstEnv (mapping
from Id to CoreExpr) that require the definition of the Expr
data type are defined in GHC.Core.Subst to avoid circular module
dependency.
Constructors
Instances1Outputable
Outputable SubstDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Subst
A set of variables that are in scope at some point.
Note that this is a superset of the variables that are currently in scope. See Note [The InScopeSet invariant].
"Secrets of the Glasgow Haskell Compiler inliner" Section 3.2 provides the motivation for this abstraction.
Instances1Outputable
Outputable InScopeSetDefined in ghc-10.0.0.20260917 · GHC.Types.Var.Env
module GHC.Core.Rules
module GHC.Types.Annotations
module GHC.Driver.Session
module GHC.Driver.Ppr
module GHC.Unit.State
module GHC.Unit.Module
module GHC.Unit.Home
Add the kind variables free in the kinds of the tyvars in the given set. Returns a deterministic set.
tyCoVarsOfTypeDSet that returns deep free variables of a type in a deterministic set. For explanation of why using VarSet is not deterministic see Note [Deterministic FV] in GHC.Types.Var.FV.
All type constructors occurring in the type; looking through type synonyms, but not newtypes. When it finds a Class, it returns the class TyCon.
Like mkTyCoForAllTy, but does not check the occurrence of the binder
See Note [Unused coercion variable in ForAllTy]
Wraps foralls over the type using the provided TyCoVars from left to right
Wraps foralls over the type using the provided InvisTVBinders from left to right
Make nested arrow types | Special, common, case: Arrow type with mult Many
A view function that looks through nothing.
Composes two substitutions, applying the second one provided first, like in function composition. This function leaves IdSubstEnv untouched because IdSubstEnv is not used during substitution for types.
Add the Var to the in-scope set
Add the Vars to the in-scope set: see also extendInScope
Add the Vars to the in-scope set: see also extendInScope
Returns the deep free variables of the types in the range of a substitution as a non-deterministic set.
Checks whether the tyvar and covar environments are empty. This function should be used over isEmptySubst when substituting for types, because types currently do not contain expressions; we can safely disregard the expression environment when deciding whether to skip a substitution. Using isEmptyTCvSubst gives us a non-trivial performance boost (up to 70% less allocation for T18223)
Generates the in-scope set for the TCvSubst from the types in the
incoming environment. No CoVars, please! The InScopeSet is just a thunk
so with a bit of luck it'll never be evaluated
Substitute within a Coercion The substitution has to satisfy the invariants described in Note [The substitution invariant].
Coercion substitution, see zipTvSubst
Find the in-scope set: see Note [The substitution invariant]
Substitute within a ThetaType The substitution has to satisfy the invariants described in Note [The substitution invariant].
Substitute within a ThetaType disabling the sanity checks. The problems that the sanity checks in substTys catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substThetaUnchecked to substTheta and remove this function. Please don't use in new code.
Substitute within a Type after adding the free variables of the type to the in-scope set. This is useful for the case when the free variables aren't already in the in-scope set or easily available. See also Note [The substitution invariant].
Substitute within a Type disabling the sanity checks. The problems that the sanity checks in substTy catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTyUnchecked to substTy and remove this function. Please don't use in new code.
Type substitution, see zipTvSubst
Type substitution, see zipTvSubst. Disables sanity checks. The problems that the sanity checks in substTy catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTyUnchecked to substTy and remove this function. Please don't use in new code.
Substitute within several Types The substitution has to satisfy the invariants described in Note [The substitution invariant].
Substitute within several Types disabling the sanity checks. The problems that the sanity checks in substTys catch are described in Note [The substitution invariant]. The goal of #11371 is to migrate all the calls of substTysUnchecked to substTys and remove this function. Please don't use in new code.
Type substitution, see zipTvSubst
Remove all substitutions that might have been built up while preserving the in-scope set originally called zapSubstEnv
Generates the in-scope set for the Subst from the types in the incoming environment. No CoVars or Ids, please!
The InScopeSet is just a thunk so with a bit of luck it'll never be evaluated
(mkTyConTy tc) returns (TyConApp tc []) but arranges to share that TyConApp among all calls See Note [Sharing nullary TyConApps] So it's just an alias for tyConNullaryTy!
Given a Type and a list of argument types to which the Type is applied, determine each argument's visibility (Inferred, Specified, or Required).
Most of the time, the arguments will be Required, but not always. Consider
f :: forall a. a -> Type. In f Type Bool, the first argument (Type) is
Specified and the second argument (Bool) is Required. It is precisely
this sort of higher-rank situation in which appTyForAllTyFlags comes in handy,
since f Type Bool would be represented in Core using AppTys.
(See also #15792).
See GHC.Types.Var Note [FunTyFlag]
Get the type on the LHS of a coercion induced by a type/data family instance.
Iterates coreView until there is no more to synonym to expand. NB: coreFullView is non-recursive and can be inlined; core_full_view is the recursive one See Note [Inlining coreView].
This function strips off the top layer only of a type synonym application (if any) its underlying representation type. Returns Nothing if there is nothing to look through.
This function does not look through type family applications.
By being non-recursive and inlined, this case analysis gets efficiently joined onto the case analysis that the caller is already doing
Drops all ForAllTys
Drops prefix of RuntimeRep constructors in TyConApps. Useful for e.g. dropping 'LiftedRep arguments of unboxed tuple TyCon applications:
dropRuntimeRepArgs [ 'LiftedRep, 'IntRep , String, Int# ] == [String, Int#]
expandSynTyConApp_maybe tc tys expands the RHS of type synonym tc
instantiated at arguments tys, or returns Nothing if tc is not a
synonym.
Expand out all type synonyms. Actually, it'd suffice to expand out just the ones that discard type variables (e.g. type Funny a = Int) But we don't know which those are currently, so we just expand all.
expandTypeSynonyms only expands out type synonyms mentioned in the type, not in the kinds of any TyCon or TyVar mentioned in the type.
Keep this synchronized with synonymTyConsOfType
Extract the function argument type and panic if that is not possible
Just like piResultTys but for a single argument Try not to iterate piResultTy, because it's inefficient to substitute one variable at a time; instead use 'piResultTys"
Extract the function result type and panic if that is not possible
Given the components of a FunTy figure out the corresponding TyConApp.
If the type is a tyvar, possibly under a cast, returns it, along with the coercion. Thus, the co is :: kind tv ~N kind ty
Extract the Levity of a type. For example, getLevity Int = Lifted,
or getLevity (Array# Int) = Unlifted.
Panics if this is not possible. Does not look through type family applications.
Extracts a list of run-time arguments from a function type, looking through newtypes to the right of arrows.
Examples:
newtype Identity a = I a
getRuntimeArgTys (Int -> Bool -> Double) == [(Int, FTF_T_T), (Bool, FTF_T_T)]
getRuntimeArgTys (Identity Int -> Bool -> Double) == [(Identity Int, FTF_T_T), (Bool, FTF_T_T)]
getRuntimeArgTys (Int -> Identity (Bool -> Identity Double)) == [(Int, FTF_T_T), (Bool, FTF_T_T)]
getRuntimeArgTys (forall a. Show a => Identity a -> a -> Int -> Bool)
== [(Show a, FTF_C_T), (Identity a, FTF_T_T),(a, FTF_T_T),(Int, FTF_T_T)]
Note that, in the last case, the returned types might mention an out-of-scope type variable. This function is used only when we really care about the kinds of the returned types, so this is OK.
*Warning**: this function can return an infinite list. For example:
newtype N a = MkN (a -> N a)
getRuntimeArgTys (N a) == repeat (a, FTF_T_T)
Extract the RuntimeRep classifier of a type. For instance,
getRuntimeRep_maybe Int = LiftedRep. Panics if this is not possible.
Attempts to obtain the type variable underlying a Type, and panics with the given message if this is not a type variable type. See also getTyVar_maybe
Attempts to obtain the type variable underlying a Type
See Type#type_classification for what an algebraic type is.
Should only be applied to types, as opposed to e.g. partially
saturated type constructors
See isBoxedRuntimeRep_maybe.
See Type#type_classification for what a boxed type is.
Panics on representation-polymorphic types; See mightBeUnliftedType for
a more approximate predicate that behaves better in the presence of
representation polymorphism.
Is this a char literal? We also look through type synonyms.
Tests whether the given type is concrete, i.e. it whether it consists only of concrete type constructors, concrete type variables, and applications.
See Note [Concrete types] in GHC.Tc.Utils.Concrete.
Check whether a type is a data family type
Checks that a kind of the form Type, Constraint
or 'TYPE r is concrete. See isConcreteType.
Precondition: The type has kind `TYPE blah` or `CONSTRAINT blah`
Checks whether this is a proper forall (with a named binder)
Like isForAllTy, but returns True only if it is a covar binder
Like isForAllTy, but returns True only if it is an inferred tyvar binder
Like isForAllTy, but returns True only if it is a tyvar binder
Is this type a function type (e.g. X -> Y or X => Y),
after expanding type synonyms?
Note:
Does not look through newtypes, so isFunTy is False for
IO (), despite the latter being operationally a function (after expanding newtypes).Does not reduce type family applications, so isFunTy is False for
Id (Int -> Bool)(where Id is the identity type family).Does not consider
ForAllTyto be a function type (even when the argument is a required argument), nor does it look through foralls. Hence both isFunTy is False for bothforall b. Show b => b -> band forforall a -> Int.
See also mightBeFunTy, when you want to know whether something could
be a function (taking a value argument) at runtime.
Is this the type Levity?
Is a tyvar of type Levity?
Check whether a type of kind RuntimeRep is lifted.
True of
LiftedRep :: RuntimeRepFalse of type variables, type family applications, and of other reps such as
IntRep :: RuntimeRep.
Returns True if the argument is (lifted) Type or Constraint See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim
Is this a type literal (symbol, numeric, or char)?
Is this the type Multiplicity?
Is a tyvar of type Multiplicity?
Is this a numeric literal. We also look through type synonyms.
Is this type a FunTy or a ForAllTy, after expanding type synonyms?
Does not look through newtypes nor reduce type family applications.
Returns true of types that are opaque to Haskell.
Is this a type of kind RuntimeRep? (e.g. LiftedRep)
Is this the type RuntimeRep?
Is a tyvar of type RuntimeRep?
Is this a symbol literal. We also look through type synonyms.
Computes whether an argument (or let right hand side) should be computed strictly or lazily, based only on its type. Currently, it's just isUnliftedType. Panics on representation-polymorphic types.
Does this classify a type allowed to have values? Responds True to things like *, TYPE Lifted, TYPE IntRep, TYPE v, Constraint.
True of a kind `TYPE _` or `CONSTRAINT _`
True = a term of this type cannot be bottom This identifies the types described by Note [NON-BOTTOM-DICTS invariant] in GHC.Core NB: unlifted types are not terminating types! e.g. you can write a term (loop 1)::Int# that diverges.
Is this kind equivalent to TYPE r (for some unknown r)?
This considers Constraint to be distinct from *.
Check whether a type of kind RuntimeRep is unlifted.
True of definitely unlifted RuntimeReps such as
UnliftedRep, IntRep, FloatRep, ...False of
LiftedRep,False for type variables and type family applications.
Is the given type definitely unlifted?
See Type#type_classification for what an unlifted type is.
Panics on representation-polymorphic types; See mightBeUnliftedType for a more approximate predicate that behaves better in the presence of representation polymorphism.
Returns True if the kind classifies unlifted types (like Int#) and False
otherwise. Note that this returns False for representation-polymorphic
kinds, which may be specialized to a kind that classifies unlifted types.
Determine whether a type could be the type of a join point of given total
arity, according to the polymorphism rule. A join point cannot be polymorphic
in its return type, since given
join j a b x y z = e1 in e2,
the types of e1 and e2 must be the same, and a and b are not in scope for e2.
(See Note [The polymorphism rule of join points] in GHC.Core.) Returns False
also if the type simply doesn't have enough arguments.
Note that we need to know how many arguments (type *and* value) the putative join point takes; for instance, if j :: forall a. a -> Int then j could be a binary join point returning an Int, but it could *not* be a unary join point returning a -> Int.
TODO: See Note [Excess polymorphism and join points]
Extract the RuntimeRep classifier of a type from its kind. For example,
kindRep * = LiftedRep; Panics if this is not possible.
Treats * and Constraint as the same
Given a kind (TYPE rr) or (CONSTRAINT rr), extract its RuntimeRep classifier rr.
For example, kindRep_maybe * = Just LiftedRep
Returns Nothing if the kind is not of form (TYPE rr)
levityType_maybe takes a Type of kind Levity, and returns its levity May not be possible for a type variable or type family application
Scale a payload by One
Applies a type to another, as in e.g. k a
Just like mkTYPEapp
Just like mkTYPEapp_maybe
Make a CastTy. The Coercion must be nominal. Checks the
Coercion for reflexivity, dropping it if it's reflexive.
See Note [Respecting definitional equality] in GHC.Core.TyCo.Rep
Given a family instance TyCon and its arg types, return the corresponding family type. E.g:
data family T a
data instance T (Maybe b) = MkT bWhere the instance tycon is :RTL, so:
mkFamilyTyConApp :RTL Int = T (Maybe Int)This one works out the FunTyFlag from the argument type See GHC.Types.Var Note [FunTyFlag]
Like mkTyCoInvForAllTy, but tv should be a tyvar
Like mkTyCoInvForAllTys, but tvs should be a list of tyvar
Like mkFunctionType, compute the FunTyFlag from the arguments
Like mkForAllTy, but assumes the variable is dependent and Specified, a common case
Like mkForAllTys, but assumes all variables are dependent and Specified, a common case
Given a RuntimeRep, applies TYPE to it.
On the fly it rewrites
TYPE LiftedRep --> liftedTypeKind (a synonym)
TYPE UnliftedRep --> unliftedTypeKind (ditto)
TYPE ZeroBitRep --> zeroBitTypeKind (ditto)
NB: no need to check for TYPE (BoxedRep Lifted), TYPE (BoxedRep Unlifted)
because those inner types should already have been rewritten
to LiftedRep and UnliftedRep respectively, by mkTyConApp
see Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim. See Note [Using synonyms to compress types] in GHC.Core.Type
Given a `[RuntimeRep]`, apply TupleRep to it
On the fly, rewrite
TupleRep [] -> zeroBitRepTy (a synonym)
See Note [TYPE and CONSTRAINT] in GHC.Builtin.Types.Prim.
See Note [Using synonyms to compress types] in GHC.Core.Type
Make a dependent forall over a TyCoVar
Make a dependent forall over a TyCoVar
Make a dependent forall over an Inferred variable
Like mkForAllTys, but assumes all variables are dependent and Inferred, a common case
mkTyConBindersPreferAnon :: [TyVar]binders
-> TyCoVarSetfree variables of result
-> [TyConBinder]
Given a list of type-level vars and the free vars of a result kind, makes PiTyBinders, preferring anonymous binders if the variable is, in fact, not dependent. e.g. mkTyConBindersPreferAnon (k:*),(b:k),(c:k) We want (k:*) Named, (b:k) Anon, (c:k) Anon
All non-coercion binders are visible.
Like mkForAllTys, but assumes all variables are dependent and visible
Unwrap one layer of newtype on a type constructor and its
arguments, using an eta-reduced version of the newtype if possible.
This requires tys to have at least newTyConInstArity tycon elements.
Given a list of things paired with their visibilities, partition the things into (invisible things, visible things).
(piResultTys f_ty [ty1, .., tyn]) gives the type of (f ty1 .. tyn)
where f :: f_ty
piResultTys is interesting because:
1. f_ty may have more for-alls than there are args
2. Less obviously, it may have fewer for-alls
For case 2. think of:
piResultTys (forall a.a) [forall b.b, Int]
This really can happen, but only (I think) in situations involving
undefined. For example:
undefined :: forall a. a
Term: undefined (forall b. b->b) Int
This term should have type (Int -> Int), but notice that
there are more type args than foralls in undefineds type.
Render a type corresponding to a user type error into a SDoc.
Attempts to obtain the type variable underlying a Type, without any expansion
Check whether a type (usually of kind RuntimeRep) is lifted, unlifted, or unknown. Returns Nothing if the type isn't of kind RuntimeRep.
`runtimeRepLevity_maybe rr` returns:
Attempts to take a type application apart, as in splitAppTy_maybe, and panics if this is not possible
Does the AppTy split as in splitAppTy_maybe, but assumes that any coreView stuff is already done.
Attempt to take a type application apart, whether it is a function, type constructor, or plain type application. Note that type family applications are NEVER unsaturated by this!
Recursively splits a type as far as is possible, leaving a residual type being applied to and the type arguments applied to it. Never fails, even if that means returning an empty list of type applications.
Like splitAppTys, but doesn't look through type synonyms
Like splitForAllTyCoVar_maybe, but only returns Just if it is a covar binder.
Attempts to take a ForAllTy apart, returning the full ForAllTyBinder
Take a ForAllTy apart, returning the binders and result type
Like splitForAllTyCoVars, but only splits ForAllTys with Invisible type variable binders. Furthermore, each returned tyvar is annotated with its Specificity.
Like splitForAllTyCoVars, but only splits ForAllTys with Required type
variable binders. Furthermore, each returned tyvar is annotated with ().
Take a forall type apart, or panics if that is not possible.
Attempts to take a ForAllTy apart, returning the Var
Take a ForAllTy apart, returning the list of tycovars and the result type. This always succeeds, even if it returns only an empty list. Note that the result type returned may have free variables that were bound by a forall.
Attempts to take a ForAllTy apart, but only if the binder is a TyVar
Like splitForAllTyCoVars, but split only for tyvars. This always succeeds, even if it returns only an empty list. Note that the result type returned may have free variables that were bound by a forall.
Attempts to extract the multiplicity, argument and result types from a type, and panics if that is not possible. See also splitFunTy_maybe
Attempts to extract the multiplicity, argument and result types from a type
Like splitPiTys, but returns only *invisible* binders, including constraints. Stops at the first visible binder.
Same as splitInvisPiTys, but stop when
- you have found n PiTyBinders,
- or you run out of invisible binders
Takes a forall type apart, or panics
Attempts to take a forall type apart; works with proper foralls and functions
Split off all PiTyBinders to a type, splitting both proper foralls and functions
(splitRuntimeRep_maybe rr) takes a Type rr :: RuntimeRep, and
returns the (TyCon,[Type]) for the RuntimeRep, if possible, where
the TyCon is one of the promoted DataCons of RuntimeRep.
Remember: the unique on TyCon that is a a promoted DataCon is the
same as the unique on the DataCon
See Note [Promoted data constructors] in GHC.Core.TyCon
May not be possible if rr is a type variable or type
family application
Attempts to tease a type apart into a type constructor and the application of a number of arguments to that constructor. Panics if that is not possible. See also splitTyConApp_maybe
Attempts to tease a type apart into a type constructor and the application of a number of arguments to that constructor
Works on visible function types only (t1 -> t2), and returns t1 and t2, but not the multiplicity
Is this kind equivalent to TYPE (BoxedRep l) for some l :: Levity?
Is this kind equivalent to Type i.e. TYPE LiftedRep?
Just like splitAppTyNoView_maybe, but does not split (c => t).
See Note [Decomposing fat arrow c=>t]
tcSplitTyConApp_maybe splits a type constructor application into its type constructor and applied types.
Differs from splitTyConApp_maybe in that it does *not* split types headed with (=>), as that's not a TyCon in the type-checker.
Note that this may fail (in funTyConAppTy_maybe) in the case
of a FunTy with an argument of unknown kind FunTy
(e.g. `FunTy (a :: k) Int`, since the kind of a isn't of
the form `TYPE rep`. This isn't usually a problem but may
be temporarily the case during canonicalization:
see Note [Decomposing FunTy] in GHC.Tc.Solver.Equality
and Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType,
Wrinkle around FunTy
Consequently, you may need to zonk your type before using this function.
The same as snd . splitTyConApp
Return Just if this TyConAppCo should be represented as a FunCo
Return Just if this TyConApp should be represented as a FunTy
tyConAppNeedsKindSig :: BoolShould specified binders count towards injective positions in the kind of the TyCon? (If you're using visible kind applications, then you want True here.)
-> TyCon-> IntThe number of args the TyCon is applied to.
-> BoolDoes
T t_1 ... t_nneed a kind signature? (Wherenis the number of arguments)
Does a TyCon (that is applied to some number of arguments) need to be
ascribed with an explicit kind signature to resolve ambiguity if rendered as
a source-syntax type?
(See Note [When does a tycon application need an explicit kind signature?]
for a full explanation of what this function checks for.)
Retrieve the tycon heading this type, if there is one. Does not look through synonyms.
The same as fst . splitTyConApp
We can short-cut the FunTy case
Given a TyCon and a list of argument types to which the TyCon is applied, determine each argument's visibility (Inferred, Specified, or Required).
Wrinkle: consider the following scenario:
T :: forall k. k -> k
tyConForAllTyFlags T [forall m. m -> m -> m, S, R, Q]After substituting, we get
T (forall m. m -> m -> m) :: (forall m. m -> m -> m) -> forall n. n -> n -> nThus, the first argument is invisible, S is visible, R is invisible again,
and Q is visible.
Scale a payload by Many; used for type arguments in core
Returns True if a type has a syntactically fixed runtime rep, as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete.
This function is equivalent to `isFixedRuntimeRepKind . typeKind` but much faster.
Precondition: The type has kind (TYPE blah)
Scale a payload by Many
Extract a relevant type, if there is one.
Does this binder bind a variable that is not erased? Returns True for anonymous binders.
Does this binder bind an invisible argument?
Is this a type-level (i.e., computationally irrelevant, thus erasable)
variable? Satisfies isTyVar = not . isId.
Does this binder bind a visible argument?
Make a named binder
Make many named binders
Make a named binder
var should be a type variable
Make many named binders Input vars should be type variables
Does this ForAllTyFlag classify an argument that is not written in Haskell?
Does this ForAllTyFlag classify an argument that is written in Haskell?
The key type representing kinds in the compiler.
The key representation of types within the compiler
A type labeled KnotTied might have knot-tied tycons in it. See Note [Type checking recursive type and class declarations] in GHC.Tc.TyCl
Mult is a type alias for Type.
Mult must contain Type because multiplicity variables are mere type variables (of kind Multiplicity) in Haskell. So the simplest implementation is to make Mult be Type.
Multiplicities can be formed with: - One: GHC.Types.One (= oneDataCon) - Many: GHC.Types.Many (= manyDataCon) - Multiplication: GHC.Types.MultMul (= multMulTyCon)
So that Mult feels a bit more structured, we provide pattern synonyms and smart constructors for these.
A type of the form p of constraint kind represents a value whose type is
the Haskell predicate p, where a predicate is what occurs before
the => in a Haskell type.
We use PredType as documentation to mark those types that we guarantee to have this kind.
It can be expanded into its representation, but:
The type checker must treat it as opaque
The rest of the compiler treats it as transparent
Consider these examples:
f :: (Eq a) => a -> Int
g :: (?x :: Int -> Int) => a -> Int
h :: (r\l) => {r} => {l::Int | r}Here the Eq a and ?x :: Int -> Int and rl are all called "predicates"
Type synonym used for types of kind RuntimeRep.
A shorthand for data with an attached Mult element (the multiplicity).
Instances2Data, Outputable
Data a => Data (Scaled a)Defined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOutputable a => Outputable (Scaled a)Defined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
A collection of PredTypes
Constructors
TyCoFoldertcf_view :: Type -> Maybe Typetcf_tyvar :: TyVar -> atcf_covar :: CoVar -> atcf_hole :: CoercionHole -> aWhat to do with coercion holes. See Note [Coercion holes] in GHC.Core.TyCo.Rep.
tcf_tycobinder :: TyCoVar -> a -> aThe returned env is used in the extended scope
A substitution of Exprs for non-coercion Ids
Type & coercion & id substitution
The Subst data type defined in this module contains substitution
for tyvar, covar and id. However, operations on IdSubstEnv (mapping
from Id to CoreExpr) that require the definition of the Expr
data type are defined in GHC.Core.Subst to avoid circular module
dependency.
Constructors
Instances1Outputable
Outputable SubstDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Subst
A type of kind ErrorMessage (from the GHC.TypeError module).
This describes how a "map" operation over a type/coercion should behave
Constructors
TyCoMappertcm_tyvar :: env -> TyVar -> m Typetcm_covar :: env -> CoVar -> m Coerciontcm_hole :: env -> CoercionHole -> m CoercionWhat to do with coercion holes. See Note [Coercion holes] in GHC.Core.TyCo.Rep.
tcm_tycobinder :: forall r. env -> TyCoVar -> ForAllTyFlag -> (env -> TyCoVar -> m r) -> m rThe returned env is used in the extended scope
tcm_tycon :: TyCon -> m TyConThis is used only for TcTyCons a) To zonk TcTyCons b) To turn TcTyCons into TyCons. See Note [Type checking recursive type and class declarations] in GHC.Tc.TyCl
Variable Binder
A ForAllTyBinder is the binder of a ForAllTy It's convenient to define this synonym here rather its natural home in GHC.Core.TyCo.Rep, because it's used in GHC.Core.DataCon.hs-boot See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility]
A TyVarBinder is a binder with only TyVar
The non-dependent version of ForAllTyFlag. See Note [FunTyFlag] Appears here partly so that it's together with its friends ForAllTyFlag and ForallVisFlag, but also because it is used in IfaceType, rather early in the compilation chain
Instances6Eq, Data, Ord, NFData, Outputable, Binary
Eq FunTyFlagDefined in ghc-10.0.0.20260917 · GHC.Types.VarData FunTyFlagDefined in ghc-10.0.0.20260917 · GHC.Types.VarOrd FunTyFlagDefined in ghc-10.0.0.20260917 · GHC.Types.VarNFData FunTyFlagDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputable FunTyFlagDefined in ghc-10.0.0.20260917 · GHC.Types.VarBinary FunTyFlagDefined in ghc-10.0.0.20260917 · GHC.Types.Var
A PiTyBinder represents an argument to a function. PiTyBinders can be dependent (Named) or nondependent (Anon). They may also be visible or not. See Note [PiTyBinders]
Instances2Data, Outputable
Data PiTyBinderDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputable PiTyBinderDefined in ghc-10.0.0.20260917 · GHC.Types.Var
Type or Coercion Variable
Type or kind Variable
Instances15Data, Ord, NamedThing, Outputable, Uniquable, HasOccName, …
Eq VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarData VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOrd VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarNamedThing VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputable VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarUniquable VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputableBndr VarDefined in ghc-10.0.0.20260917 · GHC.Core.Ppr · orphanHasOccName VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarModifyState IdDefined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstEq (DeBruijn CoreAlt)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.Expr · orphanEq (DeBruijn CoreExpr)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.Expr · orphanEq (DeBruijn Var)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.TypeToHie (Context (Located Var))Defined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstOutputableBndr (Id, TagSig)Defined in ghc-10.0.0.20260917 · GHC.Stg.EnforceEpt.TagSigtype Anno Id = SrcSpanAnnNDefined in ghc-10.0.0.20260917 · GHC.Hs.Extension · orphan
The type or kind of the Var in question
ForAllTyFlag
Is something required to appear in source Haskell (Required), permitted by request (Specified) (visible type application), or prohibited entirely from appearing in source Haskell (Inferred)? See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep
Constructors
Instances8Eq, Data, Ord, NFData, Binary, OutputableBndrFlag, …
Eq ForAllTyFlagDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.SpecificityData ForAllTyFlagDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.SpecificityOrd ForAllTyFlagDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.SpecificityNFData ForAllTyFlagDefined in ghc-10.0.0.20260917 · GHC.Hs.Specificity · orphanOutputable ForAllTyFlagDefined in ghc-10.0.0.20260917 · GHC.Hs.Specificity · orphanBinary ForAllTyFlagDefined in ghc-10.0.0.20260917 · GHC.Hs.Specificity · orphanOutputableBndrFlag ForAllTyFlag pDefined in ghc-10.0.0.20260917 · GHC.Hs.TypeOutputable tv => Outputable (VarBndr tv ForAllTyFlag)Defined in ghc-10.0.0.20260917 · GHC.Types.Var
Whether an Invisible argument may appear in source Haskell.
Constructors
InferredSpecthe argument may not appear in source Haskell, it is only inferred.
SpecifiedSpecthe argument may appear in source Haskell, but isn't required.
Instances10Eq, Data, Ord, NFData, Binary, OutputableBndrFlag, …
Eq SpecificityDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.SpecificityData SpecificityDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.SpecificityOrd SpecificityDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.SpecificityNFData SpecificityDefined in ghc-10.0.0.20260917 · GHC.Hs.Specificity · orphanBinary SpecificityDefined in ghc-10.0.0.20260917 · GHC.Hs.Specificity · orphanOutputableBndrFlag Specificity pDefined in ghc-10.0.0.20260917 · GHC.Hs.TypeRepTV Specificity SpecificityDefined in ghc-10.0.0.20260917 · GHC.HsToCore.QuoteReifyFlag Specificity SpecificityDefined in ghc-10.0.0.20260917 · GHC.Tc.Gen.SpliceCvtFlag Specificity SpecificityDefined in ghc-10.0.0.20260917 · GHC.ThToHsOutputable tv => Outputable (VarBndr tv Specificity)Defined in ghc-10.0.0.20260917 · GHC.Types.Var
module GHC.Core.TyCon
Assuming that two types are the same, ignoring coercions, find a nominal coercion between the types. This is useful when optimizing transitivity over coercion applications, where splitting two AppCos might yield different kinds. See Note [EtaAppCo] in GHC.Core.Coercion.Opt.
Creates a new coercion with both of its types casted by different casts
castCoercionKind g h1 h2, where g :: t1 ~r t2,
has type (t1 |> h1) ~r (t2 |> h2).
h1 and h2 must be nominal.
It calls coercionKindRole, so it's quite inefficient (which I stands for)
Use castCoercionKind2 instead if t1, t2, and r are known beforehand.
castCoercionKind1 g r t1 t2 h = coercionKind g r t1 t2 h h
That is, it's a specialised form of castCoercionKind, where the two
kind coercions are identical
castCoercionKind1 g r t1 t2 h, where g :: t1 ~r t2,
has type (t1 |> h) ~r (t2 |> h).
h must be nominal.
See Note [castCoercionKind1]
Creates a new coercion with both of its types casted by different casts
castCoercionKind2 g r t1 t2 h1 h2, where g :: t1 ~r t2,
has type (t1 |> h1) ~r (t2 |> h2).
h1 and h2 must be nominal.
If it is the case that
c :: (t1 ~ t2)i.e. the kind of c relates t1 and t2, then coercionKind c = Pair t1 t2.
Get a coercion's kind and role.
Apply coercionKind to multiple Coercions
Retrieve the role from a coercion.
Try one stepper and then try the next, if the first doesn't make progress. So if it returns NS_Done, it means that both steppers are satisfied
Like downgradeRole_maybe, but panics if the change isn't a downgrade.
See Note [Role twiddling functions]
Syntactic equality of coercions
Compare two Coercions, with respect to an RnEnv2
extendLiftingContext :: LiftingContextoriginal LC
-> TyCoVarnew variable to map...
-> Coercion...to this lifted version
-> LiftingContext
Extend a lifting context with a new mapping.
extendLiftingContextAndInScope :: LiftingContextOriginal LC
-> TyCoVarnew variable to map...
-> Coercionto this coercion
-> LiftingContext
Extend a lifting context with a new mapping, and extend the in-scope set
Extend the substitution component of a lifting context with a new binding for a coercion variable. Used during coercion optimisation.
Extract a covar, if possible. This check is dirty. Be ashamed of yourself. (It's dirty because it cares about the structure of a coercion, which is morally reprehensible.)
Extract the nth field of a FunCo
Is there a coercion hole in this type? See wrinkle (DE6) of Note [Defaulting equalities] in GHC.Tc.Solver.Default
If `instNewTyCon_maybe T ts = Just (rep_ty, co)` then `co :: T ts ~R# rep_ty`
Checks for a newtype, and for being saturated
Is a var in the domain of a lifting context?
Tests if this coercion is obviously reflexive. Guaranteed to work very quickly. Sometimes a coercion can be reflexive, but not obviously so. c.f. isReflexiveCo
Returns the type coerced if this coercion is reflexive. Guaranteed to work very quickly. Sometimes a coercion can be reflexive, but not obviously so. c.f. isReflexiveCo_maybe
Tests if this kind coercion is Refl Guaranteed to work very quickly. PRECONDITION: the argument is a KindCoercion So if it sees (GRefl k (MCo kk)) :: k ~ (k |> kk) then we know that kk must be reflexive. And hence if co = GRefl {} then it is equivalent to Refl, because GRefl N ty MRefl = Refl ty so we return True See Note [KindCoercion] in GHC.Core.TyCo.Rep
Tests if this kind MCoercion is obviously generalized reflexive Guaranteed to work very quickly.
Slowly checks if the coercion is reflexive. Don't call this in a loop, as it walks over the entire coercion.
Extracts the coerced type from a reflexive coercion. This potentially walks over the entire coercion, so avoid doing this in a loop.
Get the InScopeSet from a LiftingContext
Lookup a CoVar in the substitution in a LiftingContext
liftCoSubst role lc ty produces a coercion (at role role)
that coerces between lc_left(ty) and lc_right(ty), where
lc_left is a substitution mapping type variables to the left-hand
types of the mapped coercions in lc, and similar for lc_right.
liftCoSubstVarBndrUsing :: (r -> CoercionN)coercion getter
-> (LiftingContext -> Type -> r)callback
-> LiftingContext-> TyCoVar-> (LiftingContext, TyCoVar, r)
mkAppCo Return the left-hand type of the axiom, when the axiom is instantiated at the types given.
Cast a type by an MCoercion
Makes a coercion type from two types: the types whose equality is proven by the relevant Coercion
Given ty :: k1, co :: k1 ~ k2, co2:: ty ~r ty',
produces @co' :: (ty |> co) ~r ty'
It is not only a utility function, but it saves allocation when co
is a GRefl coercion.
Given ty :: k1, co :: k1 ~ k2, co2:: ty' ~r ty,
produces @co' :: ty' ~r (ty |> co)
It is not only a utility function, but it saves allocation when co
is a GRefl coercion.
Like mkCoherenceRightCo, but with an MCoercion
Make a Coercion from a tycovar, a kind coercion, and a body coercion.
Make a generalized reflexive coercion
Given r, ty :: k1, and co :: k1 ~N k2,
produces co' :: (ty |> co) ~r ty
Given ty :: k1, co :: k1 ~ k2,
produces co' :: ty ~r (ty |> co)
Make a coercion from a coercion hole
Make a Coercion quantified over a type/coercion variable; the variable has the same kind and visibility in both sides of the coercion
Instantiates a Coercion. Works for both tyvar and covar
Given co :: (a :: k) ~ (b :: k') produce co' :: k ~ k'.
Make a nominal reflexive coercion
Make a phantom coercion between two types. The coercion passed in must be a nominal coercion between the kinds of the types.
Make a forall Coercion, where both types related by the coercion are quantified over the same variable.
mkProofIrrelCo :: Rolerole of the created coercion, "r"
-> KindCoercion:: phi1 ~N phi2
-> Coerciong1 :: phi1
-> Coerciong2 :: phi2
-> Coercion:: g1 ~r g2
Make a "coercion between coercions".
Make a reflexive coercion
Make a representational reflexive coercion
Given a coercion `co :: (t1 :: TYPE r1) ~ (t2 :: TYPE r2)` produce a coercion `rep_co :: r1 ~ r2`
Create a symmetric version of the given Coercion that asserts
equality between the same types but in the other "direction", so
a kind of t1 ~ t2 becomes the kind t2 ~ t1.
Get the reverse of an MCoercion
Compose two MCoercions via transitivity
Apply a type constructor to a list of coercions. It is the caller's responsibility to get the roles correct on argument coercions.
Instantiate the left-hand side of an unbranched axiom
mkUnivCo Make a universal coercion between two arbitrary types.
like mkKindCo, but aggressively & recursively optimizes to avoid using a KindCo constructor. The output role is nominal.
Set the type of a CoercionHole
Converts a coercion to be nominal, if possible. See Note [Role twiddling functions]
Attempt to take a coercion application apart.
Like splitForAllCo_maybe, but only returns Just for covar binder
Like splitForAllCo_maybe, but only returns Just for tyvar binder
Apply "sym" to all coercions in a LiftCoEnv
Sometimes we want to look through a newtype and get its associated coercion.
This function strips off newtype layers enough to reveal something that isn't
a newtype. Specifically, here's the invariant:
topNormaliseNewType_maybe rec_nts ty = Just (co, ty')then (a) co : ty ~R ty'.
(b) ty' is not a newtype.
The function returns Nothing for non-newtypes,
or unsaturated applications
This function does *not* look through type families, because it has no access to the type family environment. If you do have that at hand, consider to use topNormaliseType_maybe, which should be a drop-in replacement for topNormaliseNewType_maybe If topNormliseNewType_maybe ty = Just (co, ty'), then co : ty ~R ty'
A general function for normalising the top-level of a type. It continues to use the provided NormaliseStepper until that function fails, and then this function returns. The roles of the coercions produced by the NormaliseStepper must all be the same, which is the role returned from the call to topNormaliseTypeX.
Typically ev is Coercion.
If topNormaliseTypeX step plus ty returns Just (ev, ty')
then ty ~ev1~ t1 ~ev2~ t2 ... ~evn~ ty'
and ev = ev1 .plus ev2 plus ... plus evn
If it returns Nothing it means that no newtype unwrapping could happen.
A NormaliseStepper that unwraps newtypes, careful not to fall into a loop. If it would fall into a loop, it produces NS_Abort.
Erase the environments in a lifting context
Coercion substitution, see zipTvSubst
Substitute within several Coercions The substitution has to satisfy the invariants described in Note [The substitution invariant].
Tidy a Coercion
See Note [Strictness in tidyType and friends]
Is this a coercion variable?
Satisfies isId v ==> isCoVar v == not (isNonCoVarId v).
Instances1Outputable
Outputable LiftingContextDefined in ghc-10.0.0.20260917 · GHC.Core.Coercion
The result of stepping in a normalisation function. See topNormaliseTypeX.
Constructors
NS_DoneNothing more to do.
NS_AbortWe exceeded the maximum stepper depth (e.g. recursive newtypes). Give up.
NS_Step RecTcChecker Type evWe stepped, yielding a new type.
Instances4Functor, Foldable, Traversable, Outputable
Functor NormaliseStepResultDefined in ghc-10.0.0.20260917 · GHC.Core.CoercionFoldable NormaliseStepResultDefined in ghc-10.0.0.20260917 · GHC.Core.CoercionTraversable NormaliseStepResultDefined in ghc-10.0.0.20260917 · GHC.Core.CoercionOutputable ev => Outputable (NormaliseStepResult ev)Defined in ghc-10.0.0.20260917 · GHC.Core.Coercion
A function to check if we can reduce a type by one step. Used with topNormaliseTypeX.
Instances6Eq, Data, Ord, NFData, Outputable, Binary
Eq CoSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepData CoSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOrd CoSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepNFData CoSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOutputable CoSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepBinary CoSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
A Coercion is concrete evidence of the equality/convertibility of two types.
A coercion to be filled in by the type-checker. See Note [Coercion holes]
Instances3Data, Outputable, Uniquable
Data CoercionHoleDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOutputable CoercionHoleDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepUniquable CoercionHoleDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
Instances5Eq, Data, Ord, NFData, Outputable
Eq FunSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepData FunSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOrd FunSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepNFData FunSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOutputable FunSelDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
A semantically more meaningful type to represent what may or may not be a useful Coercion.
Instances2Data, Outputable
Data MCoercionDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOutputable MCoercionDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
For simplicity, we have just one UnivCo that represents a coercion from some type to some other type, with (in general) no restrictions on the type. The UnivCoProvenance specifies more exactly what the coercion really is and why a program should (or shouldn't!) trust the coercion. It is reasonable to consider each constructor of UnivCoProvenance as a totally independent coercion form; their only commonality is that they don't tell you what types they coercion between. (That info is in the UnivCo constructor of Coercion.
Instances6Eq, Data, Ord, NFData, Outputable, Binary
Eq UnivCoProvenanceDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepData UnivCoProvenanceDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOrd UnivCoProvenanceDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepNFData UnivCoProvenanceDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepOutputable UnivCoProvenanceDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepBinary UnivCoProvenanceDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.Rep
Instances6Eq, Data, Ord, NFData, Outputable, Binary
Eq LeftOrRightDefined in ghc-10.0.0.20260917 · GHC.Types.BasicData LeftOrRightDefined in ghc-10.0.0.20260917 · GHC.Types.BasicOrd LeftOrRightDefined in ghc-10.0.0.20260917 · GHC.Types.BasicNFData LeftOrRightDefined in ghc-10.0.0.20260917 · GHC.Types.BasicOutputable LeftOrRightDefined in ghc-10.0.0.20260917 · GHC.Types.BasicBinary LeftOrRightDefined in ghc-10.0.0.20260917 · GHC.Types.Basic
Coercion Variable
Type or Coercion Variable
Instances15Data, Ord, NamedThing, Outputable, Uniquable, HasOccName, …
Eq VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarData VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOrd VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarNamedThing VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputable VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarUniquable VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarOutputableBndr VarDefined in ghc-10.0.0.20260917 · GHC.Core.Ppr · orphanHasOccName VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarModifyState IdDefined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstEq (DeBruijn CoreAlt)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.Expr · orphanEq (DeBruijn CoreExpr)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.Expr · orphanEq (DeBruijn Var)Defined in ghc-10.0.0.20260917 · GHC.Core.Map.TypeToHie (Context (Located Var))Defined in ghc-10.0.0.20260917 · GHC.Iface.Ext.AstOutputableBndr (Id, TagSig)Defined in ghc-10.0.0.20260917 · GHC.Stg.EnforceEpt.TagSigtype Anno Id = SrcSpanAnnNDefined in ghc-10.0.0.20260917 · GHC.Hs.Extension · orphan
See Note [Roles] in GHC.Core.Coercion
Order of constructors matters: the Ord instance coincides with the *super*typing relation on roles.
Instances7Eq, Data, Ord, NFData, Outputable, Binary, …
Eq RoleDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.BasicData RoleDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.BasicOrd RoleDefined in ghc-10.0.0.20260917 · Language.Haskell.Syntax.BasicNFData RoleDefined in ghc-10.0.0.20260917 · GHC.Core.Coercion.Axiom · orphanOutputable RoleDefined in ghc-10.0.0.20260917 · GHC.Core.Coercion.Axiom · orphanBinary RoleDefined in ghc-10.0.0.20260917 · GHC.Core.Coercion.Axiom · orphantype Anno (Maybe Role) = EpAnnCODefined in ghc-10.0.0.20260917 · GHC.Hs.Decls · orphan
module GHC.Builtin.Types
module GHC.Driver.Env
module GHC.Types.Basic
module GHC.Types.Var.Set
module GHC.Types.Var.Env
module GHC.Types.Name.Set
module GHC.Types.Name.Env
Instances38Uniquable, …
Uniquable LocalLabelDefined in ghc-10.0.0.20260917 · GHC.ByteCode.InstrUniquable LabelDefined in ghc-10.0.0.20260917 · GHC.Cmm.Dataflow.LabelUniquable LocalRegDefined in ghc-10.0.0.20260917 · GHC.Cmm.RegUniquable RegWithFormatDefined in ghc-10.0.0.20260917 · GHC.CmmToAsm.FormatUniquable RegDefined in ghc-10.0.0.20260917 · GHC.CmmToAsm.Reg.Graph.Baseso we can put regs in UniqSets
Uniquable StoreDefined in ghc-10.0.0.20260917 · GHC.CmmToAsm.Reg.Graph.SpillCleanUniquable SymNameDefined in ghc-10.0.0.20260917 · GHC.CmmToAsm.Wasm.TypesUniquable ClassDefined in ghc-10.0.0.20260917 · GHC.Core.ClassUniquable ConLikeDefined in ghc-10.0.0.20260917 · GHC.Core.ConLikeUniquable DataConDefined in ghc-10.0.0.20260917 · GHC.Core.DataConUniquable PatSynDefined in ghc-10.0.0.20260917 · GHC.Core.PatSynUniquable CoercionHoleDefined in ghc-10.0.0.20260917 · GHC.Core.TyCo.RepUniquable TyConDefined in ghc-10.0.0.20260917 · GHC.Core.TyConUniquable FastStringDefined in ghc-10.0.0.20260917 · GHC.Types.UniqueUniquable IdentDefined in ghc-10.0.0.20260917 · GHC.JS.IdentUniquable RealRegDefined in ghc-10.0.0.20260917 · GHC.Platform.RegUniquable RegDefined in ghc-10.0.0.20260917 · GHC.Platform.RegUniquable VirtualRegDefined in ghc-10.0.0.20260917 · GHC.Platform.RegUniquable RegClassDefined in ghc-10.0.0.20260917 · GHC.Platform.Reg.ClassUniquable EvBindsVarDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.EvidenceUniquable SkolemInfoDefined in ghc-10.0.0.20260917 · GHC.Tc.Types.OriginUniquable ConLikeNameDefined in ghc-10.0.0.20260917 · GHC.Types.GREInfoUniquable NameDefined in ghc-10.0.0.20260917 · GHC.Types.NameUniquable NameSpaceDefined in ghc-10.0.0.20260917 · GHC.Types.Name.OccurrenceUniquable UniqueDefined in ghc-10.0.0.20260917 · GHC.Types.UniqueUniquable VarDefined in ghc-10.0.0.20260917 · GHC.Types.VarUniquable PackageIdDefined in ghc-10.0.0.20260917 · GHC.Unit.InfoUniquable PackageNameDefined in ghc-10.0.0.20260917 · GHC.Unit.InfoUniquable ModuleDefined in ghc-10.0.0.20260917 · GHC.Unit.TypesUniquable UnitIdDefined in ghc-10.0.0.20260917 · GHC.Unit.TypesUniquable FieldLabelStringDefined in ghc-10.0.0.20260917 · GHC.Types.FieldLabel · orphanUniquable WarningCategoryDefined in ghc-10.0.0.20260917 · GHC.Unit.Module.Warnings · orphanUniquable ModuleNameDefined in ghc-10.0.0.20260917 · GHC.Types.UniqueUniquable IntDefined in ghc-10.0.0.20260917 · GHC.Types.UniqueUniquable Word64Defined in ghc-10.0.0.20260917 · GHC.Types.UniqueUniquable (CoAxiom br)Defined in ghc-10.0.0.20260917 · GHC.Core.Coercion.AxiomUniquable unit => Uniquable (Definite unit)Defined in ghc-10.0.0.20260917 · GHC.Unit.TypesIsUnitId u => Uniquable (GenUnit u)Defined in ghc-10.0.0.20260917 · GHC.Unit.Types
Unique identifier.
The type of unique identifiers that are used in many places in GHC
for fast ordering and equality tests. You should generate these with
the functions from the UniqSupply module
module GHC.Types.Unique.Set
module GHC.Types.Unique.FM
module GHC.Data.FiniteMap
module GHC.Utils.Misc
Use a Data instance to implement a deserialization scheme dual to that of serializeWithData
If the Serialized value contains something of the given type, then use the specified deserializer to return Just that.
Otherwise return Nothing.
Use a Data instance to implement a serialization scheme dual to that of deserializeWithData
Put a Typeable value that we are able to actually turn into bytes into a Serialized value ready for deserialization later
Represents a serialized value of a particular type. Attempts can be made to deserialize it at certain types
Constructors
Instances4NFData, Outputable, Binary
NFData SerializedDefined in ghc-boot-10.0.0.20260917 · GHC.SerializedBinary SerializedDefined in ghci-10.0.0.20260917 · GHCi.TH.Binary · orphanOutputable SerializedDefined in ghc-10.0.0.20260917 · GHC.Utils.OutputableBinary SerializedDefined in ghc-10.0.0.20260917 · GHC.Utils.Binary.Typeable · orphan
module GHC.Types.SrcLoc
module GHC.Utils.Outputable
module GHC.Utils.Panic
module GHC.Types.Unique.Supply
module GHC.Data.FastString
module GHC.Tc.Errors.Hole.FitTypes
module GHC.Tc.Errors.Hole.Plugin
module GHC.Unit.Module.ModGuts
module GHC.Unit.Module.ModSummary
module GHC.Unit.Module.ModIface
module GHC.Types.Meta
module GHC.Types.SourceError
A collection of messages emitted by GHC during error reporting. A diagnostic message is typically a warning or an error. See Note [Messages].
INVARIANT: All the messages in this collection must be relevant, i.e. their Severity should not be SevIgnore. The smart constructor mkMessages will filter out any message which Severity is SevIgnore.
Instances6Functor, Foldable, Traversable, Semigroup, Monoid, Outputable
Functor MessagesDefined in ghc-10.0.0.20260917 · GHC.Types.ErrorFoldable MessagesDefined in ghc-10.0.0.20260917 · GHC.Types.ErrorTraversable MessagesDefined in ghc-10.0.0.20260917 · GHC.Types.ErrorSemigroup (Messages e)Defined in ghc-10.0.0.20260917 · GHC.Types.ErrorMonoid (Messages e)Defined in ghc-10.0.0.20260917 · GHC.Types.ErrorDiagnostic e => Outputable (Messages e)Defined in ghc-10.0.0.20260917 · GHC.Types.Error
Getting Names
2 declarationsAttempt to convert a Template Haskell name to one that GHC can
understand. Original TH names such as those you get when you use
the 'foo syntax will be translated to their equivalent GHC name
exactly. Qualified or unqualified TH names will be dynamically bound
to names in the module being compiled, if possible. Exact TH names
will be bound to the name they represent, exactly.
thNameToGhcName can be used in CoreM, Hsc and TcM monads.
thNameToGhcName is recommended way to lookup Names in GHC plugins.
{-# LANGUAGE TemplateHaskellQuotes #-}
getNames :: Hsc (Maybe Name, Maybe Name)
getNames = do
class_Eq <- thNameToGhcName ''Eq
fun_eq <- thNameToGhcName '(==)
return (classEq, fun_eq)
Attempt to convert a Template Haskell name to one that GHC can
understand. Original TH names such as those you get when you use
the 'foo syntax will be translated to their equivalent GHC name
exactly. Qualified or unqualified TH names will be dynamically bound
to names in the module being compiled, if possible. Exact TH names
will be bound to the name they represent, exactly.
One must be careful to consistently use the same NameCache to create identifier that might be compared. (C.f. how the ST Monad enforces that variables from separate runST invocations are never intermingled; it would be valid to use the same tricks for Names and NameCaches.)
For now, the easiest and recommended way to ensure a consistent NameCache is used it to retrieve the preexisting one from an active HscEnv. A single HscEnv is created per GHC "session", and this ensures everything in that session will get the same name cache.