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

David Menendez dave at
Fri Feb 8 15:26:05 EST 2008

2008/2/8 Jeff Polakow <jeff.polakow at>:
   Don Stewart:
>  > readM with fail defaults to ioError for almost all Monads, and so admits
>  > many dangerous programs, which is against the intent of the proposal
>  > in the first place.
>  >
> ioError is only in the IO monad and is catchable. I think the problem is
> when fail defaults to error which can be anywhere and is not catchable.

I think Don meant "error". The default definition of fail in the Monad
class is "error".

>  > It seems with Conor's suggestion of a
>  >
>  >     maybeReturn :: MonadPlus m => Maybe a -> m a
>  >     maybeReturn = maybe mzero return
>  >
>  > we can still have the by-default-safe maybeRead, that doesn't admit
>  > exception throwing opportunities.
>  >
> Isn't the MonadPlus approach also by-default-safe?

Safe, yes, but is it more useful? (I'm tempted to argue that the way
MTL conflates mzero/mplus with throwError/catchError is unfortunate,
but that's another discussion.)

Dave Menendez <dave at>

More information about the Libraries mailing list