[Haskell] IO, exceptions and error handling

Ketil Malde ketil+haskell at ii.uib.no
Tue Jun 15 03:13:18 EDT 2004


"Tim Docker" <timothy.docker at macquarie.com> writes:

> Of course... that was my second alternative error strategy. I'm
> interest in how/when people decide when to throw exceptions versus
> when to thread errors using monads, given that changing code from
> one to the other could be quite a big deal.

I generally use 'error' for any kind of situation that shouldn't
happen during normal execution.  For run-time situations that can be
dealt with gracefully, I use Maybe or Either, and try to deal with it
as low as possible.

I realize this is very simplistic, but IME, exception handling code
trying to deal with all kinds of possibilities for failure often
becomes very spaghettiized, just like excessive use of (the other kind
of) GOTO.  There are simply too many bad things that can happen, so I
prefer the (Erlang?) strategy of 'letting it crash'.

If I were building a large long-lived application, I would probably
build subsystems using the LIC philosophy, and catch errors and
restart subsystems from a monadic framework.

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell mailing list