[Haskell-cafe] Best idiom for avoiding Defaulting warnings with
ghc -Wall -Werror ??
lemming at henning-thielemann.de
Fri Jun 22 18:35:30 EDT 2007
On Fri, 22 Jun 2007, Dave Bayer wrote:
> If I import a module that I don't use, then "ghc -Wall -Werror"
> rightly complains. By analogy, if I use "default (Int)" to ask GHC to
> default to Int but the situation never arises, then GHC should
> rightly complain. Instead, if I use "default (Int)", GHC complains
> about defaulting anyways. In my opinion, this is a bug, but I'd like
> guidance before reporting it. Is there a more elegant way to handle
> the numeric type classes with "ghc -Wall -Werror" ?
My understanding of defaulting is that it is bad style to rely on it. It
is mostly needed for working in GHCi.
For the particular exponentiation issue, I found the following: The
overwhelming part of constant exponents of (^) in my modules is 2. The
defaulting is mostly relevant for number literals, whereas variables get
their types from somewhere else. So you may consider implementing a 'sqr'
function for squaring values.
More information about the Haskell-Cafe