[Haskell-cafe] Re: New Hackage category: Error Handling

Henning Thielemann lemming at henning-thielemann.de
Mon Dec 7 19:15:50 EST 2009


On Tue, 8 Dec 2009, Richard O'Keefe wrote:

>> X/0, sqrt(-1), head [] are errors
>
> It depends on WHERE THE DATA CAME FROM.

If your program actually computes X/0 or sqrt(-1) or head [] your program 
is buggy, independent from where the zero, the minus one or the empty list 
comes.

>> Sure, the distinction exception/error depends on the source of the data 
>> that causes problems.
>
> And sadly, the library does not know this, so the library cannot classify
> problems _that_ way.

To this end the library documentation says: "Precondition: This function 
must only be called on non-empty lists." If the programmer calls it with 
an empty list anyway, it's his fault. The library user made the error 
then. Of course it would be better, if types or contracts could force such 
restrictions:
   http://www.haskell.org/pipermail/haskell-cafe/2009-November/068877.html


More information about the Haskell-Cafe mailing list