Commit 5d7b5573 authored by's avatar
Browse files

Documentation for impredicative polymorphism

parent 116e4e36
......@@ -3198,7 +3198,27 @@ for rank-2 types.
<sect2 id="impredicative-polymorphism">
<title>Impredicative polymorphism
<para>GHC supports <emphasis>impredicative polymorphism</emphasis>. This means
that you can call a polymorphic function at a polymorphic type, and
parameterise data structures over polymorphic types. For example:
f :: Maybe (forall a. [a] -> [a]) -> Maybe ([Int], [Char])
f (Just g) = Just (g [3], g "hello")
f Nothing = Nothing
Notice here that the <literal>Maybe</literal> type is parameterised by the
<emphasis>polymorphic</emphasis> type <literal>(forall a. [a] ->
<para>The technical details of this extension are described in the paper
<ulink url="">Boxy types:
type inference for higher-rank types and impredicativity</ulink>,
which appeared at ICFP 2006.
<sect2 id="scoped-type-variables">
<title>Lexically scoped type variables
......@@ -3753,7 +3773,13 @@ for these <literal>Terms</literal>:
These and many other examples are given in papers by Hongwei Xi, and Tim Sheard.
<para> The extensions to GHC are these:
The rest of this section outlines the extensions to GHC that support GADTs.
It is far from comprehensive, but the design closely follows that described in
the paper <ulink
unification-based type inference for GADTs</ulink>,
which appeared in ICFP 2006.
Data type declarations have a 'where' form, as exemplified above. The type signature of
......@@ -3896,19 +3922,26 @@ the result type of the <literal>case</literal> expression. Hence the addition <
<sect1 id="template-haskell">
<title>Template Haskell</title>
<para>Template Haskell allows you to do compile-time meta-programming in Haskell. There is a "home page" for
Template Haskell at <ulink url=""></ulink>, while
the background to
<para>Template Haskell allows you to do compile-time meta-programming in
The background to
the main technical innovations is discussed in "<ulink
Template Meta-programming for Haskell</ulink>" (Proc Haskell Workshop 2002).
The details of the Template Haskell design are still in flux. Make sure you
consult the <ulink url="">online library reference material</ulink>
There is a Wiki page about
Template Haskell at <ulink url=""></ulink>, and that is the best place to look for
further details.
You may also
consult the <ulink
Haskell library reference material</ulink>
(search for the type ExpQ).
[Temporary: many changes to the original design are described in
<ulink url="">""</ulink>.
Not all of these changes are in GHC 6.2.]
Not all of these changes are in GHC 6.6.]
<para> The first example from that paper is set out below as a worked example to help get you started.
Supports Markdown
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