Proposal: Add Text.Read.maybeRead :: Read a => String -> Maybe a
john at repetae.net
Thu Feb 7 22:52:30 EST 2008
On Thu, Feb 07, 2008 at 03:20:31PM -0500, Jeff Polakow wrote:
> Why not allow an arbitrary monad?
> readM :: (Monad m, Read a) => String -> String -> m a
> readM errMsg s = case reads s of
> [(x, "")] -> return x
> _ -> fail errMsg
Yes. I strongly support this, this routine has been in my GenUtil for a
long time as is hella useful. Though, I wouldn't give it an error
message argument and just let it have something descriptive like "readM:
no parse" as in my other reply.
John Meacham - ⑆repetae.net⑆john⑈
More information about the Libraries