Skip to content

loop fusion not working for Int32, Int64 as it does for Int ?

here is some code that works for Int, but gives me Stack Overflow for arguments 18 .. 24, and Out of memory for 25. (Just change the type annotation in main.)

import Data.Int
import System.Environment

bitcount x = if x > 0 
    then let (d,m) = divMod x 2 in  bitcount d + m
    else 0

main = do
    [ arg ]  <- getArgs
    print $ sum  $ map bitcount
          [ 0 :: Int64 .. 2^read arg - 1 ]

https://github.com/haskell-distributed/distributed-process/issues/91#issuecomment-11468092

Not sure whether it's a bug, but it's annoying. There is no conceptual difference between these numerical types, so I shouldn't have to rewrite my program when switching between them.

Trac metadata
Trac field Value
Version 7.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information