Commit 26b2caf0 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Make Rank2Types and PolymorphicComponents into a synonym for RankNTypes (no deprecation)

There was a long thread on cvs-ghc which concluded that although it's
the Right Thing to deprecate Rank2Types and PolymorphicComponents, in
favour of RankNTypes, it would cause lots of busy-work for library
authors and the pain isn't worth the gain.

So this patch removes the deprecation, and documents the synonym-ity.
parent 788ceade
......@@ -2457,11 +2457,11 @@ xFlags = [
( "CApiFFI", Opt_CApiFFI, nop ),
( "GHCForeignImportPrim", Opt_GHCForeignImportPrim, nop ),
( "LiberalTypeSynonyms", Opt_LiberalTypeSynonyms, nop ),
( "PolymorphicComponents", Opt_RankNTypes,
deprecatedForExtension "RankNTypes" ),
( "Rank2Types", Opt_RankNTypes,
deprecatedForExtension "RankNTypes" ),
( "PolymorphicComponents", Opt_RankNTypes, nop),
( "Rank2Types", Opt_RankNTypes, nop),
( "RankNTypes", Opt_RankNTypes, nop ),
( "ImpredicativeTypes", Opt_ImpredicativeTypes, nop),
( "TypeOperators", Opt_TypeOperators, nop ),
( "ExplicitNamespaces", Opt_ExplicitNamespaces, nop ),
......
......@@ -914,9 +914,7 @@
<entry>Enable <link linkend="explicit-foralls">explicit universal quantification</link>.
Implied by <option>-XScopedTypeVariables</option>,
<option>-XLiberalTypeSynonyms</option>,
<option>-XRank2Types</option>,
<option>-XRankNTypes</option>,
<option>-XPolymorphicComponents</option>,
<option>-XExistentialQuantification</option>
</entry>
<entry>dynamic</entry>
......@@ -925,13 +923,13 @@
<row>
<entry><option>-XPolymorphicComponents</option></entry>
<entry>Enable <link linkend="universal-quantification">polymorphic components for data constructors</link>.</entry>
<entry>dynamic</entry>
<entry>dynamic, synonym for <option>-XRankNTypes</option></entry>
<entry><option>-XNoPolymorphicComponents</option></entry>
</row>
<row>
<entry><option>-XRank2Types</option></entry>
<entry>Enable <link linkend="universal-quantification">rank-2 types</link>.</entry>
<entry>dynamic</entry>
<entry>dynamic, synonym for <option>-XRankNTypes</option></entry>
<entry><option>-XNoRank2Types</option></entry>
</row>
<row>
......
......@@ -2071,9 +2071,7 @@ The following syntax is stolen:
Stolen (in types) by: <option>-XExplicitForAll</option>, and hence by
<option>-XScopedTypeVariables</option>,
<option>-XLiberalTypeSynonyms</option>,
<option>-XRank2Types</option>,
<option>-XRankNTypes</option>,
<option>-XPolymorphicComponents</option>,
<option>-XExistentialQuantification</option>
</para></listitem>
</varlistentry>
......@@ -6384,20 +6382,12 @@ The function <literal>f3</literal> has a rank-3 type;
it has rank-2 types on the left of a function arrow.
</para>
<para>
GHC has three flags to control higher-rank types. (All three imply <option>-XExplicitForAll</option>, <xref linkend="explicit-foralls"/>.)
<itemizedlist>
<listitem><para>
<option>-XPolymorphicComponents</option>: data constructors (only) can have polymorphic argument types.
</para></listitem>
<listitem><para>
<option>-XRank2Types</option>: any function (including data constructors) can have a rank-2 type.
</para></listitem>
<listitem><para>
<option>-XRankNTypes</option>: any function (including data constructors) can have an arbitrary-rank type.
That is, you can nest <literal>forall</literal>s
The language option <option>-XRankNTypes</option> (which implies <option>-XExplicitForAll</option>, <xref linkend="explicit-foralls"/>)
enables higher-rank types.
That is, you can nest <literal>forall</literal>s
arbitrarily deep in function arrows.
In particular, a forall-type (also called a "type scheme"),
including an operational type class context, is legal:
For example, a forall-type (also called a "type scheme"),
including a type-class context, is legal:
<itemizedlist>
<listitem> <para> On the left or right (see <literal>f4</literal>, for example)
of a function arrow </para> </listitem>
......@@ -6407,15 +6397,20 @@ field type signatures.</para> </listitem>
<listitem> <para> As the type of an implicit parameter </para> </listitem>
<listitem> <para> In a pattern type signature (see <xref linkend="scoped-type-variables"/>) </para> </listitem>
</itemizedlist>
</para></listitem>
</itemizedlist>
Either <option>-XRank2Types</option> or <option>-XRankNTypes</option> is also required for any
The <option>-XRankNTypes</option> option is also required for any
type with a <literal>forall</literal> or
context to the right of an arrow (e.g. <literal>f :: Int -> forall a. a->a</literal>, or
<literal>g :: Int -> Ord a => a -> a</literal>). Such types are technically rank 1, but
are clearly not Haskell-98, and an extra flag did not seem worth the bother.
</para>
<para>
The obselete language options <option>-XPolymorphicComponents</option> and <option>-XRank2Types</option>
are synonyms for <option>-XRankNTypes</option>. They used to specify finer distinctions that
GHC no longer makes. (They should really elicit a deprecation warning, but they don't, purely
to avoid the need to library authors to change their old flags specifciations.)
</para>
<sect3 id="univ">
<title>Examples
</title>
......
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