[Haskell-cafe] GHC optimisations

Stefan O'Rear stefanor at cox.net
Wed Aug 22 14:13:37 EDT 2007

On Wed, Aug 22, 2007 at 06:36:15PM +0100, Neil Mitchell wrote:
> Hi
> > If Num obeys ring axioms, fromInteger is a perfectly fine
> > ring-homomorphism. (It's also the first or second homomorphism taught.)
> Does Int obey these axioms? I'm thinking that assuming properties
> about things such as numbers is very likely to go wrong very quickly.
> Monads you might be able to get away with, Numbers you probably can't.

Int does obey the axioms, it's the classical ring ℤ[4294967296].
Double, however, does not:

stefan at stefans:~$ ghci
GHCi, version 6.7.20070712: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> let x = 10000000000000000000000 ; y = 1 - x
Prelude> fromInteger (x + y) :: Double
Prelude> fromInteger x + fromInteger y :: Double

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070822/81a5fa18/attachment.bin

More information about the Haskell-Cafe mailing list