Merijn Verstraaten | 23 Feb 12:20 2013
Picon

Suggestin: IO companion for readMaybe

L.S.,

Now that GHC exports "readMaybe :: Read a => String -> Maybe a" from Text.Read (which I think should be
exported from a more obvious/newbie friendly place, btw. Maybe Prelude?) I'd like to propose a similar
companion for "readLn :: Read a => IO a" along the lines of "maybeReadLn :: Read a => IO (Maybe a)". This would
be very convenient for quick hacks and to get newcomers playing with IO without having to bother with
handling exceptions from misparses of readLn. I'm not sure about the name, some options are:
readLnMaybe, readMaybeLn, maybeReadLn

Kind regards,
Merijn
Brent Yorgey | 23 Feb 21:48 2013

Re: Suggestin: IO companion for readMaybe

On Sat, Feb 23, 2013 at 12:20:33PM +0100, Merijn Verstraaten wrote:
> L.S.,
> 
> Now that GHC exports "readMaybe :: Read a => String -> Maybe a" from Text.Read (which I think should be
exported from a more obvious/newbie friendly place, btw. Maybe Prelude?) I'd like to propose a similar
companion for "readLn :: Read a => IO a" along the lines of "maybeReadLn :: Read a => IO (Maybe a)". This would
be very convenient for quick hacks and to get newcomers playing with IO without having to bother with
handling exceptions from misparses of readLn. I'm not sure about the name, some options are:
readLnMaybe, readMaybeLn, maybeReadLn

+1. (Also +1 to exporting readMaybe from the Prelude.) Given that we
already have 'readMaybe' it seems the only logical/consistent name for
this would be 'readLnMaybe'.

-Brent

Gmane