[Haskell-cafe] A program which never crashes (even when a function calls "error")

Stephane Bortzmeyer bortzmeyer at nic.fr
Tue Aug 1 02:52:06 EDT 2006

[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:
      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")?

More information about the Haskell-Cafe mailing list