[Haskell-cafe] approxRatio and Ratio Word

Vilem-Benjamin Liepelt vl81 at kent.ac.uk
Sat Nov 4 22:04:05 UTC 2017


I have been experiencing curious behaviour with approxRatio:

Prelude Data.Ratio> let a = 0 :: Word
Prelude Data.Ratio> let b = 10 :: Word
Prelude Data.Ratio> a%b
0 % 1
Prelude Data.Ratio> approxRational (a%b) 0.01
1 % 1
Prelude Data.Ratio> approxRational (0%1) 0.01
0 % 1

Is this expected? If so, why?


More information about the Haskell-Cafe mailing list