[Haskell-cafe] (Read r) => IO (Maybe r)

Christopher Done chrisdone at googlemail.com
Fri Dec 17 14:15:10 CET 2010

On 17 December 2010 13:59, Jacek Generowicz <jacek.generowicz at cern.ch>wrote:
> What are some interesting, idiomatic ways of writing something similar to
> the following

λ> :m + Safe
λ> let getValidatedInteger = getLine >>= maybe (do putStrLn "That doesn't
seem to be an integer. Try again."; getValidatedInteger) return . readMay ::
IO Integer
Loading package safe-0.3 ... linking ... done.
λ> getValidatedInteger
That doesn't seem to be an integer. Try again.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101217/d02021a9/attachment.htm>

More information about the Haskell-Cafe mailing list