HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

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
  • 60 values
  • Packageghc-9.10.3
  • Exports63
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceName.hs

The main types

2 declarations
datadata Name
#

A unique, unambiguous name for something, containing information about where that thing originated.

Instances14Eq, Data, Ord, NFData, NamedThing, Outputable, …

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

Instances20NamedThing, …
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