[Haskell-cafe] Best idiom for avoiding Defaulting warnings with
ghc -Wall -Werror ??
simonpj at microsoft.com
Mon Jun 25 07:48:52 EDT 2007
The intention is that it should be straightforward to suppress warnings.
Warning about defaulting is important, because it's a place where a silent choice affects the dynamic semantics of your program. You can suppress the warning by supplying a type signature. In your example:
| > main =
| > let r = pi :: Double
| > x = r ^ (3 :: Int)
| > y = r ^ 3
| > z = r Prelude.^ 3
| > in putStrLn $ show (x,y,z)
Simply add a type signature for 'z', or for the naked 3 in z's definition.
I think it matters what type is chosen, because it affects the output of the program; it's good practice to be explicit about what type you want, at each site where defaulting is applied. If your idea of good practice differs from mine, then you can record your choice by using -fno-warn-type-defaults.
More information about the Haskell-Cafe