Proposal: Add Text.Read.maybeRead :: Read a => String -> Maybe a

Jeff Polakow jeff.polakow at db.com
Thu Feb 7 15:20:31 EST 2008


Hello,

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

-Jeff


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
> http://www.haskell.org/mailman/listinfo/libraries


---

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...
URL: http://www.haskell.org/pipermail/libraries/attachments/20080207/e3f76a5a/attachment.htm


More information about the Libraries mailing list