[Haskell-cafe] Exception handling when using STUArray

Donn Cave donn at avvanta.com
Sun Mar 9 01:43:20 EST 2008

On Mar 8, 2008, at 12:33 PM, Henning Thielemann wrote:

> On Sat, 8 Mar 2008, Denis Bueno wrote:
>> I am also using STUArray from some time-critical code; however, I
>> don't deal with ArrayException, or any exceptions for that matter.
>> What besides an out-of-bounds read or write might throw an
>> ArrayException?  If it is out-of-bounds reading or writing, surely
>> that indicates a bug in your program that you'd rather fix than catch
>> the exception, no?
> Another instance of mixing up exceptions and errors in the Haskell  
> libraries.
>   http://www.haskell.org/haskellwiki/Error
>   http://www.haskell.org/haskellwiki/Exception

This seems to me one of the disappointments of Haskell - not just a
detail that was handled in an awkward way, but a fundamental flaw.
I'm not talking about ArrayException, whatever that is, but the notion
that errors encountered in functional code mustn't be handled as

If your input file is not where you expected it and openFile fails,  
or it was
incompletely written out and your input processing fails in a 'head' or
pattern match, the difference is not very important to me.  I want to be
able to call your code and manage the risk that it's going to kill my  
You may feel that it's your job to write more robust functional code  
can't run into these errors, but C programmers can be found who insist
that it's the programmer's job to manage heap memory and it isn't all
that hard.  A programming language that fails to make it easier to write
more robust code, is not moving us forward.  I rejoice that Haskell  
as miserable as C, but with respect to exceptions and errors, it's  
for example Python.  Languages that can, use exceptions like IndexError.
Evidently, Haskell fundamentally can't.  That's too bad.

	Donn Cave, donn at avvanta.com

More information about the Haskell-Cafe mailing list