[commit: ghc] context-quantification-4426: Note context quantification becomes an error in 7.12; add release notes (39f62a2)
git at git.haskell.org
git at git.haskell.org
Wed Sep 17 20:37:01 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : context-quantification-4426
Link : http://ghc.haskell.org/trac/ghc/changeset/39f62a28beb71d5a7c7bec67af75a079a4dea092/ghc
>---------------------------------------------------------------
commit 39f62a28beb71d5a7c7bec67af75a079a4dea092
Author: Krzysztof Gogolewski <krz.gogolewski at gmail.com>
Date: Wed Sep 17 22:35:43 2014 +0200
Note context quantification becomes an error in 7.12; add release notes
>---------------------------------------------------------------
39f62a28beb71d5a7c7bec67af75a079a4dea092
compiler/hsSyn/HsTypes.lhs | 7 +++++--
compiler/rename/RnTypes.lhs | 3 ++-
docs/users_guide/7.10.1-notes.xml | 24 ++++++++++++++++++++++
docs/users_guide/glasgow_exts.xml | 3 ++-
testsuite/tests/rename/should_compile/T4426.stderr | 15 +++++++++-----
5 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/compiler/hsSyn/HsTypes.lhs b/compiler/hsSyn/HsTypes.lhs
index 104ffe7..9bd5845 100644
--- a/compiler/hsSyn/HsTypes.lhs
+++ b/compiler/hsSyn/HsTypes.lhs
@@ -303,8 +303,11 @@ After renaming
Explicit => the variables the user wrote (renamed)
Qualified currently behaves exactly as Implicit,
-but gives an additional warning if there are
-implicitly quantified variables.
+but it is deprecated to use it for implicit quantification.
+In this case, GHC 7.10 gives a warning; see
+Note [Context quantification] and Trac #4426.
+In GHC 7.12, Qualified will no longer bind variables
+and this will become an error.
The kind variables bound in the hsq_kvs field come both
a) from the kind signatures on the kind vars (eg k1)
diff --git a/compiler/rename/RnTypes.lhs b/compiler/rename/RnTypes.lhs
index 1826f91..5537526 100644
--- a/compiler/rename/RnTypes.lhs
+++ b/compiler/rename/RnTypes.lhs
@@ -868,7 +868,8 @@ warnContextQuantification in_doc tvs
= addWarnAt loc $
vcat [ ptext (sLit "Variable") <+> quotes (ppr tv) <+>
ptext (sLit "is implicitly quantified due to a context") $$
- ptext (sLit "Use explicit forall syntax instead")
+ ptext (sLit "Use explicit forall syntax instead.") $$
+ ptext (sLit "This will become an error in GHC 7.12.")
, in_doc ]
opTyErr :: RdrName -> HsType RdrName -> SDoc
diff --git a/docs/users_guide/7.10.1-notes.xml b/docs/users_guide/7.10.1-notes.xml
index 404d239..d319cc5 100644
--- a/docs/users_guide/7.10.1-notes.xml
+++ b/docs/users_guide/7.10.1-notes.xml
@@ -34,6 +34,30 @@
Added support for <link linkend="binary-literals">binary integer literals</link>
</para>
</listitem>
+ <listitem>
+ <para>
+ Simplified rules for implicit quantification. In previous versions of GHC,
+ it was possible to use the <literal>=></literal> arrow
+ to quantify over type variables in <literal>data</literal> and
+ <literal>type</literal> declarations without a
+ <literal>forall</literal> quantifier. For example,
+ <literal>data Fun = Fun (Ord a => a -> b)</literal> was identical to
+ <literal>data Fun = Fun (forall a b. Ord a => a -> b)</literal>, while
+ <literal>data Fun = Fun (a -> b)</literal> caused a not-in-scope error.
+ This implicit quantification is now deprecated, and variables
+ in higher-rank constructors should be quantified with <literal>forall</literal>
+ regardless of whether a class context is present or not.
+ GHC 7.10 raises a warning (controlled by
+ <option>-fwarn-context-quantification</option>, enabled by default)
+ and GHC 7.12 will raise an error. See <link linkend="univ">examples</link>
+ in GHC documentation.
+ </para>
+ <para>
+ The change also applies to Template Haskell splices such as
+ <literal>[t|Ord a => a|]</literal>, which should be written as
+ <literal>[t|forall a. Ord a => a|]</literal>.
+ </para>
+ </listitem>
</itemizedlist>
</sect3>
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 2c314fa..13090c6 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -7732,7 +7732,8 @@ newtype Swizzle' = MkSwizzle' (Ord a => [a] -> [a])
</programlisting>
As of GHC 7.10, this is deprecated. The <literal>-fwarn-context-quantification</literal>
-flag detects this situation and issues a warning.
+flag detects this situation and issues a warning. In GHC 7.12, declarations
+such as <literal>MkSwizzle'</literal> will cause an out-of-scope error.
</para>
<para>
diff --git a/testsuite/tests/rename/should_compile/T4426.stderr b/testsuite/tests/rename/should_compile/T4426.stderr
index a68f5ed..3cce305 100644
--- a/testsuite/tests/rename/should_compile/T4426.stderr
+++ b/testsuite/tests/rename/should_compile/T4426.stderr
@@ -1,30 +1,35 @@
T4426.hs:6:12: Warning:
Variable ‘m’ is implicitly quantified due to a context
- Use explicit forall syntax instead
+ Use explicit forall syntax instead.
+ This will become an error in GHC 7.12.
In the type ‘a -> m a’
In the declaration for type synonym ‘F’
T4426.hs:8:15: Warning:
Variable ‘b’ is implicitly quantified due to a context
- Use explicit forall syntax instead
+ Use explicit forall syntax instead.
+ This will become an error in GHC 7.12.
In the type ‘a -> b’
In the definition of data constructor ‘X’
T4426.hs:10:21: Warning:
Variable ‘b’ is implicitly quantified due to a context
- Use explicit forall syntax instead
+ Use explicit forall syntax instead.
+ This will become an error in GHC 7.12.
In the type ‘a -> b -> c’
In the definition of data constructor ‘Y’
T4426.hs:10:21: Warning:
Variable ‘c’ is implicitly quantified due to a context
- Use explicit forall syntax instead
+ Use explicit forall syntax instead.
+ This will become an error in GHC 7.12.
In the type ‘a -> b -> c’
In the definition of data constructor ‘Y’
T4426.hs:12:17: Warning:
Variable ‘m’ is implicitly quantified due to a context
- Use explicit forall syntax instead
+ Use explicit forall syntax instead.
+ This will become an error in GHC 7.12.
In the type ‘m b’
In the type signature for ‘f’
More information about the ghc-commits
mailing list