Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jberryman
GHC
Commits
40bc127b
Commit
40bc127b
authored
Jan 23, 2003
by
simonpj
Browse files
[project @ 2003-01-23 14:55:36 by simonpj]
Document warning suppression with leading underscore on variable names
parent
9aba9a7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/docs/users_guide/using.sgml
View file @
40bc127b
...
...
@@ -826,7 +826,7 @@ ghc ––make Main.hs
generated during compilation. By default, you get a standard set
of warnings which are generally likely to indicate bugs in your
program. These are:
<option>-fwarn-overl
p
apping-patterns</option>,
<option>-fwarn-overlapping-patterns</option>,
<option>-fwarn-deprecations</option>,
<option>-fwarn-duplicate-exports</option>,
<option>-fwarn-missing-fields</option>, and
...
...
@@ -987,6 +987,18 @@ g [] = 2
an instance declaration is missing one or more methods, and
the corresponding class declaration has no default
declaration for them.</para>
<para>The warning is suppressed if the method name
begins with an underscore. Here's an example where this is useful:
<programlisting>
class C a where
_simpleFn :: a -> String
complexFn :: a -> a -> String
complexFn x y = ... _simpleFn ...
</programlisting>
The idea is that: (a) users of the class will only call <literal>complexFn</literal>;
never <literal>_simpleFn</literal>; and (b)
instance declarations can define either <literal>complexFn</literal> or <literal>_simpleFn</literal>.
</para>
</listitem>
</varlistentry>
...
...
@@ -1111,9 +1123,12 @@ f "2" = 2
<para>Report all unused variables which arise from pattern
matches, including patterns consisting of a single variable.
For instance <literal>f x y = []</literal> would report
<VarName>x</VarName> and <VarName>y</VarName> as unused. To
eliminate the warning, all unused variables can be replaced
with wildcards.</para>
<VarName>x</VarName> and <VarName>y</VarName> as unused. The
warning is suppressed if the variable name begins with an underscore, thus:
<programlisting>
f _x = True
</programlisting>
</para>
</listitem>
</varlistentry>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment