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

Donn Cave donn at avvanta.com
Fri Mar 27 12:31:08 EDT 2009

Quoth John Lato <jwlato at gmail.com>,

> An exception is caused by some sort of interaction with the run-time
> system (frequently a hardware issue).  The programmer typically can't
> check for these in advance, but can only attempt to recover after
> they've happened.
> An error is some sort of bug that should be fixed by the programmer.

I have never felt that I really understood that one.

What about invalid inputs?  Say someone encounters a disk full error,
and the resulting partly written file is now unreadable data for its
intended application because of an invalid file encoding?  Is that
an exception, or a bug that should be fixed?

My guess is that you'll say it's a bug, i.e., that application's
file decoding result should be an Either type that anticipates that
the file encoding may be invalid.

I will also guess if the file is unreadable because of an external
I/O problem like no read access to file or filesystem, you would
similarly expect this to be treated like that - I mean, ideally, e.g.,
hGetLine :: Handle -> IO (Either IOError String)

Does that make sense so far?


More information about the Haskell-Cafe mailing list