HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleghc-10.0.0.20260917GHC2024

GHC.Types.Name

GHC uses several kinds of name internally:

  • OccName: see GHC.Types.Name.Occurrence#name_types

  • RdrName: see GHC.Types.Name.Reader#name_types

  • Name is the type of names that have had their scoping and binding resolved. They have an OccName but also a Unique that disambiguates Names that have the same OccName and indeed is used for all Name comparison. Names also contain information about where they originated from, see GHC.Types.Name#name_sorts

  • GHC.Types.Id.Id: see GHC.Types.Id#name_types

  • Var: see GHC.Types.Var#name_types

Names are one of:

  • External, if they name things declared in other modules. Some external Names are wired in, i.e. they name primitives defined in the compiler itself

  • Internal, if they name things in the module being compiled. Some internal Names are system names, if they are names manufactured by the compiler

  • 2 types
  • 1 class
  • 62 values

The main types

2 declarations
datadata Name
#

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

    The same comments as for Name's Ord instance apply.

  • Data NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name
  • Ord NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name

    Caution: 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.Name
  • NamedThing NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name
  • Outputable NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name
  • Uniquable NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name
  • Binary NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name

    Assumes that the Name is a non-binding one. See putIfaceTopBndr and getIfaceTopBndr for serializing binding Names. See UserData for the rationale for this distinction.

  • OutputableBndr NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name
  • HasOccName NameDefined in ghc-10.0.0.20260917 · GHC.Types.Name
  • ModifyState NameDefined in ghc-10.0.0.20260917 · GHC.Iface.Ext.Ast
  • Outputable (WithUserRdr Name)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.Reader
  • OutputableBndr (WithUserRdr Name)Defined in ghc-10.0.0.20260917 · GHC.Types.Name.Reader
  • ToHie (Context (Located Name))Defined in ghc-10.0.0.20260917 · GHC.Iface.Ext.Ast
  • ToHie (Context (Located (WithUserRdr Name)))Defined in ghc-10.0.0.20260917 · GHC.Iface.Ext.Ast
  • type Anno Name = SrcSpanAnnNDefined in ghc-10.0.0.20260917 · GHC.Hs.Extension · orphan

Creating Names

Manipulating and deconstructing Names

valuepprTickyName :: Module -> Name -> SDoc
#

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.

Predicates on Names

valuenameIsLocalOrFrom :: Module -> Name -> Bool
#

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

valuestableNameCmp :: Name -> Name -> Ordering
#

Compare Names lexicographically This only works for Names that originate in the source code or have been tidied.

Class NamedThing and overloaded friends

10 declarations
classclass NamedThing a where
#

A class allowing convenient access to the Name of various datatypes

Methods

Instances21NamedThing, …
valuenameStableString :: Name -> String
#

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"

Orphan instances

1 instance