Proposal: Add Text.Read.maybeRead :: Read a => String -> Maybe a
jeff.polakow at db.com
Thu Feb 7 15:20:31 EST 2008
Why not allow an arbitrary monad?
readM :: (Monad m, Read a) => String -> String -> m a
readM errMsg s = case reads s of
[(x, "")] -> return x
_ -> fail errMsg
libraries-bounces at haskell.org wrote on 02/07/2008 01:46:48 PM:
> 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.
> [attachment "maybeRead.patch" deleted by Jeff Polakow/db/dbcom]
> Libraries mailing list
> Libraries at haskell.org
This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries