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

  • PackageAgda-2.7.0.1
  • Exports132
  • LanguageHaskell2010
  • LicenceMIT
  • SourceBase.hs

Scope representation

36 declarations
datadata Scope
#

A scope is a named collection of names partitioned into public and private names.

Instances9Eq, Show, Generic, NFData, Pretty, Null, …
datadata DataOrRecordModule
#
Instances8Bounded, Enum, Eq, Show, Generic, NFData, …
datadata NameSpaceId
#

See Access.

Constructors

  • PrivateNS

    Things not exported by this module.

  • PublicNS

    Things defined and exported by this module.

  • ImportedNS

    Things from open public, exported by this module.

Instances9Bounded, Enum, Eq, Show, Generic, NFData, …
datadata ScopeInfo
#

The complete information about the scope at a particular program point includes the scope stack, the local variables, and the context precedence.

Constructors

Instances9Eq, Show, Generic, NFData, Pretty, Null, …
datadata NameMapEntry
#

For the sake of highlighting, the _scopeInverseName map also stores the KindOfName of an A.QName.

Constructors

Instances5Show, Generic, Semigroup, NFData, Rep
datadata BindingSource
#

For each bound variable, we want to know whether it was bound by a λ, Π, module telescope, pattern, or let.

Constructors

  • LambdaBound

    λ (currently also used for Π and module parameters)

  • PatternBound Hiding

    f ... =. Remember Hiding for pattern variables {x} and {{x}}. This information is only used for checking pattern synonyms. It is not serialized.

  • LetBound
    let ... in
  • WithBound
    | ... in q
Instances7Eq, Show, Generic, NFData, Pretty, EmbPrj, …
datadata LocalVar
#

A local variable can be shadowed by an import. In case of reference to a shadowed variable, we want to report a scope error.

Constructors

Instances8Eq, Ord, Show, Generic, NFData, Pretty, …

Name spaces

9 declarations
datadata NameSpace
#

A NameSpace contains the mappings from concrete names that the user can write to the abstract fully qualified names that the type checker wants to read.

Constructors

Instances7Eq, Show, Generic, NFData, Pretty, EmbPrj, …
datadata NameOrModule
#

Non-dependent tag for name or module.

Instances9Bounded, Enum, Eq, Ord, Show, Generic, …

Decorated names

25 declarations
datadata KindOfName
#

For the sake of parsing left-hand sides, we distinguish constructor and record field names from defined names.

Constructors

Instances9Bounded, Enum, Eq, Ord, Show, Generic, …
datadata WithKind a
#

Decorate something with KindOfName

Instances9Functor, Foldable, Traversable, DeclaredNames, Collection, Singleton, …
datadata WhyInScope
#

Where does a name come from?

This information is solely for reporting to the user, see whyInScope.

Constructors

Instances5Show, Generic, NFData, EmbPrj, Rep
datadata AbstractName
#

A decoration of QName.

Constructors

Instances18Eq, Ord, Show, Generic, NFData, Pretty, …
datadata NameMetadata
#
Instances5Show, Generic, NFData, EmbPrj, Rep
datadata AbstractModule
#

A decoration of abstract syntax module names.

Constructors

Instances10Eq, Ord, Show, Generic, NFData, Pretty, …
datadata ResolvedName
#

Constructors

Instances10Eq, Show, Generic, NFData, Pretty, ToConcrete, …
datadata AmbiguousNameReason
#

Why is a resolved name ambiguous? What did it resolve to?

Invariant (statically enforced): At least two resolvents in total.

Constructors

Instances4Show, Generic, NFData, Rep

Operations on name and module maps.

2 declarations

Operations on name spaces

4 declarations

General operations on scopes

20 declarations
valuefilterScope :: (Name -> Bool) -> (Name -> Bool) -> Scope -> Scope
#

Filter a scope keeping only concrete names matching the predicates. The first predicate is applied to the names and the second to the modules.

valuefindNameInScope :: InScope a => Name -> Scope -> [(a, Access)]
#

Look up a single name in the current scope.

This is equivalent to Map.lookup n . allNamesInScope', but more efficient when only a single name needs to be looked up.

valuemergeScopes :: [Scope] -> Scope
#

Merge a non-empty list of scopes. The result has the name of the first scope in the list.

Specific operations on scopes

24 declarations

Remove a name from a scope. Caution: does not update the nsInScope set. This is only used by rebindName and in that case we add the name right back (but with a different kind).

Apply an ImportDirective to a scope:

  1. rename keys (C.Name) according to renaming;

  2. for untouched keys, either of

a) remove keys according to hiding, or b) filter keys according to using.

Both steps could be done in one pass, by first preparing key-filtering functions C.Name -> Maybe C.Name for defined names and module names. However, the penalty of doing it in two passes should not be too high. (Doubling the run time.)

Inverse look-up

9 declarations

Find the concrete names that map (uniquely) to a given abstract qualified name. Sort by number of modules in the qualified name, unqualified names first.

Update binding site

1 declaration
classclass SetBindingSite a where
#

Set the nameBindingSite in an abstract name.

Methods

Instances7SetBindingSite, …

(Debug) printing

2 declarations

Boring instances

0 declarations

Orphan instances

1 instance