[Haskell-cafe] Errors in non-monadic code

Donn Cave donn at avvanta.com
Mon Aug 19 22:12:13 CEST 2013


jabolopes at google.com,
MIME-Version: 1.0
Content-type: text/plain; charset=UTF-8
In-Reply-To: <CAKFCL4VfY-Dz3Xo9ZUZ_SmfRQ2nLGDLbovU=SuF1-sSnqVS8Hw at mail.gmail.com>
References: <CAKFCL4VfY-Dz3Xo9ZUZ_SmfRQ2nLGDLbovU=SuF1-sSnqVS8Hw at mail.gmail.com>

quoth Brandon Allbery,

> Even in IO, exceptions should be reserved for truly exceptional conditions
> (of the "program cannot safely continue" variety), not merely for error
> checking when this can be described as a normal flow of evaluation.
> Exceptions are not simply alternative flow of control, even in procedural
> languages; they are *disruptions* of flow of control.

I think that would be debatable, especially as applied to procedural languages
in general.  It's very common to use exceptions in routine flow of control in
Python programs, if I remember right.  Meanwhile, the Haskell library in my
opinion somewhat weakens your case by making ordinary conditions into exceptions,
for example end-of-file.  

In the end it's a large grey area.  Ideally, what the program has to do, or
whether it can even continue at all, is determined by the program using
information reported by the function that encounters the error.  If there's
a good reason why exceptions should be used only when the program won't be
able to continue, it must be that the language's exception handling facililty
isn't very robust.

	Donn




More information about the Haskell-Cafe mailing list