[Haskell-cafe] Re: Exception handling in numeric computations

Jonathan Cast jonathanccast at fastmail.fm
Mon Mar 30 13:14:06 EDT 2009

On Fri, 2009-03-27 at 21:16 -0700, Donn Cave wrote:
> Quoth Henning Thielemann <lemming at henning-thielemann.de>,
> > On Fri, 27 Mar 2009, Donn Cave wrote:
> >
> >> Quoth Jonathan Cast <jonathanccast at fastmail.fm>,
> >>
> >>> An `error' is any condition where the correct response is for the
> >>> programmer to change the source code :)
> >>
> >> That's a broad category, that overlaps with conditions where there
> >> are one or more correct responses for the original program as well.
> >>
> >> If I throw exceptions within the type system, using IO or whatever,
> >> and at some later time observe that I have caught one that would
> >> have been better handled closer to its source, for example.  I've
> >> already technically satisfied my requirement, since everything is
> >> in an exception monad, but the exception is still a bug.
> >
> > I don't understand this one.
> A lame attempt to demonstrate that "condition where [a] correct
> response is to change the code"

Please don't mis-quote me.  I said `the' correct response.  Both
programming and operating computers are goal-directed processes; an
error is a situation where the program detects a bug such that it cannot
make progress toward the current goal without the programmer going and
fixing that bug.

If you have a condition where there is something (useful...) you want to
do within the context of the current source code, do not use an error to
signal that condition.  Use an exception.

> applies to too many cases to be
> useful.  (And that there are no cases where [the only] correct
> response is to change the code.)

I think Henning's response, and others, have adequately covered this.


More information about the Haskell-Cafe mailing list