
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. Here's an example: In a library, you have a function that starts up an external system, runs a calculation, then shuts down the external system. Like this: bracketSystem :: MonadIO m => m a -> m a bracketSystem x = do startUpSystem ret <- x shutDownSystem return ret Now you would really like to wrap that in bracket to make sure that "shutDownSystem" is called even when an IO exception is thrown. But unfortunately, bracket is currently not available for MonadIO, nor is there any way to emulate it AFIK. (This is a "maybe" for HaskellPrime: http://hackage.haskell.org/trac/haskell-prime/ticket/110) So the best you can do is make sure not to do anything inside "x" that is likely to throw an IO exception. That way, you'll only be left with zombies and other mess when the hard disk fills up, or other rare and serious conditions. If we start throwing IO exceptions for common and minor occurrences like no readline history available, libraries like this become impossible to write in Haskell. And code that has already been written becomes unusable. Thanks, Yitz