
On Wed, Jan 23, 2008 at 01:49:34AM +0200, Yitzchak Gale wrote:
Ian Lynagh wrote:
People using MonadIO can convert this into the variant that doesn't throw an exception by replacing readlineFunction args with something like (try $ readlineFunction args) >> return ()
That's in the IO monad, so not always available.
Everywhere you can write readlineFunction args you can write (try $ readlineFunction args) >> return () The only way you can have problems is if there is a library (that you don't control), which exports a (MonadIO m => m a) that internally calls readlineFunction args and doesn't catch exceptions. Personally I'd say that that is a bug in that other library, and it ought to be catching the exception and either ignoring it, returning some sort of sum type, or also constraining m to be in some sort of MonadError monad.
If we start throwing IO exceptions for common and minor occurrences like no readline history available
Pretty much any actual IO you do has this problem, e.g. readFile on a non-existent file. Thanks Ian