[Haskell-cafe] Re: A question about "monad laws"

Roman Leshchinskiy rl at cse.unsw.edu.au
Thu Feb 14 17:41:02 EST 2008

Aaron Denney wrote:
> On 2008-02-14, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
>> Richard A. O'Keefe wrote:
>>> SafeInt is what you should use when you *THINK* your results should all fit
>>> in a machine int but aren't perfectly sure.  (And this is nearly all the 
>>> time.)
>> Again, I strongly disagree. You should use Integer unless your program 
>> is too slow and profiling shows that Integer is the culprit. If and only 
>> if that is the case should you think about alternatives. That said, I 
>> doubt that your SafeInt would be significantly faster than Integer.
> Why?  GMP is pretty good, but it's not going to be anywhere near
> hardware speeds.

This how Integer is defined in the libraries:

data Integer	
    = S# Int#				-- small integers
    | J# Int# ByteArray#			-- large integers

As long as the Int# doesn't overflow, you don't call any GMP routines.


More information about the Haskell-Cafe mailing list