Copyright | 1999 - 2003 Wolfgang Lux 2005 Martin Engelke 2011 - 2012 Björn Peemöller 2016 Finn Teegen |
---|---|
License | BSD-3-clause |
Maintainer | bjp@informatik.uni-kiel.de |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
The module TopEnv
implements environments for qualified and
possibly ambiguous identifiers. An identifier is ambiguous if two
different entities are imported under the same name or if a local
definition uses the same name as an imported entity. Following an idea
presented in a paper by Diatchki, Jones and Hallgren (2002),
an identifier is associated with a list of entities in order to handle
ambiguous names properly.
In general, two entities are considered equal if the names of their original definitions match. However, in the case of algebraic data types it is possible to hide some or all of their data constructors on import and export, respectively. In this case we have to merge both imports such that all data constructors which are visible through any import path are visible in the current module. The class Entity is used to handle this merge.
The code in this module ensures that the list of entities returned by
the functions lookupTopEnv
and qualLookupTopEnv
contains exactly one
element for each imported entity regardless of how many times and
from which module(s) it was imported. Thus, the result of these function
is a list with exactly one element if and only if the identifier is
unambiguous. The module names associated with an imported entity identify
the modules from which the entity was imported.
Synopsis
- newtype TopEnv a = TopEnv {}
- class Entity a where
- emptyTopEnv :: TopEnv a
- predefTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a
- importTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a
- qualImportTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a
- bindTopEnv :: Ident -> a -> TopEnv a -> TopEnv a
- qualBindTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a
- rebindTopEnv :: Ident -> a -> TopEnv a -> TopEnv a
- qualRebindTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a
- unbindTopEnv :: Ident -> TopEnv a -> TopEnv a
- qualUnbindTopEnv :: QualIdent -> TopEnv a -> TopEnv a
- lookupTopEnv :: Ident -> TopEnv a -> [a]
- qualLookupTopEnv :: QualIdent -> TopEnv a -> [a]
- qualElemTopEnv :: QualIdent -> TopEnv a -> Bool
- allImports :: TopEnv a -> [(QualIdent, a)]
- moduleImports :: ModuleIdent -> TopEnv a -> [(Ident, a)]
- localBindings :: TopEnv a -> [(Ident, a)]
- allLocalBindings :: TopEnv a -> [(QualIdent, a)]
- allBindings :: TopEnv a -> [(QualIdent, a)]
- allEntities :: TopEnv a -> [a]
Data types
Top level environment
creation and insertion
emptyTopEnv :: TopEnv a Source #
Empty TopEnv
importTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a Source #
qualImportTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a Source #
lookupTopEnv :: Ident -> TopEnv a -> [a] Source #
qualLookupTopEnv :: QualIdent -> TopEnv a -> [a] Source #
allImports :: TopEnv a -> [(QualIdent, a)] Source #
moduleImports :: ModuleIdent -> TopEnv a -> [(Ident, a)] Source #
localBindings :: TopEnv a -> [(Ident, a)] Source #
allLocalBindings :: TopEnv a -> [(QualIdent, a)] Source #
allBindings :: TopEnv a -> [(QualIdent, a)] Source #
allEntities :: TopEnv a -> [a] Source #