On 29-Sep-1999, George Russell <[EMAIL PROTECTED]> wrote:
> Fergus Henderson wrote:
> [many interesting things which are snipped]
> > There are many common examples where exceptions arise for reasons other
> > than I/O, for example integer overflow, division by zero, taking the
> > square root of a negative number, head of an empty list, and so forth.
>
> When that happens in my code it counts as a bug! Therefore error is
> appropriate. If you are in some larger Haskell universe calling component
> Haskell code it is unfortunate if a single error calls the entire universe
> to collapse, so you do need some way of recovering, but perhaps a function
> as mentioned of type
> a -> IO (Maybe a)
> which traps the error might suffice for this case.
If implementors can provide a function of type
`a -> IO (Maybe a)', then they can just as easily provide
a function of type `a -> IO (Either a Exception)',
as is done in Hugs/ghc with the `tryAll' function.
And it may well be useful for the error recovery code
to have some information about what kind of error occurred,
so that it can print better error diagnostics
and/or choose the appropriate recovery action based on
the kind of error.
So why limit expressiveness by providing only the former?
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.