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

Henning Thielemann lemming at henning-thielemann.de
Fri Feb 8 08:20:22 EST 2008


On Fri, 8 Feb 2008, Aaron Denney wrote:

> On 2008-02-08, Yitzchak Gale <gale at sefer.org> wrote:
> > I vote mildly in favor of maybeRead,
> > strongly against readM.
> >
> > "fail" refers only to failure of pattern matching.
> > The wart is that its name should have been
> > more specific, like "patternFail". Using
> > "fail" for a non-pattern-matching error is a
> > bug, not just a wart, in my opinion.
>
> Even if you do consider it a bug, it's an extremely useful bug.
> I don't see the point in deprecating it until a truly usable alternative
> is actually in the standard.

If an alternative is added to the standard libraries, readM would have to
remain. I think the generalization is not useful enough to introduce the
monad version that we will regret later. readM can be added with the right
type, when the alternative appears. Until then maybeRead is fine.


More information about the Libraries mailing list