@@ -678,6 +678,25 @@ tl_hexadecimal (n::Positive Int) s ox =
678 where t = TL.dropWhile isHexDigit s
678 where t = TL.dropWhile isHexDigit s
679 p = if ox then "0x" else ""
679 p = if ox then "0x" else ""
681+isFloaty c = c `elem` "+-.0123456789eE"
683+t_read_rational p tol (n::Double) s =
684+ case p (T.pack (show n) `T.append` t) of
686+ Right (n',t') -> t == t' && abs (n-n') <= tol
687+ where t = T.dropWhile isFloaty s
689+tl_read_rational p tol (n::Double) s =
690+ case p (TL.pack (show n) `TL.append` t) of
692+ Right (n',t') -> t == t' && abs (n-n') <= tol
693+ where t = TL.dropWhile isFloaty s
695+t_double = t_read_rational T.double 1e-13
696+tl_double = tl_read_rational TL.double 1e-13
697+t_rational = t_read_rational T.rational 1e-16
698+tl_rational = tl_read_rational TL.rational 1e-16
681-- Input and output.
700-- Input and output.
683-- Work around lack of Show instance for TextEncoding.
702-- Work around lack of Show instance for TextEncoding.
@@ -1163,7 +1182,11 @@ tests = [
1163 testProperty "t_decimal" t_decimal,
1182 testProperty "t_decimal" t_decimal,
1164 testProperty "tl_decimal" tl_decimal,
1183 testProperty "tl_decimal" tl_decimal,
1165 testProperty "t_hexadecimal" t_hexadecimal,
1184 testProperty "t_hexadecimal" t_hexadecimal,
1166− testProperty "tl_hexadecimal" tl_hexadecimal
1185+ testProperty "tl_hexadecimal" tl_hexadecimal,
1186+ testProperty "t_double" t_double,
1187+ testProperty "tl_double" tl_double,
1188+ testProperty "t_rational" t_rational,
1189+ testProperty "tl_rational" tl_rational
1169 testGroup "input-output" [
1192 testGroup "input-output" [