
On Fri, Jun 22, 2007 at 12:34:09PM -0700, Dave Bayer wrote:
On Jun 22, 2007, at 11:42 AM, David Roundy wrote:
On Fri, Jun 22, 2007 at 11:37:15AM -0700, Dave Bayer wrote:
GHC issues a "Warning: Defaulting the following constraint(s) to type `Int'" for the definition of z.
Why don't you just use -fno-warn-type-defaults? ... ghc -Werr -Wall is a often good idea, but if you prefer a different programming style (e.g. no top-level type declarations required), ghc gives you the flexibility to do that.
To be precise, I __PREFER__ a "ghc -Wall -Werror" programming style. In particular, I always want defaulting errors, because sometimes I miss the fact that numbers I can count on my fingers are defaulting to Integer.
Once I explicitly declare "default (Int)", I want "ghc -Wall - Werror" to shut up, unless this defaulting rule never gets used. Instead, it complains anyways when the defaulting takes place that I've just declared I know about. In other words, I want warnings involving "default" to follow the same logic currently used for warnings involving "import".
I see, that makes sense. And I have no idea that would help you.
This is a bug. I want "ghc -Wall -Werror" to be a practical choice, left on all the time, and in my example I had to work too hard to avoid the warning. Other people just wouldn't use "ghc -Wall - Werror", the way some people won't use seat belts, and the way some people view any strongly typed language as a cumbersome seat belt. If we tolerate ridiculously arcane syntax to handle these situations, we fully deserve to be marginalized while Ruby takes over the world.
In other words, I'm disputing that the top-level declarations are in fact required. GHC can be trivially modified to allow Haskell to handle this situation far more elegantly.
I think of top-level type declarations as type-checked comments, rather than a seat-belt. It forces you to communicate to others what a function does, if that function may be used elsewhere. I like this. Although it can be cumbersome for quick and dirty code, developers trying to read your code will thank you for it (unless you make *everything* top-level, which is just poor coding style). -Wall -Werror isn't a seat belt, it's a coding-style guideline. -- David Roundy Department of Physics Oregon State University