Using Rational (equals Ratio Integer) in a haste program results in wrong values if the nominator exceeds 2^32-1. The denominator on the other hand seems to work as expected.
Minimal example:
import Data.Ratio
testInteger :: String -> String
testInteger a = show (read a :: Integer)
testRational :: String -> String
testRational a = show ((read a :: Integer) % 1)
testRational2 :: String -> String
testRational2 a = show (1 % (read a :: Integer))
main = do
putStrLn $ testInteger "1234567890"
putStrLn $ testInteger "12345678901"
putStrLn $ testRational "1234567890"
putStrLn $ testRational "12345678901"
putStrLn $ testRational2 "1234567890"
putStrLn $ testRational2 "12345678901"
Using Rational (equals Ratio Integer) in a haste program results in wrong values if the nominator exceeds 2^32-1. The denominator on the other hand seems to work as expected.
Minimal example:
Expected Output (console):
Actual Output (line 4 is different):
It is noteworthy that
mod 12345678901 (2^32)
equals3755744309
. Compiling with ghc and running the program on the console works as expected.Used Versions: