GHC.Types.TyThing

ghc-9.14.0.20251028: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Types.TyThing

Description

A global typecheckable-thing, essentially anything that has a name.

Synopsis

- data TyThing
  - = AnId Id
  - | AConLike ConLike
  - | ATyCon TyCon
  - | ACoAxiom (CoAxiom Branched)
- class Monad m => MonadThings (m :: Type -> Type) where
  - lookupThing :: Name -> m TyThing
  - lookupId :: Name -> m Id
  - lookupDataCon :: Name -> m DataCon
  - lookupTyCon :: Name -> m TyCon
- mkATyCon :: TyCon -> TyThing
- mkAnId :: Id -> TyThing
- pprShortTyThing :: TyThing -> SDoc
- pprTyThingCategory :: TyThing -> SDoc
- tyThingCategory :: TyThing -> String
- implicitTyThings :: TyThing -> [TyThing]
- implicitConLikeThings :: ConLike -> [TyThing]
- implicitClassThings :: Class -> [TyThing]
- implicitTyConThings :: TyCon -> [TyThing]
- implicitCoTyCon :: TyCon -> [TyThing]
- isImplicitTyThing :: TyThing -> Bool
- tyThingParent_maybe :: TyThing -> Maybe TyThing
- tyThingsTyCoVars :: [TyThing] -> TyCoVarSet
- tyThingLocalGREs :: TyThing -> [GlobalRdrElt]
- tyThingGREInfo :: TyThing -> GREInfo
- tyThingTyCon :: HasDebugCallStack => TyThing -> TyCon
- tyThingCoAxiom :: HasDebugCallStack => TyThing -> CoAxiom Branched
- tyThingDataCon :: HasDebugCallStack => TyThing -> DataCon
- tyThingConLike :: HasDebugCallStack => TyThing -> ConLike
- tyThingId :: HasDebugCallStack => TyThing -> Id

# 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 #

class Monad m => MonadThings (m :: Type -> Type) where Source #

Class that abstracts out the common ability of the monads in GHC to lookup a `TyThing` in the monadic environment by `Name`. Provides a number of related convenience functions for accessing particular kinds of `TyThing`

Minimal complete definition

lookupThing

Methods

lookupThing :: Name -> m TyThing Source #

lookupId :: Name -> m Id Source #

lookupDataCon :: Name -> m DataCon Source #

lookupTyCon :: Name -> m TyCon Source #

#### Instances

Instances details

MonadThings CoreM Source # |
Instance details Defined in GHC.Plugins Methods lookupThing :: Name -> CoreM TyThing Source # lookupId :: Name -> CoreM Id Source # lookupDataCon :: Name -> CoreM DataCon Source # lookupTyCon :: Name -> CoreM TyCon Source #
MonadThings TcS Source # |
Instance details Defined in GHC.Tc.Solver.Monad Methods lookupThing :: Name -> TcS TyThing Source # lookupId :: Name -> TcS Id Source # lookupDataCon :: Name -> TcS DataCon Source # lookupTyCon :: Name -> TcS TyCon Source #
MonadThings (IOEnv (Env DsGblEnv DsLclEnv)) Source # |
Instance details Defined in GHC.HsToCore.Monad Methods lookupThing :: Name -> IOEnv (Env DsGblEnv DsLclEnv) TyThing Source # lookupId :: Name -> IOEnv (Env DsGblEnv DsLclEnv) Id Source # lookupDataCon :: Name -> IOEnv (Env DsGblEnv DsLclEnv) DataCon Source # lookupTyCon :: Name -> IOEnv (Env DsGblEnv DsLclEnv) TyCon Source #
MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) Source # |
Instance details Defined in GHC.Tc.Utils.Env 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 #
MonadThings m => MonadThings (ReaderT s m) Source # |
Instance details Defined in GHC.Types.TyThing Methods lookupThing :: Name -> ReaderT s m TyThing Source # lookupId :: Name -> ReaderT s m Id Source # lookupDataCon :: Name -> ReaderT s m DataCon Source # lookupTyCon :: Name -> ReaderT s m TyCon Source #

mkATyCon :: TyCon -> TyThing Source #

mkAnId :: Id -> TyThing Source #

pprShortTyThing :: TyThing -> SDoc Source #

pprTyThingCategory :: TyThing -> SDoc Source #

tyThingCategory :: TyThing -> String Source #

implicitTyThings :: TyThing -> [TyThing] Source #

Determine the `TyThing`s brought into scope by another `TyThing` other than itself. For example, Id's don't have any implicit TyThings as they just bring themselves into scope, but classes bring their dictionary datatype, type constructor and some selector functions into scope, just for a start!

implicitConLikeThings :: ConLike -> [TyThing] Source #

implicitClassThings :: Class -> [TyThing] Source #

implicitTyConThings :: TyCon -> [TyThing] Source #

implicitCoTyCon :: TyCon -> [TyThing] Source #

isImplicitTyThing :: TyThing -> Bool Source #

Returns `True` if there should be no interface-file declaration for this thing on its own: either it is built-in, or it is part of some other declaration, or it is generated implicitly by some other declaration.

tyThingParent_maybe :: TyThing -> Maybe TyThing Source #

tyThingParent_maybe x returns (Just p) when pprTyThingInContext should print a declaration for p (albeit with some "..." in it) when asked to show x It returns the *immediate* parent. So a datacon returns its tycon but the tycon could be the associated type of a class, so it in turn might have a parent.

tyThingsTyCoVars :: [TyThing] -> TyCoVarSet Source #

tyThingLocalGREs :: TyThing -> [GlobalRdrElt] Source #

The `GlobalRdrElt`s that a `TyThing` should bring into scope. Used to build the `GlobalRdrEnv` for the InteractiveContext.

tyThingGREInfo :: TyThing -> GREInfo Source #

Obtain information pertinent to the renamer about a particular `TyThing`.

This extracts out renamer information from typechecker information.

tyThingTyCon :: HasDebugCallStack => TyThing -> TyCon Source #

Get the `TyCon` from a `TyThing` if it is a type constructor thing. Panics otherwise

tyThingCoAxiom :: HasDebugCallStack => TyThing -> CoAxiom Branched Source #

Get the `CoAxiom` from a `TyThing` if it is a coercion axiom thing. Panics otherwise

tyThingDataCon :: HasDebugCallStack => TyThing -> DataCon Source #

Get the `DataCon` from a `TyThing` if it is a data constructor thing. Panics otherwise

tyThingConLike :: HasDebugCallStack => TyThing -> ConLike Source #

Get the `ConLike` from a `TyThing` if it is a data constructor thing. Panics otherwise

tyThingId :: HasDebugCallStack => TyThing -> Id Source #

Get the `Id` from a `TyThing` if it is a id *or* data constructor thing. Panics otherwise