
On Tue, 1 Aug 2006, Stephane Bortzmeyer wrote:
[It is a philosophical question, not a practical programming problem.]
I'm used, in imperative programming languages with exceptions (like Python) to call any function without fear of stopping the program because I can always catch the exceptions with things like (Python):
while not over: try: code which may raise an exception... except Exception e: do something clever
How to do it in Haskell? How can I call functions like Prelude.head while being sure my program won't stop, even if I call head on an empty list (thus calling "error")?
Catching errors is quite a hack. If the head of an empty list is requested, then this is considered a programming error, not a user error. Thus the best is to stop the program. Don't mix programming errors with problems caused by users (that is, exceptions).