summaryrefslogtreecommitdiff
path: root/docs/users_guide/using-warnings.rst
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2019-02-11 09:24:04 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2019-02-11 21:28:46 +0000
commitdb47e6320b585adb5100c773105c9e861eebab21 (patch)
tree41acf34b30b32010f6b15070a53bb78954623ba0 /docs/users_guide/using-warnings.rst
parent180c9762d4565f0e8b192abf95d2bed57765e0c5 (diff)
downloadhaskell-wip/wildcards-warn.tar.gz
Implement -Wredundant-record-wildcards and -Wunused-record-wildcardswip/wildcards-warn
-Wredundant-record-wildcards warns when a .. pattern binds no variables. -Wunused-record-wildcards warns when none of the variables bound by a .. pattern are used. These flags are not enabled by `-Wall` currently. If people think it is appropuiate to add them then that is an easy change.
Diffstat (limited to 'docs/users_guide/using-warnings.rst')
-rw-r--r--docs/users_guide/using-warnings.rst48
1 files changed, 45 insertions, 3 deletions
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst
index 03ca184531..396bc2b1bc 100644
--- a/docs/users_guide/using-warnings.rst
+++ b/docs/users_guide/using-warnings.rst
@@ -1565,9 +1565,9 @@ of ``-W(no-)*``.
When :extension:`ExplicitForAll` is enabled, explicitly quantified type
variables may also be identified as unused. For instance: ::
-
+
type instance forall x y. F x y = []
-
+
would still report ``x`` and ``y`` as unused on the right hand side
Unlike :ghc-flag:`-Wunused-matches`, :ghc-flag:`-Wunused-type-patterns` is
@@ -1575,7 +1575,7 @@ of ``-W(no-)*``.
unlike term-level pattern names, type names are often chosen expressly for
documentation purposes, so using underscores in type names can make the
documentation harder to read.
-
+
.. ghc-flag:: -Wunused-foralls
:shortdesc: warn about type variables in user-written
``forall``\\s that are unused
@@ -1594,6 +1594,48 @@ of ``-W(no-)*``.
would report ``a`` and ``c`` as unused.
+.. ghc-flag:: -Wunused-record-wildcards
+ :shortdesc: Warn about record wildcard matches when none of the bound variables
+ are used.
+ :type: dynamic
+ :reverse: -Wno-unused-record-wildcards
+ :category:
+
+ .. index::
+ single: unused, warning, record wildcards
+
+ Report all record wildcards where none of the variables bound implicitly
+ are used. For instance: ::
+
+
+ data P = P { x :: Int, y :: Int }
+
+ f1 :: P -> Int
+ f1 P{..} = 1 + 3
+
+ would report that the ``P{..}`` match is unused.
+
+.. ghc-flag:: -Wredundant-record-wildcards
+ :shortdesc: Warn about record wildcard matches when the wildcard binds no patterns.
+ :type: dynamic
+ :reverse: -Wno-redundant-record-wildcards
+ :category:
+
+ .. index::
+ single: unused, warning, record wildcards
+
+ Report all record wildcards where the wild card match binds no patterns.
+ For instance: ::
+
+
+ data P = P { x :: Int, y :: Int }
+
+ f1 :: P -> Int
+ f1 P{x,y,..} = x + y
+
+ would report that the ``P{x, y, ..}`` match has a redundant use of ``..``.
+
+
.. ghc-flag:: -Wwrong-do-bind
:shortdesc: warn about do bindings that appear to throw away monadic values
that you should have bound instead