[[project @ 2002-01-08 07:29:07 by chak] chak**20020108072907 Some docu covering VarSet, NameSet, VarEnv, and NameEnv. ] { hunk ./ghc/docs/comm/index.html 9 -

The Glasgow Haskell Compiler (GHC) Commentary [v0.6]

+

The Glasgow Haskell Compiler (GHC) Commentary [v0.7]

hunk ./ghc/docs/comm/index.html 83 -Last modified: Mon Nov 26 19:23:12 EST 2001 +Last modified: Tue Jan 8 18:23:25 EST 2002 hunk ./ghc/docs/comm/the-beast/basicTypes.html 15 - names. + names. Some of those are discussed in the following. Some more + detailed information on Vars, Ids, and + TyVars is provided elsewhere. + +

Elementary Types

hunk ./ghc/docs/comm/the-beast/basicTypes.html 51 -

+

Sets, Finite Maps, and Environments

+

+ Sets of variables, or more generally names, which are needed throughout + the compiler, are provided by the modules VarSet.lhs + and NameSet.lhs, + respectively. Moreover, frequently maps from variables (or names) to + other data is needed. For example, a substitution is represented by a + finite map from variable names to expressions. Jobs like this are + solved by means of variable and name environments implemented by the + modules VarEnv.lhs + and NameEnv.lhs. + +

The Module VarSet

+

+ The Module VarSet provides the types VarSet, + IdSet, and TyVarSet, which are synonyms in the + current implementation, as Var, Id, and + TyVar are synonyms. The module provides all the operations + that one would expect including the creating of sets from individual + variables and lists of variables, union and intersection operations, + element checks, deletion, filter, fold, and map functions. +

+ The implementation is based on UniqSets, + which in turn are simply UniqFMs + (i.e., finite maps with uniques as keys) that map each unique to the + variable that it represents. + +

The Module NameSet

+

+ The Module NameSet provides the same functionality as + VarSet only for Names. + As for the difference between Names and Vars, + a Var is built from a Name plus additional + information (mostly importantly type information). + +

The Module VarEnv

+

+ The module VarEnv provides the types VarEnv, + IdEnv, and TyVarEnv, which are again + synonyms. The provided base functionality is similar to + VarSet with the main difference that a type VarEnv + T associates a value of type T with each variable in + the environment, thus effectively implementing a finite map from + variables to values of type T. +

+ The implementation of VarEnv is also by UniqFM, + which entails the slightly surprising implication that it is + not possible to retrieve the domain of a variable environment. + In other words, there is no function corresponding to + VarSet.varSetElems :: VarSet -> [Var] in + VarEnv. This is because the UniqFM used to + implement VarEnv stores only the unique corresponding to a + variable in the environment, but not the entire variable (and there is + no mapping from uniques to variables). +

+ In addition to plain variable environments, the module also contains + special substitution environments - the type SubstEnv - + that associates variables with a special purpose type + SubstResult. + +

The Module NameEnv

+

+ The type NameEnv.NameEnv is like VarEnv only + for Names. + +


hunk ./ghc/docs/comm/the-beast/basicTypes.html 125 -Last modified: Wed Aug 8 19:23:01 EST 2001 +Last modified: Tue Jan 8 18:29:52 EST 2002 }