I wonder, why Haskell does not check/report the overflow for Int?


For the Haskell implementation, it is natural to have the  Int 
arithmetic cost much less (about 5 times) than  Integer.

Therefore, for the applications like the polynomial arithmetics
(and many others) that represent a power product as 

"newtype PP = PP [Integer] "   or   "newtype PP' = PP' [Int] "

it worths to preserve both PP and PP'.

PP' is considerably cheaper in running, and PP is generic.

Unfortunately, PP' is incorrect.

For example,   x^(2^n) --> x^0,   if  2^n > maximal_Int.

For the algebra, it would be better to 
                   *break in such case with the overflow message*.

With this, the researcher runs the faster program and does not 
risk to get the incorrect result.

Setting things like   newtype Int' = I' Int  
in application and programming arithmetics in Haskell, probably,
would not do. This will run slow. 
Besides,   (I' 2)+x   looks worse than   2+x.
So
1. is this good for Haskell to perform the Int arithmetic modulo 
   maximal_Int ?
2. in what way could it provide also Int' ?



------------------
Sergey Mechveliani

[EMAIL PROTECTED]


Reply via email to