[Haskell] IO, exceptions and error handling

Duncan Coutts duncan.coutts at worcester.oxford.ac.uk
Mon Jun 14 10:57:02 EDT 2004


On Mon, 2004-06-14 at 14:34, Graham Klyne wrote:
> I'm finding that a recurring theme in my work with Haskell libraries (and 
> in particular the XML libraries) is the awkwardness of handling errors 
> outside the IO monad.

With GHC You can throw exceptions in pure code but may only catch them
in the IO monad. As Keith pointed out this is because the language would
not be referentially transparent if you could catch exception in 'pure'
code.

This is often enough in most situations. If you need to catch the
exceptions too then you'll want an error monad of some sort.

Duncan



More information about the Haskell mailing list