HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

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
  • 137 values
  • Packageghc-9.10.3
  • Exports144
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceOccurrence.hs

The NameSpace type

1 declaration

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

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

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

30 declarations
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

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