Generalizing Network.CGI exceptions to MonadCatchIO

Bas van Dijk v.dijk.bas at gmail.com
Mon Mar 15 16:33:59 EDT 2010


On Mon, Mar 15, 2010 at 8:37 PM, Anders Kaseorg <andersk at mit.edu> wrote:
> (It would be possible to generalize the types even further, from
> SomeException to Exception e => e, but I’m worried about introducing
> ambiguous type variables into existing code.  After this patch, new code
> can just use the Control.Monad.CatchIO functions directly to deal with
> Exception e => e.)

(Note I'm not a user of the cgi package so don't take the following to
seriously)

What about deprecating all the cgi exception handling functions:
throwCGI, catchCGI and tryCGI in favor of the CatchIO ones?

The advantage: a simpler API.

The disadvantage: possible ambiguous type variables like you
mentioned. However, these can usually be resolved using a simple type
annotation in your exception handler. Maybe somebody can analyze the
reverse dependencies of cgi to see if any ambiguities will actually
arise:

http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/cgi-3001.1.7.2

regards,

Bas

P.S.
It would also be a good idea to rename the section "Error handling" to
"Exception handling" because of:

http://haskell.org/haskellwiki/Error_vs._Exception


More information about the Libraries mailing list