
8 Mar
2009
8 Mar
'09
8:50 p.m.
On Sun, Mar 8, 2009 at 9:34 PM, Bjorn Buckwalter
(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.