diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2019-02-11 09:24:04 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-02-14 02:36:02 -0500 |
commit | 19626218566ea709b5f6f287d3c296b0c4021de2 (patch) | |
tree | d22f486e543a19670be2ae88e8e358f99e1e54fd /docs/users_guide/using-warnings.rst | |
parent | 1d9a1d9fb8fe0a1fea2c44c4246f102ff3e1f3a3 (diff) | |
download | haskell-19626218566ea709b5f6f287d3c296b0c4021de2.tar.gz |
Implement -Wredundant-record-wildcards and -Wunused-record-wildcards
-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 enabled by `-Wall`.
Diffstat (limited to 'docs/users_guide/using-warnings.rst')
-rw-r--r-- | docs/users_guide/using-warnings.rst | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 03ca184531..c392ab38df 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,50 @@ 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 + :since: 8.10.1 + :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 + :since: 8.10.1 + :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 |