[Haskell] IO, exceptions and error handling
alastair at reid-consulting-uk.ltd.uk
Mon Jun 14 12:57:46 EDT 2004
> I assume the suggested mapException function [sect 5.4] remains
> unproblematic ... is it (or some equivalent) actually implemented?
The same page has a host of other useful operations.
Two useful capabilities that are missing in the actual implementation are:
1) Provision for routinely adding filename and line number.
(Of course, we'd need some kind of compiler support for filling
that info in.)
data Exception = ... | Location SrcLoc Exception | ...
2) The ability to build up lists of exceptions perhaps by adding something
data Exception = ... | Nested Exception Exception | ...
This would allow handlers to build 'stacks' of exceptions rather like the
stackdumps Java exceptions produce. For example:
foo x = mapException (Nested (ErrorCall "while in foo")) $ bar x
bar x = mapException (Nested (ErrorCall "while in bar")) $ baz x
baz x = 1/x
Nested (ErrorCall "while in foo")
(Nested (ErrorCall "while in bar")
[Alternate names for 'Nested' welcome. `WhileDoing` is my next best
More information about the Haskell