ghc-lib-parser-9.10.1.20250103: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
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 #

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 # |
Instance details Defined in GHC.Types.TyThing Methods getOccName :: TyThing -> OccName # getName :: TyThing -> Name #
Outputable TyThing # |
Instance details Defined in GHC.Types.TyThing Methods ppr :: TyThing -> SDoc #

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

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 #

lookupId :: Name -> m Id #

lookupDataCon :: Name -> m DataCon #

lookupTyCon :: Name -> m TyCon #

#### Instances

Instances details

MonadThings m => MonadThings (ReaderT s m) # |
Instance details Defined in GHC.Types.TyThing Methods lookupThing :: Name -> ReaderT s m TyThing # lookupId :: Name -> ReaderT s m Id # lookupDataCon :: Name -> ReaderT s m DataCon # lookupTyCon :: Name -> ReaderT s m TyCon #

mkATyCon :: TyCon -> TyThing #

mkAnId :: Id -> TyThing #

pprShortTyThing :: TyThing -> SDoc #

pprTyThingCategory :: TyThing -> SDoc #

tyThingCategory :: TyThing -> String #

implicitTyThings :: TyThing -> [TyThing] #

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

implicitClassThings :: Class -> [TyThing] #

implicitTyConThings :: TyCon -> [TyThing] #

implicitCoTyCon :: TyCon -> [TyThing] #

isImplicitTyThing :: TyThing -> Bool #

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 #

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 #

tyThingLocalGREs :: TyThing -> [GlobalRdrElt] #

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

tyThingGREInfo :: TyThing -> GREInfo #

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

This extracts out renamer information from typechecker information.

tyThingTyCon :: HasDebugCallStack => TyThing -> TyCon #

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

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

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

tyThingDataCon :: HasDebugCallStack => TyThing -> DataCon #

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

tyThingConLike :: HasDebugCallStack => TyThing -> ConLike #

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

tyThingId :: HasDebugCallStack => TyThing -> Id #

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