summaryrefslogtreecommitdiff
path: root/libraries/base/Text
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/Text')
-rw-r--r--libraries/base/Text/Read.hs4
-rw-r--r--libraries/base/Text/Read/Lex.hs2
2 files changed, 6 insertions, 0 deletions
diff --git a/libraries/base/Text/Read.hs b/libraries/base/Text/Read.hs
index b2c3d6bfc7..6c9d89db76 100644
--- a/libraries/base/Text/Read.hs
+++ b/libraries/base/Text/Read.hs
@@ -62,6 +62,8 @@ reads = readsPrec minPrec
-- | Parse a string using the 'Read' instance.
-- Succeeds if there is exactly one valid result.
-- A 'Left' value indicates a parse error.
+--
+-- /Since: 4.6.0.0/
readEither :: Read a => String -> Either String a
readEither s =
case [ x | (x,"") <- readPrec_to_S read' minPrec s ] of
@@ -76,6 +78,8 @@ readEither s =
-- | Parse a string using the 'Read' instance.
-- Succeeds if there is exactly one valid result.
+--
+-- /Since: 4.6.0.0/
readMaybe :: Read a => String -> Maybe a
readMaybe s = case readEither s of
Left _ -> Nothing
diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs
index 28bad33852..f2ef4cc922 100644
--- a/libraries/base/Text/Read/Lex.hs
+++ b/libraries/base/Text/Read/Lex.hs
@@ -61,6 +61,7 @@ data Lexeme
| EOF
deriving (Eq, Show)
+-- | /Since: 4.6.0.0/
data Number = MkNumber Int -- Base
Digits -- Integral part
| MkDecimal Digits -- Integral part
@@ -130,6 +131,7 @@ numberToRangedRational (neg, pos) n@(MkDecimal iPart mFPart (Just exp))
else Just (numberToRational n)
numberToRangedRational _ n = Just (numberToRational n)
+-- | /Since: 4.6.0.0/
numberToRational :: Number -> Rational
numberToRational (MkNumber base iPart) = val (fromIntegral base) 0 iPart % 1
numberToRational (MkDecimal iPart mFPart mExp)