[Haskell-cafe] Numerics and Warnings

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Thu Apr 11 02:10:40 CEST 2013


On Thu, Apr 11, 2013 at 12:56:05AM +0100, Barak A. Pearlmutter wrote:
> > ... in most of the cases I do want this warnings. It's possible to get
> > something default to Integer when it should be Int. There are only few
> > cases when it's not appropriate. Only ^ and ^^ with literals I think
> 
> There are a few other cases, albeit less annoying.  Like this:
> 
> c = fromIntegral 2 :: Int
> 
> Granted this is silly code, but the same case arises inside pretty much
> any code that is generic over Integral, in which case the warning you
> get is not the *right* warning.  Example:
> 
> genericTake n xs = take (fromIntegral n) xs
> genericTake 444444444444444444444444444444 "foobar"

Hi Barak,

I don't write a lot of numeric code so I am under-educated in this area.
Could you write a more substantial example so I get a clearer idea of what's
going on?

Thanks,

Tom



More information about the Haskell-Cafe mailing list