Commit 6c2b22ef authored by chak's avatar chak
Browse files

[project @ 2001-11-13 03:28:03 by chak]

A little more info about type checking
parent 2772264a
......@@ -11,6 +11,47 @@
Probably the most important phase in the frontend is the type checker,
which is located at <a
GHC type checks programs in their original Haskell form before the
desugarer converts them into Core code. This complicates the type
checker as it has to handle the much more verbose Haskell AST, but it
improves error messages, as the those message are based on the same
structure that the user sees.
GHC defines the abstract syntax of Haskell programs in <a
using a structure that abstracts over the concrete representation of
bound occurences of identifiers and patterns. The module <a
instantiates this structure for the type checker using <a
to represent identifiers - in fact, a <code>TcId</code> is currently
nothing but just a synonym for a <a href="vars.html">plain
<h4>Types Variables and Zonking</h4>
During type checking type variables are represented by mutable variables
- cf. the <a href="vars.html#TyVar">variable story.</a> Consequently,
unification can instantiate type variables by updating those mutable
variables. This process of instantiation is (for reasons that elude
me) called <a
in GHC's sources. The zonking routines for the various forms of Haskell
constructs are responsible for most of the code in the module <a
whereas the routines that actually operate on mutable types are defined
in <a
this includes routines to create mutable structures and update them as
well as routines that check constraints, such as that type variables in
function signatures have not been instantiated during type checking.
The actual type unification routine is <code>uTys</code> in the same
All type variables that may be instantiated (those in signatures
may not), but haven't been instantiated during type checking, are zonked
to <code>()</code>, so that after type checking all mutable variables
have been eliminated.
<h4>Type Checking Environment</h4>
......@@ -89,7 +130,7 @@
<!-- hhmts start -->
Last modified: Wed Aug 8 19:24:09 EST 2001
Last modified: Tue Nov 13 14:28:44 EST 2001
<!-- hhmts end -->
......@@ -74,8 +74,10 @@ data VarDetails
-- should not be unified with a non-tyvar type
<a name="TyVar">
<h2>Type variables (<code>TyVar</code>)</h2>
The <code>TyVar</code> case is self-explanatory. The
<code>MutTyVar</code> case is used only during type checking. Then a
type variable can be unified, using an imperative update, with a type,
......@@ -224,7 +226,7 @@ A <code>Local</code> name can be cloned freely.
<!-- hhmts start -->
Last modified: Wed Aug 8 19:23:01 EST 2001
Last modified: Tue Nov 13 14:11:35 EST 2001
<!-- hhmts end -->
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment