extra-1.6.13: Extra functions I use.
Text.Read.Extra
Description
This module provides Text.Read with functions added in later versions.
module Text.Read
readEither :: Read a => String -> Either String a #
Parse a string using the Read instance. Succeeds if there is exactly one valid result. A Left value indicates a parse error.
Read
Left
>>> readEither "123" :: Either String Int Right 123
>>>
readEither "123" :: Either String Int
>>> readEither "hello" :: Either String Int Left "Prelude.read: no parse"
readEither "hello" :: Either String Int
Since: base-4.6.0.0
readMaybe :: Read a => String -> Maybe a #
Parse a string using the Read instance. Succeeds if there is exactly one valid result.
>>> readMaybe "123" :: Maybe Int Just 123
readMaybe "123" :: Maybe Int
>>> readMaybe "hello" :: Maybe Int Nothing
readMaybe "hello" :: Maybe Int