From 40bc127b66178bed99e66907fe1b28f58c2fa17d Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 23 Jan 2003 14:55:36 +0000 Subject: [PATCH] [project @ 2003-01-23 14:55:36 by simonpj] Document warning suppression with leading underscore on variable names --- ghc/docs/users_guide/using.sgml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ghc/docs/users_guide/using.sgml b/ghc/docs/users_guide/using.sgml index 97b7eda..54c77d7 100644 --- a/ghc/docs/users_guide/using.sgml +++ b/ghc/docs/users_guide/using.sgml @@ -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: - , + , , , , 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. + The warning is suppressed if the method name + begins with an underscore. Here's an example where this is useful: + + class C a where + _simpleFn :: a -> String + complexFn :: a -> a -> String + complexFn x y = ... _simpleFn ... + + The idea is that: (a) users of the class will only call complexFn; + never _simpleFn; and (b) + instance declarations can define either complexFn or _simpleFn. + @@ -1111,9 +1123,12 @@ f "2" = 2 Report all unused variables which arise from pattern matches, including patterns consisting of a single variable. For instance f x y = [] would report - x and y as unused. To - eliminate the warning, all unused variables can be replaced - with wildcards. + x and y as unused. The + warning is suppressed if the variable name begins with an underscore, thus: + + f _x = True + + -- 1.7.10.4