diff options
| author | Simon Peyton Jones <simonpj@microsoft.com> | 2017-05-08 14:04:34 +0100 |
|---|---|---|
| committer | Simon Peyton Jones <simonpj@microsoft.com> | 2017-05-09 10:43:54 +0100 |
| commit | 549c8b33da25371ab1aa1818ef27fc418252e667 (patch) | |
| tree | 5530e7c2152e113965c641f9a32dd9c21e2dc44b /docs/users_guide | |
| parent | d46a5102e0911e96a85434e46bbfe8b9ccc86471 (diff) | |
| download | haskell-549c8b33da25371ab1aa1818ef27fc418252e667.tar.gz | |
Don't warn about variable-free strict pattern bindings
See Trac #13646 and the new
Note [Pattern bindings that bind no variables]
Diffstat (limited to 'docs/users_guide')
| -rw-r--r-- | docs/users_guide/using-warnings.rst | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index ed2b12b84c..6a42f548d4 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -902,18 +902,20 @@ of ``-W(no-)*``. single: binds, unused Warn if a pattern binding binds no variables at all, unless it is a - lone, possibly-banged, wild-card pattern. For example: :: + lone wild-card pattern, or a banged pattern. For example: :: Just _ = rhs3 -- Warning: unused pattern binding (_, _) = rhs4 -- Warning: unused pattern binding _ = rhs3 -- No warning: lone wild-card pattern - !_ = rhs4 -- No warning: banged wild-card pattern; behaves like seq + !() = rhs4 -- No warning: banged pattern; behaves like seq + In general a lazy pattern binding `p = e` is a no-op if `p` does not + bind any variables. The motivation for allowing lone wild-card patterns is they are not very different from ``_v = rhs3``, which elicits no warning; and they can be useful to add a type constraint, e.g. ``_ = x::Int``. A - lone banged wild-card pattern is useful as an alternative (to - ``seq``) way to force evaluation. + banged pattern (see :ref:`bang-patterns`) is *not* a no-op, because + it forces evaluation, and is useful as an alternative to ``seq``. .. ghc-flag:: -Wunused-imports |
