[Haskell-cafe] Best idiom for avoiding Defaulting warnings with ghc -Wall -Werror ??

Dave Bayer bayer at cpw.math.columbia.edu
Mon Jun 25 11:53:18 EDT 2007


On Jun 25, 2007, at 8:15 AM, Simon Peyton-Jones wrote:

> i2 = 2 :: Int
> i3 = 3 :: Int

The code

> {-# OPTIONS_GHC -Wall -Werror #-}
>
> module Main where
>
> i2 = 2 :: Int
> i3 = 3 :: Int
>
> main :: IO ()
> main = putStrLn $ show (i2,i3)

generates the errors

> Main.hs:5:0: Warning: Definition but no type signature for `i2'
> Main.hs:6:0: Warning: Definition but no type signature for `i3'

and imposes a linear per-use penalty of one extra character per use.  
If I can't write x^3, I find x*x*x more transparent than x^i3.

I know how to fix this; my previous message considered

> i2,i3 :: Int
> (i2,i3) = (2,3)

which still imposes a linear per-use penalty of one extra character  
per use.

It continues to appear to me that "ghc -Wall -Werror" doesn't support  
small Int constants without a per-use penalty, measured in code length.

Am I the only one blessed/cursed with a vision of how proponents of  
"practical" languages would have a field day with this? Perhaps I'm  
reading too many blogs.



More information about the Haskell-Cafe mailing list