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

Modulelanguage-c-0.9.3Haskell2010

Language.C.Analysis.NameSpaceMap

This module manages name spaces.

  • A name space map associates identifiers with their definition.

  • Each name space map is organized in a hierarchical way using the notion of scopes. A name space map, at any moment, always has a global scope and may have several local scopes. Definitions in inner scopes hide definitions of the same identifier in outer scopes.

  • 1 type
  • 13 values
  • Packagelanguage-c-0.9.3
  • Exports14
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceNameSpaceMap.hs

name space maps

6 declarations
datadata NameSpaceMap k v
#

NameSpaceMap a is a Map from identifiers to a, which manages global and local name spaces.

valuensMapToList :: Ord k => NameSpaceMap k a -> [(k, a)]
#

flatten a namespace into a assoc list

nameSpaceToList ns = (localDefInnermost ns ++ .. ++ localDefsOutermost ns) ++ globalDefs ns

scope modification

8 declarations
valuedefGlobal
  1. :: Ord k
  2. => NameSpaceMap k a
  3. -> k
  4. -> a
  5. -> (NameSpaceMap k a, Maybe a)
#

Add global definition

(ns',oldDef) = defGlobal ns ident def adds a global definition ident := def to the namespace. It returns the modified namespace ns'. If the identifier is already declared in the global namespace, the definition is overwritten and the old definition oldDef is returned.

valueleaveScope :: Ord k => NameSpaceMap k a -> (NameSpaceMap k a, [(k, a)])
#

Leave innermost local scope

(ns',defs) = leaveScope ns pops leaves the innermost local scope. and returns its definitions

valuedefLocal
  1. :: Ord k
  2. => NameSpaceMap k a
  3. -> k
  4. -> a
  5. -> (NameSpaceMap k a, Maybe a)
#

Add local definition

(ns',oldDef) = defLocal ns ident def adds the local definition ident := def to the innermost local scope, if there is a local scope, and to the global scope otherwise. It returns the modified name space ns' and the old binding of the identifier oldDef, which is overwritten.

valuelookupName :: Ord k => NameSpaceMap k a -> k -> Maybe a
#

Search for a definition

def = find ns ident returns the definition in some scope (inner to outer), if there is one.