
Achim Schneider
Nevertheless, a question comes to me - shouldn't compiler report a warning?
While doing that is easy in this case, it becomes quite delicate in the general case. More precisely, it grows into the halting problem.
I think it would be nice with a warning when a literal will overflow. I'd also like run time warnings for overflows, the fact that all the finite integral types wrap around is often an annoyance. I believe that for Int (where the exact precision is unspecified) programs that wrap will be non-portable. I wonder if it would be possible to write a debugging Data.Word library, where you could have something like: instance Num Word8 where (+) w1 w2 = let (i :: Integer) = fromIntegral w1 + fromIntegral w2 (w :: Word8) = w1 Word8.plus w2 in if (fromIntegral w /= i) then error ... else w : Then at least it could be used for testing (including QuickCheck) and lower the probability of overflow and wrap-around. I suspect that the Num instances are too tightly coupled with the data definitions to make such a module possible, though. -k -- If I haven't seen further, it is by standing in the footprints of giants