Proposal: Add Text.Read.maybeRead :: Read a => String -> Maybe a
Henning Thielemann
lemming at henning-thielemann.de
Thu Feb 7 15:18:25 EST 2008
On Thu, 7 Feb 2008, Don Stewart wrote:
> This function is typically defined once per project. So its
> about time this safe variant of 'read' made it into the base.
>
> maybeRead :: Read a => String -> Maybe a
> maybeRead s = case reads s of
> [(x, "")] -> Just x
> _ -> Nothing
>
> Consideration period: 1 week.
>
> Patch to Text.Read attached.
Seems to be useful. May prevent people from using just 'read' while hoping
that parsing will always succeed.
More information about the Libraries
mailing list