summaryrefslogtreecommitdiff
path: root/docs/comm/the-beast/basicTypes.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/comm/the-beast/basicTypes.html')
-rw-r--r--docs/comm/the-beast/basicTypes.html132
1 files changed, 132 insertions, 0 deletions
diff --git a/docs/comm/the-beast/basicTypes.html b/docs/comm/the-beast/basicTypes.html
new file mode 100644
index 0000000000..ca56d6b6a8
--- /dev/null
+++ b/docs/comm/the-beast/basicTypes.html
@@ -0,0 +1,132 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
+ <title>The GHC Commentary - The Basics</title>
+ </head>
+
+ <body BGCOLOR="FFFFFF">
+ <h1>The GHC Commentary - The Basics</h1>
+ <p>
+ The directory <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/"><code>fptools/ghc/compiler/basicTypes/</code></a>
+ contains modules that define some of the essential types definition for
+ the compiler - such as, identifiers, variables, modules, and unique
+ names. Some of those are discussed in the following. See elsewhere for more
+ detailed information on:
+ <ul>
+ <li> <a href="vars.html"><code>Var</code>s, <code>Id</code>s, and <code>TyVar</code>s</a>
+ <li> <a href="renamer.html"><code>OccName</code>s, <code>RdrName</code>s, and <code>Names</code>s</a>
+ </ul>
+
+ <h2>Elementary Types</h2>
+
+ <h4><code>Id</code>s</h4>
+ <p>
+ An <code>Id</code> (defined in <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/Id.lhs"><code>Id.lhs</code></a>
+ essentially records information about value and data constructor
+ identifiers -- to be precise, in the case of data constructors, two
+ <code>Id</code>s are used to represent the worker and wrapper functions
+ for the data constructor, respectively. The information maintained in
+ the <code>Id</code> abstraction includes among other items strictness,
+ occurrence, specialisation, and unfolding information.
+ <p>
+ Due to the way <code>Id</code>s are used for data constructors,
+ all <code>Id</code>s are represented as variables, which contain a
+ <code>varInfo</code> field of abstract type <code><a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/IdInfo.lhs">IdInfo</a>.IdInfo</code>.
+ This is where the information about <code>Id</code>s is really stored.
+ The following is a (currently, partial) list of the various items in an
+ <code>IdInfo</code>:
+ <p>
+ <dl>
+ <dt><a name="occInfo">Occurence information</a>
+ <dd>The <code>OccInfo</code> data type is defined in the module <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/BasicTypes.lhs"><code>BasicTypes.lhs</code></a>.
+ Apart from the trivial <code>NoOccInfo</code>, it distinguishes
+ between variables that do not occur at all (<code>IAmDead</code>),
+ occur just once (<code>OneOcc</code>), or a <a
+ href="simplifier.html#loopBreaker">loop breakers</a>
+ (<code>IAmALoopBreaker</code>).
+ </dl>
+
+ <h2>Sets, Finite Maps, and Environments</h2>
+ <p>
+ Sets of variables, or more generally names, which are needed throughout
+ the compiler, are provided by the modules <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/VarSet.lhs"><code>VarSet.lhs</code></a>
+ and <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/NameSet.lhs"><code>NameSet.lhs</code></a>,
+ 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 <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/VarEnv.lhs"><code>VarEnv.lhs</code></a>
+ and <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/NameEnv.lhs"><code>NameEnv.lhs</code></a>.
+
+ <h4>The Module <code>VarSet</code></h4>
+ <p>
+ The Module <code>VarSet</code> provides the types <code>VarSet</code>,
+ <code>IdSet</code>, and <code>TyVarSet</code>, which are synonyms in the
+ current implementation, as <code>Var</code>, <code>Id</code>, and
+ <code>TyVar</code> 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.
+ <p>
+ The implementation is based on <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/utils/UniqSet.lhs"><code>UniqSet</code></a>s,
+ which in turn are simply <a href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/utils/UniqFM.lhs"><code>UniqFM</code></a>s
+ (i.e., finite maps with uniques as keys) that map each unique to the
+ variable that it represents.
+
+ <h4>The Module <code>NameSet</code></h4>
+ <p>
+ The Module <code>NameSet</code> provides the same functionality as
+ <code>VarSet</code> only for <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/basicTypes/Name.lhs"><code>Name</code></a>s.
+ As for the difference between <code>Name</code>s and <code>Var</code>s,
+ a <code>Var</code> is built from a <code>Name</code> plus additional
+ information (mostly importantly type information).
+
+ <h4>The Module <code>VarEnv</code></h4>
+ <p>
+ The module <code>VarEnv</code> provides the types <code>VarEnv</code>,
+ <code>IdEnv</code>, and <code>TyVarEnv</code>, which are again
+ synonyms. The provided base functionality is similar to
+ <code>VarSet</code> with the main difference that a type <code>VarEnv
+ T</code> associates a value of type <code>T</code> with each variable in
+ the environment, thus effectively implementing a finite map from
+ variables to values of type <code>T</code>.
+ <p>
+ The implementation of <code>VarEnv</code> is also by <a
+ href="http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/ghc/compiler/utils/UniqFM.lhs"><code>UniqFM</code></a>,
+ which entails the slightly surprising implication that it is
+ <em>not</em> possible to retrieve the domain of a variable environment.
+ In other words, there is no function corresponding to
+ <code>VarSet.varSetElems :: VarSet -> [Var]</code> in
+ <code>VarEnv</code>. This is because the <code>UniqFM</code> used to
+ implement <code>VarEnv</code> 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).
+ <p>
+ In addition to plain variable environments, the module also contains
+ special substitution environments - the type <code>SubstEnv</code> -
+ that associates variables with a special purpose type
+ <code>SubstResult</code>.
+
+ <h4>The Module <code>NameEnv</code></h4>
+ <p>
+ The type <code>NameEnv.NameEnv</code> is like <code>VarEnv</code> only
+ for <code>Name</code>s.
+
+ <p><hr><small>
+<!-- hhmts start -->
+Last modified: Tue Jan 8 18:29:52 EST 2002
+<!-- hhmts end -->
+ </small>
+ </body>
+</html>