
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@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 1.0 Prelude> fromInteger x + fromInteger y :: Double 0.0 Stefan