On Sun, Mar 8, 2009 at 9:34 PM, Bjorn Buckwalter
<[email protected]> wrote:
> (For my current needs the formats accepted by "read" are sufficient,
> but I want reasonable error handling (Maybe or Either) instead of an
> exception on bad inputs.)
Why not
readM :: (Monad m, Read a) => String -> m a
readM str = case [x | (x,"") <- readsPrec 0 str] of
[x] -> return x
_ -> fail "readM: failed"
Also, I remember seeing this function exported by some module, but I
don't remember where.
HTH,
--
Felipe.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe