
8 Feb
2008
8 Feb
'08
5:50 a.m.
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. My preferences for the type of this function, from best to worst, would be: 1. (Error e, MonadError e m, Read a) => String -> m a 2. (MonadZero m, Read a) => String -> m a 3. (MonanPlus m, Read a) => String -> m a 4. Read a => String -> Maybe a But (1) depends on mtl, and MonadZero is not even part of the libraries, so (2) is also out. That leaves (3) and (4) as the only possibilities. They're still useful sometimes. Thanks, Yitz