@@ -22,8 +22,8 @@ module Data.Text.Read
24import Control.Monad (liftM)
24import Control.Monad (liftM)
25−import Data.Char (digitToInt, isDigit, isHexDigit, ord)
25+import Data.Char (isDigit, isHexDigit, ord)
26−import Data.Ratio
26+import Data.Ratio ((%))
27import Data.Text as T
27import Data.Text as T
29-- | Read some text, and if the read succeeds, return its value and
29-- | Read some text, and if the read succeeds, return its value and
@@ -56,8 +56,17 @@ hexadecimal txt
56 | otherwise = hex txt
56 | otherwise = hex txt
57 where (h,t) = T.splitAt 2 txt
57 where (h,t) = T.splitAt 2 txt
59+hexDigitToInt :: Char -> Int
61+ | c >= '0' && c <= '9' = ord c - ord '0'
62+ | c >= 'a' && c <= 'f' = ord c - (ord 'a' - 10)
63+ | otherwise = ord c - (ord 'A' - 10)
65+digitToInt :: Char -> Int
66+digitToInt c = ord c - ord '0'
59−-- | Read a leading sign character (@\'-\'@ or @\'+\'@) and apply it
68+-- | Read an optional leading sign character (@\'-\'@ or @\'+\'@) and
60−-- to the result of applying the given reader.
69+-- apply it to the result of applying the given reader.
61signed :: Num a => Reader a -> Reader a
70signed :: Num a => Reader a -> Reader a
62{-# INLINE signed #-}
71{-# INLINE signed #-}
63signed f = runP (signa (P f))
72signed f = runP (signa (P f))