ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.Tc.Utils.Env

Contents

- Orphan instances

Synopsis

- data TyThing
  - = AnId Id
  - | AConLike ConLike
  - | ATyCon TyCon
  - | ACoAxiom (CoAxiom Branched)
- data TcTyThing
  - = AGlobal TyThing
  - | ATcId {
    - tct_id :: TcId
    - tct_info :: IdBindingInfo
    }
  - | ATyVar Name TcTyVar
  - | ATcTyCon TyCon
  - | APromotionErr PromotionErr
- type TcId = Id
- data InstInfo a = InstInfo {
  - iSpec :: ClsInst
  - iBinds :: InstBindings a
  }
- iDFunId :: InstInfo a -> DFunId
- pprInstInfoDetails :: OutputableBndrId a => InstInfo (GhcPass a) -> SDoc
- simpleInstInfoClsTy :: InstInfo a -> (Class, Type)
- simpleInstInfoTy :: InstInfo a -> Type
- simpleInstInfoTyCon :: InstInfo a -> TyCon
- data InstBindings a = InstBindings {
  - ib_tyvars :: [Name]
  - ib_binds :: LHsBinds a
  - ib_pragmas :: [LSig a]
  - ib_extensions :: [Extension]
  - ib_derived :: Bool
  }
- tcExtendGlobalEnv :: [TyThing] -> TcM r -> TcM r
- tcExtendTyConEnv :: [TyCon] -> TcM r -> TcM r
- tcExtendGlobalEnvImplicit :: [TyThing] -> TcM r -> TcM r
- setGlobalTypeEnv :: TcGblEnv -> TypeEnv -> TcM TcGblEnv
- tcExtendGlobalValEnv :: [Id] -> TcM a -> TcM a
- tcTyThBinders :: [TyThing] -> TcM ThBindEnv
- tcLookupLocatedGlobal :: LocatedA Name -> TcM TyThing
- tcLookupGlobal :: Name -> TcM TyThing
- tcLookupGlobalOnly :: Name -> TcM TyThing
- tcLookupTyCon :: Name -> TcM TyCon
- tcLookupClass :: Name -> TcM Class
- tcLookupDataCon :: Name -> TcM DataCon
- tcLookupPatSyn :: Name -> TcM PatSyn
- tcLookupConLike :: Name -> TcM ConLike
- tcLookupLocatedGlobalId :: LocatedA Name -> TcM Id
- tcLookupLocatedTyCon :: LocatedN Name -> TcM TyCon
- tcLookupLocatedClass :: LocatedA Name -> TcM Class
- tcLookupAxiom :: Name -> TcM (CoAxiom Branched)
- lookupGlobal :: HscEnv -> Name -> IO TyThing
- lookupGlobal_maybe :: HscEnv -> Name -> IO (MaybeErr SDoc TyThing)
- ioLookupDataCon :: HscEnv -> Name -> IO DataCon
- addTypecheckedBinds :: TcGblEnv -> [LHsBinds GhcTc] -> TcGblEnv
- tcExtendKindEnv :: NameEnv TcTyThing -> TcM r -> TcM r
- tcExtendKindEnvList :: [(Name, TcTyThing)] -> TcM r -> TcM r
- tcExtendTyVarEnv :: [TyVar] -> TcM r -> TcM r
- tcExtendNameTyVarEnv :: [(Name, TcTyVar)] -> TcM r -> TcM r
- tcExtendLetEnv :: TopLevelFlag -> TcSigFun -> IsGroupClosed -> [TcId] -> TcM a -> TcM a
- tcExtendSigIds :: TopLevelFlag -> [TcId] -> TcM a -> TcM a
- tcExtendRecIds :: [(Name, TcId)] -> TcM a -> TcM a
- tcExtendIdEnv :: [TcId] -> TcM a -> TcM a
- tcExtendIdEnv1 :: Name -> TcId -> TcM a -> TcM a
- tcExtendIdEnv2 :: [(Name, TcId)] -> TcM a -> TcM a
- tcExtendBinderStack :: [TcBinder] -> TcM a -> TcM a
- tcExtendLocalTypeEnv :: TcLclEnv -> [(Name, TcTyThing)] -> TcLclEnv
- isTypeClosedLetBndr :: Id -> Bool
- tcCheckUsage :: Name -> Mult -> TcM a -> TcM (a, HsWrapper)
- tcLookup :: Name -> TcM TcTyThing
- tcLookupLocated :: LocatedA Name -> TcM TcTyThing
- tcLookupLocalIds :: [Name] -> TcM [TcId]
- tcLookupId :: Name -> TcM Id
- tcLookupIdMaybe :: Name -> TcM (Maybe Id)
- tcLookupTyVar :: Name -> TcM TcTyVar
- tcLookupTcTyCon :: HasDebugCallStack => Name -> TcM TcTyCon
- tcLookupLcl_maybe :: Name -> TcM (Maybe TcTyThing)
- getInLocalScope :: TcM (Name -> Bool)
- wrongThingErr :: String -> TcTyThing -> Name -> TcM a
- pprBinders :: [Name] -> SDoc
- tcAddDataFamConPlaceholders :: [LInstDecl GhcRn] -> TcM a -> TcM a
- tcAddPatSynPlaceholders :: [PatSynBind GhcRn GhcRn] -> TcM a -> TcM a
- getTypeSigNames :: [LSig GhcRn] -> NameSet
- tcExtendRecEnv :: [(Name, TyThing)] -> TcM r -> TcM r
- tcInitTidyEnv :: TcM TidyEnv
- tcInitOpenTidyEnv :: [TyCoVar] -> TcM TidyEnv
- tcLookupInstance :: Class -> [Type] -> TcM ClsInst
- tcGetInstEnvs :: TcM InstEnvs
- tcExtendRules :: [LRuleDecl GhcTc] -> TcM a -> TcM a
- tcGetDefaultTys :: TcM ([Type], (Bool, Bool))
- checkWellStaged :: SDoc -> ThLevel -> ThLevel -> TcM ()
- tcMetaTy :: Name -> TcM Type
- thLevel :: ThStage -> ThLevel
- topIdLvl :: Id -> ThLevel
- isBrackStage :: ThStage -> Bool
- newDFunName :: Class -> [Type] -> SrcSpan -> TcM Name
- newFamInstTyConName :: LocatedN Name -> [Type] -> TcM Name
- newFamInstAxiomName :: LocatedN Name -> [[Type]] -> TcM Name
- mkStableIdFromString :: String -> Type -> SrcSpan -> (OccName -> OccName) -> TcM TcId
- mkStableIdFromName :: Name -> Type -> SrcSpan -> (OccName -> OccName) -> TcM TcId
- mkWrapperName :: (MonadIO m, HasModule m) => IORef (ModuleEnv Int) -> String -> String -> m FastString

