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

Lennart Augustsson lennart at augustsson.net
Sun Feb 10 18:33:16 EST 2008


Because the fail method is an abomination that should never have been
included in the Monad class.

2008/2/7 Jeff Polakow <jeff.polakow at db.com>:

>
> 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.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20080210/39f9ed5f/attachment.htm


More information about the Libraries mailing list