@@ -678,6 +678,25 @@ tl_hexadecimal (n::Positive Int) s ox =
678678 where t = TL.dropWhile isHexDigit s
679679 p = if ox then "0x" else ""
680680
681+isFloaty c = c `elem` "+-.0123456789eE"
682+
683+t_read_rational p tol (n::Double) s =
684+ case p (T.pack (show n) `T.append` t) of
685+ Left err -> False
686+ Right (n',t') -> t == t' && abs (n-n') <= tol
687+ where t = T.dropWhile isFloaty s
688+
689+tl_read_rational p tol (n::Double) s =
690+ case p (TL.pack (show n) `TL.append` t) of
691+ Left err -> False
692+ Right (n',t') -> t == t' && abs (n-n') <= tol
693+ where t = TL.dropWhile isFloaty s
694+
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
699+
681700-- Input and output.
682701
683702-- Work around lack of Show instance for TextEncoding.
@@ -1163,7 +1182,11 @@ tests = [
11631182 testProperty "t_decimal" t_decimal,
11641183 testProperty "tl_decimal" tl_decimal,
11651184 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
11671190 ],
11681191
11691192 testGroup "input-output" [