
Simon Marlow wrote:
Avoiding exceptions because MonadIO has trouble with them is not a good enough reason, IMO. We should fix MonadIO instead.
I'm all for it! Below is a summary of the three approaches that have been proposed, as far as I can remember: 1. Make the functions in Control.Exception more polymorphic. This is part of the more general program of providing polymorphic IO described in Haskell' ticket 110. Brian Hulley attached to that ticket a version of Control.Exception that does this by introducing the MonadException subclass of MonadIO. http://hackage.haskell.org/trac/haskell-prime/attachment/ticket/110/Exceptio... 2. In another branch from this thread, I suggested adding only the following three low-level exception handling functions to Control.Exception: startDelayingExceptions stopDelayingExceptions getDelayedException This would allow exception handling to be extended arbitrarily in other libraries, with only a small addition to Control.Exception. Simon Marlow pointed out that this mechanism would lose certain optimizations that exist, e.g., for preserving tail-recursion in block. That would be a cost of this generality. (Obviously we would retain the current mechanism for IO itself.) http://www.haskell.org/pipermail/libraries/2008-February/009159.html 3. Earlier in this thread, Judah Jacobson proposed adding additional liftIO functions to MonadIO, or a subclass, that match the kinds of the exception handling functions of Control.Exception. The kinds that would be needed are: For block and unblock: * -> * For catch: * -> (* -> *) -> * For setUncaughtExceptionHandler: (* -> *) -> * The liftIO for catch is the most general, so it could be reused for the others, but that would look a little ad hoc. This approach has the advantage that it does not require any change at all to Control.Exception, but it puts more of a burden on monad authors. http://www.haskell.org/pipermail/libraries/2008-January/009034.html Any other approaches? Any opinions about which of these would be best? Thanks, Yitz

Yitzchak Gale wrote:
Simon Marlow wrote:
Avoiding exceptions because MonadIO has trouble with them is not a good enough reason, IMO. We should fix MonadIO instead.
I'm all for it!
Below is a summary of the three approaches that have been proposed, as far as I can remember:
1. Make the functions in Control.Exception more polymorphic. This is part of the more general program of providing polymorphic IO described in Haskell' ticket 110. Brian Hulley attached to that ticket a version of Control.Exception that does this by introducing the MonadException subclass of MonadIO.
http://hackage.haskell.org/trac/haskell-prime/attachment/ticket/110/Exceptio...
Correct me if I'm wrong, but it doesn't seem to be necessary to modify Control.Exception directly in order to adopt this proposal. The new module could be provided as Control.Monad.IO.Exception (for example) in the mtl package. No changes to the base package are required to make this functionality available to everyone. Right? If so, this seems like the smoothest way to address the problem. Cheers, Simon

On Mon, Feb 4, 2008 at 8:25 AM, Simon Marlow
Yitzchak Gale wrote:
Simon Marlow wrote:
Avoiding exceptions because MonadIO has trouble with them is not a good enough reason, IMO. We should fix MonadIO instead.
I'm all for it!
Below is a summary of the three approaches that have been proposed, as far as I can remember:
1. Make the functions in Control.Exception more polymorphic. This is part of the more general program of providing polymorphic IO described in Haskell' ticket 110. Brian Hulley attached to that ticket a version of Control.Exception that does this by introducing the MonadException subclass of MonadIO.
http://hackage.haskell.org/trac/haskell-prime/attachment/ticket/110/Exceptio...
Correct me if I'm wrong, but it doesn't seem to be necessary to modify Control.Exception directly in order to adopt this proposal. The new module could be provided as Control.Monad.IO.Exception (for example) in the mtl package. No changes to the base package are required to make this functionality available to everyone. Right?
If so, this seems like the smoothest way to address the problem.
Of the three possibilities listed by Yitzchak, I'm most in favor of adding Brian Hulley's module to the mtl package. (In particular, I've decided that I like it more than my own, earlier proposal.) The only change that I'd make would be to remove setUncaughtExceptionHandler from the MonadException class; it's GHC-specific, and I'm not sure how useful having it in arbitrary MonadIO would be anyway. Best, -Judah

Simon Marlow wrote:
The new module could be provided as Control.Monad.IO.Exception (for example) in the mtl package... this seems like the smoothest way to address the problem.
Judah Jacobson wrote:
Of the three possibilities listed by Yitzchak, I'm most in favor of adding Brian Hulley's module to the mtl package. (In particular, I've decided that I like it more than my own, earlier proposal.)
The comments in Brian Hulley's module warn that we need to address some issues raised by Oleg before actually adopting this proposal. I'll be out for a few days, I'll try to look at it after that if no one else gets to it. Thanks, Yitz
participants (3)
-
Judah Jacobson
-
Simon Marlow
-
Yitzchak Gale