# Documentation

data TyThing Source #

A global typecheckable-thing, essentially anything that has a name. Not to be confused with a `TcTyThing`, which is also a typecheckable thing but in the *local* context. See GHC.Tc.Utils.Env for how to retrieve a `TyThing` given a `Name`.

Constructors

AnId Id |
AConLike ConLike |
ATyCon TyCon |
ACoAxiom (CoAxiom Branched) |

#### Instances

Instances details

NamedThing TyThing Source # |
Instance details Defined in GHC.Types.TyThing Methods getOccName :: TyThing -> OccName Source # getName :: TyThing -> Name Source #
Outputable TyThing Source # |
Instance details Defined in GHC.Types.TyThing Methods ppr :: TyThing -> SDoc Source #

data TcTyThing Source #

A typecheckable thing available in a local context. Could be `AGlobal` `TyThing`, but also lexically scoped variables, etc. See GHC.Tc.Utils.Env for how to retrieve a `TyThing` given a `Name`.

Constructors

AGlobal TyThing |
ATcId |

Fields

- tct_id :: TcId
- tct_info :: IdBindingInfo

ATyVar Name TcTyVar |
ATcTyCon TyCon |
APromotionErr PromotionErr |

#### Instances

Instances details

Outputable TcTyThing Source # |
Instance details Defined in GHC.Tc.Types Methods ppr :: TcTyThing -> SDoc Source #

