Dictionary Function Identifier
Moduleghc-9.10.3GHC2021
GHC.Core.InstEnv
- 13 types
- 42 values
- Packageghc-9.10.3
- Exports55
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceVar.hs
Constructors
Instances2Semigroup, Outputable
Semigroup PotentialUnifiersDefined in ghc-9.10.3 · GHC.Core.InstEnvOutputable PotentialUnifiersDefined in ghc-9.10.3 · GHC.Core.InstEnv
The semantics allowed for overlapping instances for a particular instance. See Note [Safe Haskell isSafeOverlap] in GHC.Core.InstEnv for a explanation of the isSafeOverlap field.
AnnKeywordId : AnnOpen
'{-# OVERLAPPABLE'or'{-# OVERLAPPING'or'{-# OVERLAPS'or'{-# INCOHERENT', AnnClose`#-}`,
Constructors
Instances4Eq, Data, Outputable, Binary
Eq OverlapFlagDefined in ghc-9.10.3 · GHC.Types.BasicData OverlapFlagDefined in ghc-9.10.3 · GHC.Types.BasicOutputable OverlapFlagDefined in ghc-9.10.3 · GHC.Types.BasicBinary OverlapFlagDefined in ghc-9.10.3 · GHC.Types.Basic
Constructors
NoOverlap SourceTextThis instance must not overlap another NoOverlap instance. However, it may be overlapped by Overlapping instances, and it may overlap Overlappable instances.
Overlappable SourceTextSilently ignore this instance if you find a more specific one that matches the constraint you are trying to resolve
Example: constraint (Foo [Int]) instance Foo [Int] instance {-# OVERLAPPABLE #-} Foo [a]
Since the second instance has the Overlappable flag, the first instance will be chosen (otherwise its ambiguous which to choose)
Overlapping SourceTextSilently ignore any more general instances that may be used to solve the constraint.
Example: constraint (Foo [Int]) instance {-# OVERLAPPING #-} Foo [Int] instance Foo [a]
Since the first instance has the Overlapping flag, the second---more general---instance will be ignored (otherwise it is ambiguous which to choose)
Overlaps SourceTextEquivalent to having both Overlapping and Overlappable flags.
Incoherent SourceTextBehave like Overlappable and Overlapping, and in addition pick an arbitrary one if there are multiple matching candidates, and don't worry about later instantiation
Example: constraint (Foo [b]) instance {-# INCOHERENT -} Foo [Int] instance Foo [a] Without the Incoherent flag, we'd complain that instantiating
bwould change which instance was chosen. See also Note [Incoherent instances] in GHC.Core.InstEnvNonCanonical SourceTextBehave like Incoherent, but the instance choice is observable by the program behaviour. See Note [Coherence and specialisation: overview].
We don't have surface syntax for the distinction between Incoherent and NonCanonical instances; instead, the flag `-f{no-}specialise-incoherents` (on by default) controls whether
INCOHERENTinstances are regarded as Incoherent or NonCanonical.
Instances7Eq, Data, Outputable, Binary, ToHie, Anno, …
Eq OverlapModeDefined in ghc-9.10.3 · GHC.Types.BasicData OverlapModeDefined in ghc-9.10.3 · GHC.Types.BasicOutputable OverlapModeDefined in ghc-9.10.3 · GHC.Types.BasicBinary OverlapModeDefined in ghc-9.10.3 · GHC.Types.BasicToHie (LocatedP OverlapMode)Defined in ghc-9.10.3 · GHC.Iface.Ext.Asttype Anno OverlapMode = SrcSpanAnnPDefined in ghc-9.10.3 · GHC.Hs.Decls · orphantype Anno OverlapMode = SrcSpanAnnPDefined in ghc-9.10.3 · GHC.Hs.Decls · orphan
A type-class instance. Note that there is some tricky laziness at work here. See Note [ClsInst laziness and the rough-match fields] for more details.
Constructors
ClsInstis_cls_nm :: NameClass name
is_tcs :: [RoughMatchTc]Top of type args The class itself is always the first element of this list
is_dfun_name :: Nameis_dfun_name = idName . is_dfun.We use is_dfun_name for the visibility check, instIsVisible, which needs to know the Module which the dictionary is defined in. However, we cannot use the Module attached to is_dfun since doing so would mean we would potentially pull in an entire interface file unnecessarily. This was the cause of #12367.
is_tvs :: [TyVar]is_cls :: Classis_tys :: [Type]is_dfun :: DFunIdis_flag :: OverlapFlagis_orphan :: IsOrphanis_warn :: Maybe (WarningTxt GhcRn)
Instances3Data, NamedThing, Outputable
Data ClsInstDefined in ghc-9.10.3 · GHC.Core.InstEnvNamedThing ClsInstDefined in ghc-9.10.3 · GHC.Core.InstEnvOutputable ClsInstDefined in ghc-9.10.3 · GHC.Core.InstEnv
mkImportedClsInst :: Namethe name of the class
-> [RoughMatchTc]the rough match signature of the instance
-> Namethe Name of the dictionary binding
-> DFunIdthe Id of the dictionary.
-> OverlapFlagmay this instance overlap?
-> IsOrphanis this instance an orphan?
-> Maybe (WarningTxt GhcRn)warning emitted when solved
-> ClsInst
A fuzzy comparison function for class instances, intended for sorting instances before displaying them to the user.
Collects the names of concrete types and type constructors that make up the head of a class instance. For instance, given `class Foo a b`:
`instance Foo (Either (Maybe Int) a) Bool` would yield [Either, Maybe, Int, Bool]
Used in the implementation of ":info" in GHCi.
The tcSplitSigmaTy is because of instance Foo a => Baz T where ... The decl is an orphan if Baz and T are both not locally defined, even if Foo *is* locally defined
InstEnvs represents the combination of the global type class instance environment, the local type class instance environment, and the set of transitively reachable orphan modules (according to what modules have been directly imported) used to test orphan instance visibility.
Constructors
Set of visible orphan modules, according to what modules have been directly imported. This is based off of the dep_orphs field, which records transitively reachable orphan modules (modules that define orphan instances).
Instances1Outputable
Outputable InstEnvDefined in ghc-9.10.3 · GHC.Core.InstEnv
Why a particular typeclass application couldn't be looked up.
Constructors
LookupInstErrNotExactTyvars aren't an exact match.
LookupInstErrFlexiVarOne of the tyvars is flexible.
LookupInstErrNotFoundNo matching instance was found.
Instances2Generic, Rep
Generic LookupInstanceErrReasonDefined in ghc-9.10.3 · GHC.Core.InstEnvtype Rep LookupInstanceErrReason = D1 ('MetaDataDefined in ghc-9.10.3 · GHC.Core.InstEnv"LookupInstanceErrReason"
"GHC.Core.InstEnv"
"ghc-9.10.3-cff4"
'False) (C1 ('MetaCons"LookupInstErrNotExact"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"LookupInstErrFlexiVar"
'PrefixI 'False) U1 :+: C1 ('MetaCons"LookupInstErrNotFound"
'PrefixI 'False) U1))
Makes no particular effort to detect conflicts.
True when when the instance heads are the same e.g. both are Eq [(a,b)] Used for overriding in GHCi Obviously should be insensitive to alpha-renaming
Look up an instance in the given instance environment. The given class application must match exactly one instance and the match may not contain any flexi type variables. If the lookup is unsuccessful, yield 'Left errorMessage'.
See Note [Rules for instance lookup] ^ See Note [Safe Haskell Overlapping Instances] in GHC.Tc.Solver ^ See Note [Safe Haskell Overlapping Instances Implementation] in GHC.Tc.Solver
Checks for an exact match of ClsInst in the instance environment. We use this when we do signature checking in GHC.Tc.Module
Test if an instance is visible, by checking that its origin module is in VisibleOrphanModules. See Note [Instance lookup and orphan instances]