[Haskell] IO, exceptions and error handling

Tim Docker timothy.docker at macquarie.com
Mon Jun 14 10:39:32 EDT 2004

Keith Wansbrough wrote:

> Read the paper _A Semantics for Imprecise Exceptions_.  The 
> problem is that the evaluation order of Haskell would have to 
> be fixed for this not to lose referential transparency.  What 
> is the value of
> catchExcept (show (makeExcept "E1" + makeExcept "E2"))
>    (\x -> x)
> ?  Haskell wouldn't be "purely functional" any more.

As Graham Klyne indicated in a previous mail, in practice there
are two ways of dealing with errors in purely functional code:

  - capture possible errors in the result type. This will
    probably force the use of a monad, with the subsequent
    sequencing of operation and coding style.

  - throw an exception, and hence be unable to recover from
    errors outside the IO monad.

Both of these approaches seem fairly "invasive" in their
effect on the code. Are people using haskell for real world
tasks happy with having to choose from these? The former is
more general, but any function that needs to be able to
fail or propagate failure will end up being a do {} block.


More information about the Haskell mailing list