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

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

Moduleghc-lib-parser-9.14.1.20251220GHC2021

GHC.Types.Name.Occurrence

GHC uses several kinds of name internally:

  • OccName represents names as strings with just a little more information: the "namespace" that the name came from, e.g. the namespace of value, type constructors or data constructors

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

  • Name: see GHC.Types.Name#name_types

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

  • Var: see GHC.Types.Var#name_types

  • 6 types
  • 1 class
  • 140 values

The NameSpace type

1 declaration
datadata NameSpace
#
Instances5Eq, Ord, NFData, Uniquable, Binary
  • Eq NameSpaceDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Ord NameSpaceDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • NFData NameSpaceDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Uniquable NameSpaceDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Binary NameSpaceDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence

Construction

Pretty Printing

The OccName type

3 declarations
datadata OccName
#

Occurrence Name

In this context that means: "classified (i.e. as a type name, value name, etc) but not qualified and not yet resolved"

Instances8Eq, Data, Ord, NFData, Outputable, Binary, …
  • Eq OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Data OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Ord OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • NFData OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Outputable OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Binary OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • OutputableBndr OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • HasOccName OccNameDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence

Construction

valuemkDFunOcc
  1. :: String

    Typically the class and type glommed together e.g. OrdMaybe. Only used in debug mode, for extra clarity

  2. -> Bool

    Is this a hs-boot instance DFun?

  3. -> OccSet

    avoid these Occs

  4. -> OccName

    E.g. $f3OrdMaybe

#
classclass HasOccName name where
#

Other names in the compiler add additional information to an OccName. This class provides a consistent way to access the underlying OccName.

Methods

Instances12HasOccName, …

Derived OccNames

Test for definitions internally generated by GHC. This predicate is used to suppress printing of internal definitions in some debug prints

Is an OccName one of a Typeable TyCon or Module binding? This is needed as these bindings are renamed differently. See Note [Grand plan for Typeable] in GHC.Tc.Instance.Typeable.

valuemkInstTyTcOcc
  1. :: String

    Family name, e.g. Map

  2. -> OccSet

    avoid these Occs

  3. -> OccName
    R:Map
#

Derive a name for the representation type constructor of a data/newtype instance.

Deconstruction

valueisSymOcc :: OccName -> Bool
#

Test if the OccName is that for any operator (whether it is a data constructor or variable or whatever)

valueisValOcc :: OccName -> Bool
#

Value OccNamess are those that are either in the variable, field name or data constructor namespaces

Haskell 98 encourages compilers to suppress warnings about unused names in a pattern if they start with _: this implements that test

The OccEnv type

31 declarations
newtypenewtype OccEnv a
#

A map keyed on OccName. See Note [OccEnv].

Instances3Functor, NFData, Outputable
  • Functor OccEnvDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • NFData a => NFData (OccEnv a)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
  • Outputable a => Outputable (OccEnv a)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Name.Occurrence
valuemkOccEnv_C
  1. :: (a -> a -> a)

    old -> new -> result

  2. -> [(OccName, a)]
  3. -> OccEnv a
#

Create an OccEnv from a list, combining different values with the same OccName using the combining function.

valuenonDetFoldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b
#

Fold over an OccEnv. Non-deterministic, unless the folding function is commutative (i.e. a1 f ( a2 f b ) == a2 f ( a1 f b ) for all a1, a2, b).

The OccSet type

10 declarations

Dealing with main

2 declarations

Tidying up

12 declarations
typetype FastStringEnv a = UniqFM FastString a
#

A non-deterministic set of FastStrings. See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM for explanation why it's not deterministic and why it matters. Use DFastStringEnv if the set eventually gets converted into a list or folded over in a way where the order changes the generated code.