[Haskell-cafe] abs minBound < (0 :: Int) && negate minBound == (minBound :: Int)

Ketil Malde ketil at malde.org
Wed Aug 21 08:17:14 CEST 2013

> fact 0 = 1
> fact n = n * fact (n-1)
> Now I ran it as fact 1000000 with signature Int -> Int and with
> Integer -> Integer
> In the first case I got 0 in about 3 seconds
> And if that sounds like a unreal argument, consider representing and
> storing Graham's number.

So, since computers are finite anyway, we can just arbitrarily (well,
almost) redefine large constants, and set all factorials above some
threshold to zero?  Perhaps we should also set pi=3, that would simplify
lots of things :-)

> Pragmatically: 32-bits is unwise for a bank-balance, 64 should be a
> bit more safe

Please start a bank using modulo arithmetic, I'm looking forward to
overdrafting my account!  

> So yes, Haskell's Int, should have been called FastInt or Int29 or somethin'

On a more serious note, I accept that Int (and other limited precision
numbers) is a fact of life, and sometimes useful for performance

I would have liked, however, to have a compiler option or some other way
to make my programs throw an exception on overflow - even if this turned
out to be slower, I could at least use it when testing my programs,
which would have caught a few bugs.

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list