[Haskell-cafe] Int is broken [Was: Different answers on different machines]

Kata lightquake at amateurtopologist.com
Sun Jun 2 23:13:18 CEST 2013

On Sunday, June 2, 2013 at 5:02 PM, Tommy Thorn wrote:
> On Jun 2, 2013, at 12:52 , Henry Laxen <nadine.and.henry at pobox.com (mailto:nadine.and.henry at pobox.com)> wrote:
> > Yes, that was it. The dell was a 32 bit system, and the desktop a 64. I 
> > changed everything from Int to Integer, and now both agree. Thanks for the 
> > pointer.
> > 
> Isn't that just terrible? I hate the fact that Haskell was defined to neither trap the overflow
> or just treat everything as Integer [like Scheme]. A sacrifice of program safety in the name
> of efficiency.
> I disagree with this choice and posit that a clever implementation can minimize the cost
> of the overflow checking in most relevant cases.
> I wish this fatal flaw would be reconsidered for the next major revision.
> Tommy
In addition to Haskell already having an arbitrary-width integer type called Integer, consider the case where you have some program that basically boils down to 

f :: Int -> Int
f x = {- some super-complicated mathematical expression -}

f can only have bounds checks eliminated if the values of the inputs are known in advance. How often are you really going to know that? If you do something like

main = do
    x <- read <$> getLine
    print $ f x

then you have to put all the bounds checks in *anyway*.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130602/60c199e5/attachment.htm>

More information about the Haskell-Cafe mailing list