type TcId = Id Source #

data InstInfo a Source #

Constructors

InstInfo |

Fields

- iSpec :: ClsInst
- iBinds :: InstBindings a

#### Instances

Instances details

OutputableBndrId a => Outputable (InstInfo (GhcPass a)) Source # |
Instance details Defined in GHC.Tc.Utils.Env Methods ppr :: InstInfo (GhcPass a) -> SDoc Source #

iDFunId :: InstInfo a -> DFunId Source #

pprInstInfoDetails :: OutputableBndrId a => InstInfo (GhcPass a) -> SDoc Source #

simpleInstInfoClsTy :: InstInfo a -> (Class, Type) Source #

simpleInstInfoTy :: InstInfo a -> Type Source #

simpleInstInfoTyCon :: InstInfo a -> TyCon Source #

data InstBindings a Source #

Constructors

InstBindings |

Fields

- ib_tyvars :: [Name]
- ib_binds :: LHsBinds a
- ib_pragmas :: [LSig a]
- ib_extensions :: [Extension]
- ib_derived :: Bool

tcExtendGlobalEnv :: [TyThing] -> TcM r -> TcM r Source #

tcExtendTyConEnv :: [TyCon] -> TcM r -> TcM r Source #

tcExtendGlobalEnvImplicit :: [TyThing] -> TcM r -> TcM r Source #

setGlobalTypeEnv :: TcGblEnv -> TypeEnv -> TcM TcGblEnv Source #

tcExtendGlobalValEnv :: [Id] -> TcM a -> TcM a Source #

tcTyThBinders :: [TyThing] -> TcM ThBindEnv Source #

tcLookupLocatedGlobal :: LocatedA Name -> TcM TyThing Source #

tcLookupGlobal :: Name -> TcM TyThing Source #

tcLookupGlobalOnly :: Name -> TcM TyThing Source #

tcLookupTyCon :: Name -> TcM TyCon Source #

tcLookupClass :: Name -> TcM Class Source #

tcLookupDataCon :: Name -> TcM DataCon Source #

tcLookupPatSyn :: Name -> TcM PatSyn Source #

tcLookupConLike :: Name -> TcM ConLike Source #

tcLookupLocatedGlobalId :: LocatedA Name -> TcM Id Source #

tcLookupLocatedTyCon :: LocatedN Name -> TcM TyCon Source #

tcLookupLocatedClass :: LocatedA Name -> TcM Class Source #

tcLookupAxiom :: Name -> TcM (CoAxiom Branched) Source #

lookupGlobal :: HscEnv -> Name -> IO TyThing Source #

lookupGlobal_maybe :: HscEnv -> Name -> IO (MaybeErr SDoc TyThing) Source #

ioLookupDataCon :: HscEnv -> Name -> IO DataCon Source #

addTypecheckedBinds :: TcGblEnv -> [LHsBinds GhcTc] -> TcGblEnv Source #

tcExtendKindEnv :: NameEnv TcTyThing -> TcM r -> TcM r Source #

tcExtendKindEnvList :: [(Name, TcTyThing)] -> TcM r -> TcM r Source #

tcExtendTyVarEnv :: [TyVar] -> TcM r -> TcM r Source #

tcExtendNameTyVarEnv :: [(Name, TcTyVar)] -> TcM r -> TcM r Source #

tcExtendLetEnv :: TopLevelFlag -> TcSigFun -> IsGroupClosed -> [TcId] -> TcM a -> TcM a Source #

tcExtendSigIds :: TopLevelFlag -> [TcId] -> TcM a -> TcM a Source #

tcExtendRecIds :: [(Name, TcId)] -> TcM a -> TcM a Source #

tcExtendIdEnv :: [TcId] -> TcM a -> TcM a Source #

tcExtendIdEnv1 :: Name -> TcId -> TcM a -> TcM a Source #

