curry-frontend-1.0.3: Compile the functional logic language Curry to several intermediate formats

Copyright1999 - 2003 Wolfgang Lux
2005 Martin Engelke
2011 - 2012 Björn Peemöller
2016 Finn Teegen
LicenseBSD-3-clause
Maintainerbjp@informatik.uni-kiel.de
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Base.TopEnv

Contents

Description

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

Data types

newtype TopEnv a Source #

Top level environment

Constructors

TopEnv 

Fields

Instances
Functor TopEnv Source # 
Instance details

Defined in Base.TopEnv

Methods

fmap :: (a -> b) -> TopEnv a -> TopEnv b #

(<$) :: a -> TopEnv b -> TopEnv a #

Show a => Show (TopEnv a) Source # 
Instance details

Defined in Base.TopEnv

Methods

showsPrec :: Int -> TopEnv a -> ShowS #

show :: TopEnv a -> String #

showList :: [TopEnv a] -> ShowS #

SubstKind a => SubstKind (TopEnv a) Source # 
Instance details

Defined in Base.KindSubst

Methods

subst :: KindSubst -> TopEnv a -> TopEnv a Source #

SubstType a => SubstType (TopEnv a) Source # 
Instance details

Defined in Base.TypeSubst

Methods

subst :: TypeSubst -> TopEnv a -> TopEnv a Source #

class Entity a where Source #

Minimal complete definition

origName

Methods

origName :: a -> QualIdent Source #

merge :: a -> a -> Maybe a Source #

creation and insertion

predefTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a Source #

Insert an Entity into a TopEnv as a predefined Entity

importTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a Source #

Insert an Entity as unqualified into a TopEnv

qualImportTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a Source #

Insert an Entity as qualified into a TopEnv

bindTopEnv :: Ident -> a -> TopEnv a -> TopEnv a Source #