The issue with this example is that you have genericTake :: Integral a => a -> [b] -> [b]
where the 'a' is converted to an Int without being checked for overflow. IMHO type defaulting is irrelevant for this one problem; evaluating > take 444444444444444444444444444444 "foobar" has exactly the same result without any defaulting taking place. Arguably fromIntegral could have other behavior (error/exception/Maybe) when a conversion would overflow, but that seems like a very significant change. Aside from this example, I'm quite sympathetic to the issue. I've more than once defined values as let two = 2 :: Int three = 3 :: Int solely to suppress warnings about type defaulting for (^n). Really, I'd prefer to see the Prelude export (^) :: Num a => a -> Int -> a I think that's the most common case, and it's probably never useful to raise to a power greater than (maxBound :: Int). John L. On Thu, Apr 11, 2013 at 8:10 AM, Tom Ellis < tom-lists-haskell-cafe-2...@jaguarpaw.co.uk> wrote: > 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 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe