HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

ModuleAgda-2.8.0.2Haskell2010

Agda.Syntax.Scope.Base

This module defines the notion of a scope and operations on scopes.

Contents
  1. Scope representation
  2. Name spaces
  3. Decorated names
  4. Operations on name and module maps.
  5. Operations on name spaces
  6. General operations on scopes
  7. Specific operations on scopes
  8. Inverse look-up
  9. Update binding site
  10. (Debug) printing
  11. Boring instances
Synopsis
  • PackageAgda-2.8.0.2
  • Exports136
  • LanguageHaskell2010
  • LicenceMIT
  • SourceBase.hs

Scope representation

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
  • MacroBound

    Binding added to scope by one of context-manipulating reflection primitives

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

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

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

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

Instances11Eq, Show, Generic, NFData, Pretty, ToConcrete, …

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

A failure in name resolution, indicating the reason that a name which is in scope could not be returned from tryResolveName.

Constructors

Instances3Show, Generic, Rep

Operations on name and module maps.

Operations on name spaces

General operations on scopes

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.

Specific operations on scopes

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

Update binding site

classclass SetBindingSite a where

Set the nameBindingSite in an abstract name.

Methods

Instances7SetBindingSite, …

(Debug) printing

Boring instances

Orphan instances

1 instance