[Haskell-beginners] 'read' throws; why not maybe or either?
Patrick Redmond
plredmond at gmail.com
Tue Nov 26 04:32:32 UTC 2013
Thanks all! I was able to make use of readEither to do just what I wanted.
On Tuesday, November 26, 2013, Michael Orlitzky wrote:
> On 11/24/2013 04:49 PM, Patrick Redmond wrote:
> > Is there a variation of 'read' which uses Maybe or Either to handle
> > failure instead of an exception?
>
> readMaybe:
>
>
> http://hackage.haskell.org/package/base-4.6.0.1/docs/Text-Read.html#v:readMaybe
>
> Prelude> import Text.Read (readMaybe)
> Prelude Text.Read> readMaybe "Hello, World!" :: Maybe Int
> Nothing
> Prelude Text.Read> readMaybe "45" :: Maybe Int
> Just 45
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org <javascript:;>
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131126/348022af/attachment.html>
More information about the Beginners
mailing list