tcExtendIdEnv2 :: [(Name, TcId)] -> TcM a -> TcM a Source #

tcExtendBinderStack :: [TcBinder] -> TcM a -> TcM a Source #

tcExtendLocalTypeEnv :: TcLclEnv -> [(Name, TcTyThing)] -> TcLclEnv Source #

isTypeClosedLetBndr :: Id -> Bool Source #

tcCheckUsage :: Name -> Mult -> TcM a -> TcM (a, HsWrapper) Source #

`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.

tcLookup :: Name -> TcM TcTyThing Source #

tcLookupLocated :: LocatedA Name -> TcM TcTyThing Source #

tcLookupLocalIds :: [Name] -> TcM [TcId] Source #

tcLookupId :: Name -> TcM Id Source #

tcLookupIdMaybe :: Name -> TcM (Maybe Id) Source #

tcLookupTyVar :: Name -> TcM TcTyVar Source #

tcLookupTcTyCon :: HasDebugCallStack => Name -> TcM TcTyCon Source #

tcLookupLcl_maybe :: Name -> TcM (Maybe TcTyThing) Source #

getInLocalScope :: TcM (Name -> Bool) Source #

wrongThingErr :: String -> TcTyThing -> Name -> TcM a Source #

pprBinders :: [Name] -> SDoc Source #

tcAddDataFamConPlaceholders :: [LInstDecl GhcRn] -> TcM a -> TcM a Source #

tcAddPatSynPlaceholders :: [PatSynBind GhcRn GhcRn] -> TcM a -> TcM a Source #

getTypeSigNames :: [LSig GhcRn] -> NameSet Source #

tcExtendRecEnv :: [(Name, TyThing)] -> TcM r -> TcM r Source #

tcInitTidyEnv :: TcM TidyEnv Source #

tcInitOpenTidyEnv :: [TyCoVar] -> TcM TidyEnv Source #

Get a `TidyEnv` that includes mappings for all vars free in the given type. Useful when tidying open types.

tcLookupInstance :: Class -> [Type] -> TcM ClsInst Source #

tcGetInstEnvs :: TcM InstEnvs Source #

tcExtendRules :: [LRuleDecl GhcTc] -> TcM a -> TcM a Source #

tcGetDefaultTys :: TcM ([Type], (Bool, Bool)) Source #

checkWellStaged :: SDoc -> ThLevel -> ThLevel -> TcM () Source #

tcMetaTy :: Name -> TcM Type Source #

thLevel :: ThStage -> ThLevel Source #

topIdLvl :: Id -> ThLevel Source #

isBrackStage :: ThStage -> Bool Source #

newDFunName :: Class -> [Type] -> SrcSpan -> TcM Name Source #

Make a name for the dict fun for an instance decl. It's an *external* name, like other top-level names, and hence must be made with newGlobalBinder.

newFamInstTyConName :: LocatedN Name -> [Type] -> TcM Name Source #

newFamInstAxiomName :: LocatedN Name -> [[Type]] -> TcM Name Source #

mkStableIdFromString :: String -> Type -> SrcSpan -> (OccName -> OccName) -> TcM TcId Source #

mkStableIdFromName :: Name -> Type -> SrcSpan -> (OccName -> OccName) -> TcM TcId Source #

mkWrapperName :: (MonadIO m, HasModule m) => IORef (ModuleEnv Int) -> String -> String -> m FastString Source #

    mkWrapperName ref what nameBase

See Note [Generating fresh names for FFI wrappers] for `ref`'s purpose.

# Orphan instances

MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) Source # |
Instance details Methods lookupThing :: Name -> IOEnv (Env TcGblEnv TcLclEnv) TyThing Source # lookupId :: Name -> IOEnv (Env TcGblEnv TcLclEnv) Id Source # lookupDataCon :: Name -> IOEnv (Env TcGblEnv TcLclEnv) DataCon Source # lookupTyCon :: Name -> IOEnv (Env TcGblEnv TcLclEnv) TyCon Source #