summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Schmits <git@tryp.io>2022-07-18 19:44:50 +0200
committerTorsten Schmits <git@tryp.io>2022-07-18 19:44:50 +0200
commita40e63fee44891f4418592f7994243b72fd90a8c (patch)
tree80a20129b233fb890d64a7342a0f9d23960dbfbb
parent92e141666d5c206d0504aa3cb234d7f2f4e5e787 (diff)
downloadhaskell-a40e63fee44891f4418592f7994243b72fd90a8c.tar.gz
add -Wpattern-signature-binds to user guide
-rw-r--r--docs/users_guide/exts/scoped_type_variables.rst3
-rw-r--r--docs/users_guide/using-warnings.rst14
2 files changed, 17 insertions, 0 deletions
diff --git a/docs/users_guide/exts/scoped_type_variables.rst b/docs/users_guide/exts/scoped_type_variables.rst
index fa117fc032..e10454e8db 100644
--- a/docs/users_guide/exts/scoped_type_variables.rst
+++ b/docs/users_guide/exts/scoped_type_variables.rst
@@ -227,6 +227,9 @@ case, *the signature brings that type variable into scope*. For example: ::
The pattern type signature makes the type variable available on the right-hand side of the equation.
+GHC will print a warning about variables brought into scope by signatures
+in this fashion if the flag :ghc-flag:`-Wpattern-signature-binds` is set.
+
Bringing type variables into scope is particularly important
for existential data constructors. For example: ::
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst
index 977bb69941..80f91f4f5f 100644
--- a/docs/users_guide/using-warnings.rst
+++ b/docs/users_guide/using-warnings.rst
@@ -129,6 +129,7 @@ The following flags are simple ways to select standard "packages" of warnings:
* :ghc-flag:`-Wimplicit-lift`
* :ghc-flag:`-Wmissing-kind-signatures`
* :ghc-flag:`-Wunticked-promoted-constructors`
+ * :ghc-flag:`-pattern-signature-binds`
.. ghc-flag:: -Weverything
:shortdesc: enable all warnings supported by GHC
@@ -2355,6 +2356,19 @@ of ``-W(no-)*``.
triggered whenever this happens, and can be addressed by enabling the
extension.
+.. ghc-flag:: -Wpattern-signature-binds
+ :shortdesc: warn when a pattern signature binds a type variable
+ :type: dynamic
+ :reverse: -Wno-pattern-signature-binds
+
+ :since: 9.6
+
+ :extension:`ScopedTypeVariables` allows patterns to be annotated with type signatures.
+ If a signature mentions a type variable that hasn't been explicitly quantified in a
+ ``forall``, GHC will implicitly bind it.
+ This warning reports such an implicitly bound variable.
+
+
If you're feeling really paranoid, the :ghc-flag:`-dcore-lint` option is a good choice.
It turns on heavyweight intra-pass sanity-checking within GHC. (It checks GHC's
sanity, not yours.)