| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Agda.Syntax.Scope.Monad
Contents
Description
The scope monad with operations.
Synopsis
- addNameToInverseScope :: KindOfName -> Name -> AbstractName -> ScopeInfo -> ScopeInfo
- addVarToBind :: Name -> LocalVar -> ScopeM ()
- annotateDecls :: ReadTCState m => m [Declaration] -> m (Maybe Declaration)
- annotateExpr :: ReadTCState m => m Expr -> m Expr
- applyImportDirectiveM :: QName -> ImportDirective -> Scope -> ScopeM (ImportDirective, Scope)
- bindModule :: Access -> Name -> ModuleName -> ScopeM ()
- bindName :: Access -> KindOfName -> Name -> QName -> ScopeM ()
- bindName' :: Access -> KindOfName -> NameMetadata -> Name -> QName -> ScopeM ()
- bindName'' :: Access -> KindOfName -> NameMetadata -> Name -> QName -> ScopeM (Maybe TypeError)
- bindQModule :: Access -> QName -> ModuleName -> ScopeM ()
- bindRecordConstructorPseudoName :: ModuleName -> KindOfName -> QName -> ScopeM ()
- bindVariable :: BindingSource -> Name -> Name -> ScopeM ()
- bindVarsToBind :: ScopeM ()
- canHaveSuffixTest :: HasBuiltins m => m (QName -> Bool)
- checkNoFixityForClosedOperator :: [Renaming] -> ScopeM ()
- checkNoFixityInRenamingModule :: [Renaming] -> ScopeM ()
- checkNoShadowing :: LocalVars -> LocalVars -> ScopeM ()
- computeFixitiesAndPolarities :: DoWarn -> [Declaration] -> ScopeM a -> ScopeM a
- copyName :: QName -> QName -> ScopeM ()
- copyScope :: QName -> ModuleName -> Scope -> ScopeM (Scope, ScopeCopyInfo)
- createModule :: Maybe DataOrRecordModule -> ModuleName -> ScopeM ()
- dropRecordConstructorPseudoName :: Scope -> Scope
- freshAbstractName :: Fixity' -> Name -> ScopeM Name
- freshAbstractName_ :: Name -> ScopeM Name
- freshAbstractQName :: Fixity' -> Name -> ScopeM QName
- freshAbstractQName' :: Name -> ScopeM QName
- freshConcreteName :: Range -> Int -> String -> ScopeM Name
- getConcreteFixity :: Name -> ScopeM Fixity'
- getConcretePolarity :: Name -> ScopeM (Maybe PragmaPolarities)
- getCurrentScope :: ScopeM Scope
- getLocalVars :: ReadTCState m => m LocalVars
- getNamedScope :: ModuleName -> ScopeM Scope
- getNotation :: QName -> Set1 Name -> ScopeM NewNotation
- getVarsToBind :: ScopeM LocalVars
- importedNameMapFromList :: (Ord n1, Ord m1) => [ImportedName' (n1, n2) (m1, m2)] -> ImportedNameMap n1 n2 m1 m2
- isDatatypeModule :: ReadTCState m => ModuleName -> m (Maybe DataOrRecordModule)
- isRecordConstructor :: QName -> Maybe QName
- lookupImportedName :: (Ord n1, Ord m1) => ImportedNameMap n1 n2 m1 m2 -> ImportedName' n1 m1 -> ImportedName' n2 m2
- mapImportDir :: (Ord n1, Ord m1) => [ImportedName' (n1, n2) (m1, m2)] -> [ImportedName' (n1, n2) (m1, m2)] -> ImportDirective' n1 m1 -> ImportDirective' n2 m2
- mapRenaming :: (Ord n1, Ord m1) => ImportedNameMap n1 n2 m1 m2 -> ImportedNameMap n1 n2 m1 m2 -> Renaming' n1 m1 -> Renaming' n2 m2
- memoToScopeInfo :: ScopeMemo -> ScopeCopyInfo
- modifyCurrentScope :: (Scope -> Scope) -> ScopeM ()
- modifyLocalVars :: (LocalVars -> LocalVars) -> ScopeM ()
- modifyNamedScope :: ModuleName -> (Scope -> Scope) -> ScopeM ()
- modifyScopes :: (Map ModuleName Scope -> Map ModuleName Scope) -> ScopeM ()
- noGeneralizedVarsIfLetOpen :: OpenKind -> Scope -> Scope
- openModule :: KwRange -> OpenKind -> Maybe ModuleName -> QName -> ImportDirective -> ScopeM ImportDirective
- openModule_ :: KwRange -> OpenKind -> QName -> ImportDirective -> ScopeM ImportDirective
- outsideLocalVars :: Int -> ScopeM a -> ScopeM a
- printLocals :: Int -> String -> ScopeM ()
- rebindName :: Access -> KindOfName -> NameMetadata -> Name -> QName -> ScopeM ()
- recordConstructorPseudoName :: Name
- resolveModule :: QName -> ScopeM AbstractModule
- resolveName :: QName -> ScopeM ResolvedName
- resolveName' :: KindsOfNames -> Maybe (Set1 Name) -> QName -> ScopeM ResolvedName
- scopeWarning :: HasCallStack => DeclarationWarning' -> ScopeM ()
- scopeWarning' :: CallStack -> DeclarationWarning' -> ScopeM ()
- setContextPrecedence :: PrecedenceStack -> ScopeM ()
- setLocalVars :: LocalVars -> ScopeM ()
- stripNoNames :: ScopeM ()
- tryResolveName :: (ReadTCState m, HasBuiltins m, MonadError NameResolutionError m) => KindsOfNames -> Maybe (Set1 Name) -> QName -> m ResolvedName
- unbindVariable :: Name -> ScopeM a -> ScopeM a
- withCheckNoShadowing :: ScopeM a -> ScopeM a
- withContextPrecedence :: ReadTCState m => Precedence -> m a -> m a
- withLocalVars :: ScopeM a -> ScopeM a
- data ImportedNameMap n1 n2 m1 m2 = ImportedNameMap {
- inameMap :: Map n1 n2
- imoduleMap :: Map m1 m2
- data OpenKind
- data ScopeMemo = ScopeMemo {
- memoNames :: Ren QName
- memoModules :: Map ModuleName (ModuleName, Bool)
- type WSM = StateT ScopeMemo ScopeM
- module Agda.Syntax.Scope.State
Documentation
addNameToInverseScope :: KindOfName -> Name -> AbstractName -> ScopeInfo -> ScopeInfo Source #
annotateDecls :: ReadTCState m => m [Declaration] -> m (Maybe Declaration) Source #
annotateExpr :: ReadTCState m => m Expr -> m Expr Source #
applyImportDirectiveM Source #
Arguments
| :: QName | Name of the scope, only for error reporting. |
| -> ImportDirective | Description of how scope is to be modified. |
| -> Scope | Input scope. |
| -> ScopeM (ImportDirective, Scope) | Scope-checked description, output scope. |
Apply an import directive and check that all the names mentioned actually exist.
Monadic for the sake of error reporting.
bindModule :: Access -> Name -> ModuleName -> ScopeM () Source #
Bind a module name.
bindName :: Access -> KindOfName -> Name -> QName -> ScopeM () Source #
Bind a defined name. Must not shadow anything.
bindName' :: Access -> KindOfName -> NameMetadata -> Name -> QName -> ScopeM () Source #
bindName'' :: Access -> KindOfName -> NameMetadata -> Name -> QName -> ScopeM (Maybe TypeError) Source #
Bind a name. Returns the TypeError if exists, but does not throw it.
bindQModule :: Access -> QName -> ModuleName -> ScopeM () Source #
Bind a qualified module name. Adds it to the imports field of the scope.
bindRecordConstructorPseudoName :: ModuleName -> KindOfName -> QName -> ScopeM () Source #
Bind the pseudo-name constructor in the scope of the record module,
mapping it to the (possibly anonymous) constructor of the record.
This is what makes R.constructor resolve: R is the record module
and constructor an ordinary name in it, so no special treatment is
needed when resolving the qualified name R.constructor.
Note that constructor is a keyword, thus, it can never be parsed
as an unqualified name. In particular, open R does not make the
record constructor accessible under the name constructor, and
constructor cannot be mentioned in using, hiding or renaming.
This does not put the record constructor itself into the record module (which would be wrong, see issue #4189, since the record module is parameterized over the record value, but the constructor is not); it only adds this alias for it.
Arguments
| :: BindingSource |
|
| -> Name | Concrete name. |
| -> Name | Abstract name. |
| -> ScopeM () |
Bind a variable.
bindVarsToBind :: ScopeM () Source #
After collecting some variable names in the scopeVarsToBind, bind them all simultaneously.
canHaveSuffixTest :: HasBuiltins m => m (QName -> Bool) Source #
Test if a given abstract name can appear with a suffix. Currently only true for the names of builtin sorts.
checkNoFixityForClosedOperator :: [Renaming] -> ScopeM () Source #
Warn about fixity declarations for targets that are non-operators or closed operators:
checkNoFixityInRenamingModule :: [Renaming] -> ScopeM () Source #
Warn about useless fixity declarations in renaming directives.
Monadic for the sake of error reporting.
computeFixitiesAndPolarities :: DoWarn -> [Declaration] -> ScopeM a -> ScopeM a Source #
Collect the fixity/syntax declarations and polarity pragmas from the list of declarations and store them in the scope.
copyName :: QName -> QName -> ScopeM () Source #
Mark a name as being a copy in the TC state, associating it with
the given ScopeCopyRef for liveness information.
copyScope :: QName -> ModuleName -> Scope -> ScopeM (Scope, ScopeCopyInfo) Source #
Create a new scope with the given name from an old scope. Renames public names in the old scope to match the new name and returns the renamings.
createModule :: Maybe DataOrRecordModule -> ModuleName -> ScopeM () Source #
Create a new module with an empty scope.
If the module is not new (e.g. duplicate import),
don't erase its contents.
(Just if it is a datatype or record module.)
dropRecordConstructorPseudoName :: Scope -> Scope Source #
Remove the record constructor pseudo-name from the scope of a record module.
The alias constructor is only meant to be used in the qualified form
R.constructor, where R is the record module. Thus, it is not brought
into scope by open R.
It is also not copied when the record module R itself is applied to
arguments (as in module M = R): the record module is parameterized over
the record value, but the record constructor is not (issue #4189).
(When R is only copied as a submodule of the applied module, the
constructor is copied correctly, since the arguments are then taken from
the enclosing module.)
freshAbstractName :: Fixity' -> Name -> ScopeM Name Source #
Create a fresh abstract name from a concrete name.
This function is used when we translate a concrete name
in a binder. The Range of the concrete name is
saved as the nameBindingSite of the abstract name.
freshAbstractQName :: Fixity' -> Name -> ScopeM QName Source #
Create a fresh abstract qualified name.
freshConcreteName :: Range -> Int -> String -> ScopeM Name Source #
Create a concrete name that is not yet in scope.
| NOTE: See chooseName in Agda.Syntax.Translation.AbstractToConcrete for similar logic.
| NOTE: See withName in Agda.Syntax.Translation.ReflectedToAbstract for similar logic.
getConcretePolarity :: Name -> ScopeM (Maybe PragmaPolarities) Source #
Get the polarities of a not yet bound name.
getLocalVars :: ReadTCState m => m LocalVars Source #
getNamedScope :: ModuleName -> ScopeM Scope Source #
Arguments
| :: QName | |
| -> Set1 Name | The name must correspond to one of the names in this set. |
| -> ScopeM NewNotation |
Get the notation of a name. The name is assumed to be in scope.
importedNameMapFromList :: (Ord n1, Ord m1) => [ImportedName' (n1, n2) (m1, m2)] -> ImportedNameMap n1 n2 m1 m2 Source #
Create a ImportedNameMap.
isDatatypeModule :: ReadTCState m => ModuleName -> m (Maybe DataOrRecordModule) Source #
isRecordConstructor :: QName -> Maybe QName Source #
Is this the qualified name which refers to the constructor of a
record (like Foo.constructor)?
If so, return the part of the name referring to the record (Foo).
This is only used to produce a good error message when Foo.constructor
does not resolve; the resolution itself goes through the ordinary
scope lookup, see bindRecordConstructorPseudoName.
lookupImportedName :: (Ord n1, Ord m1) => ImportedNameMap n1 n2 m1 m2 -> ImportedName' n1 m1 -> ImportedName' n2 m2 Source #
Apply a ImportedNameMap.
Arguments
| :: (Ord n1, Ord m1) | |
| => [ImportedName' (n1, n2) (m1, m2)] | Translation of imported names. |
| -> [ImportedName' (n1, n2) (m1, m2)] | Translation of names defined by this import. |
| -> ImportDirective' n1 m1 | |
| -> ImportDirective' n2 m2 |
Translation of ImportDirective.
Arguments
| :: (Ord n1, Ord m1) | |
| => ImportedNameMap n1 n2 m1 m2 | Translation of |
| -> ImportedNameMap n1 n2 m1 m2 | Translation of |
| -> Renaming' n1 m1 | Renaming before translation (1). |
| -> Renaming' n2 m2 | Renaming after translation (2). |
Translation of Renaming.
modifyNamedScope :: ModuleName -> (Scope -> Scope) -> ScopeM () Source #
Apply a function to the given scope.
modifyScopes :: (Map ModuleName Scope -> Map ModuleName Scope) -> ScopeM () Source #
Apply a function to the scope map.
openModule :: KwRange -> OpenKind -> Maybe ModuleName -> QName -> ImportDirective -> ScopeM ImportDirective Source #
Open a module, possibly given an already resolved module name.
openModule_ :: KwRange -> OpenKind -> QName -> ImportDirective -> ScopeM ImportDirective Source #
Open a module.
outsideLocalVars :: Int -> ScopeM a -> ScopeM a Source #
Run a computation outside some number of local variables and add them back afterwards. This lets you bind variables in the middle of the context and is used when binding generalizable variables (#3735).
rebindName :: Access -> KindOfName -> NameMetadata -> Name -> QName -> ScopeM () Source #
Rebind a name. Use with care!
Ulf, 2014-06-29: Currently used to rebind the name defined by an
unquoteDecl, which is a QuotableName in the body, but a DefinedName
later on.
recordConstructorPseudoName :: Name Source #
The pseudo-name constructor under which the constructor of a record
is bound in the scope of the record module.
Since constructor is a keyword, this name is only reachable
as the tail of a qualified name, e.g., R.constructor.
resolveModule :: QName -> ScopeM AbstractModule Source #
Look up a module in the scope.
resolveName :: QName -> ScopeM ResolvedName Source #
Look up the abstract name referred to by a given concrete name.
resolveName' :: KindsOfNames -> Maybe (Set1 Name) -> QName -> ScopeM ResolvedName Source #
Look up the abstract name corresponding to a concrete name of a certain kind and/or from a given set of names. Sometimes we know already that we are dealing with a constructor or pattern synonym (e.g. when we have parsed a pattern). Then, we can ignore conflicting definitions of that name of a different kind. (See issue 822.)
scopeWarning :: HasCallStack => DeclarationWarning' -> ScopeM () Source #
scopeWarning' :: CallStack -> DeclarationWarning' -> ScopeM () Source #
setContextPrecedence :: PrecedenceStack -> ScopeM () Source #
setLocalVars :: LocalVars -> ScopeM () Source #
stripNoNames :: ScopeM () Source #
Clear the scope of any no names.
Arguments
| :: (ReadTCState m, HasBuiltins m, MonadError NameResolutionError m) | |
| => KindsOfNames | Restrict search to these kinds of names. |
| -> Maybe (Set1 Name) | Unless |
| -> QName | Name to be resolved |
| -> m ResolvedName | If illegally ambiguous, throw error with the ambiguous name. |
unbindVariable :: Name -> ScopeM a -> ScopeM a Source #
Temporarily unbind a variable. Used for non-recursive lets.
withCheckNoShadowing :: ScopeM a -> ScopeM a Source #
Check that the newly added variable have unique names.
withContextPrecedence :: ReadTCState m => Precedence -> m a -> m a Source #
withLocalVars :: ScopeM a -> ScopeM a Source #
Run a computation without changing the local variables.
data ImportedNameMap n1 n2 m1 m2 Source #
A finite map for ImportedNames.
Constructors
| ImportedNameMap | |
Fields
| |
Constructors
| LetOpenModule | |
| TopOpenModule |
Constructors
| ScopeMemo | |
Fields
| |
module Agda.Syntax.Scope.State
Orphan instances
| MonadFixityError ScopeM Source # | |
Methods throwMultipleFixityDecls :: List1 (Name, Pair Fixity') -> ScopeM a Source # throwMultiplePolarityPragmas :: List1 Name -> ScopeM a Source # warnUnknownNamesInFixityDecl :: Set1 Name -> ScopeM () Source # warnUnknownNamesInPolarityPragmas :: Set1 Name -> ScopeM () Source # warnUnknownFixityInMixfixDecl :: Set1 Name -> ScopeM () Source # warnPolarityPragmasButNotPostulates :: Set1 Name -> ScopeM () Source # warnEmptyPolarityPragma :: Range -> ScopeM () Source # warnFixityDeclarationForNonOperator :: Range -> Name -> ScopeM () Source # | |