
27 Feb
2002
27 Feb
'02
5:24 a.m.
Simon Marlow notes:
But fromIntegral *does* do the right thing, doesn't it?
Numeric.showHex (fromIntegral (-1 :: Int32) :: Word32) "" "0xffffffff"
Interesting. The fact that this fooled Julian as well as me suggests the behavior needs to be better documented. Interestingly, hugs yields an error. I'm going to follow up in more detail to haskell, as this is really about the behavior of "fromInteger", and has nothing to do with Word32 or Int32 per se at all.
There's this paragraph which talks about the behaviour of fromIntegral in GHC: http://www.haskell.org/ghc/docs/latest/set/vs-haskell-defn.html#HASKELL98-UN... but it suggests that this only happens for Int. I'll expand it to cover the sized integral types. Cheers, Simon