[Haskell-cafe] exceptions vs. Either
ketil+haskell at ii.uib.no
Tue Aug 3 06:51:50 EDT 2004
Graham Klyne <GK at ninebynine.org> writes:
> 2. I like to distinguish between "expected errors" and "unexpected
> errors". Having been burned in the past by using exceptions (not FP),
> I try to use them only for conditions that are truly unexpected;
> i.e. _exceptional_. Bad input, IMO, is something that is not
> unexpected, so I don't really like to handle that via exceptions.
I agree, trying to handle exceptions caused by incorrect input is just
needless complication, the program should crash, and the calling
function should be fixed instead.
Common errors that happen to me are:
Prelude.head : empty list
Prelude.read : no parse
and Prelude.(!!) : index too large
and so on.
Is there any easy way (TH?) to amend these to output the line number
of the offending caller? It would be a great improvement to see
Prelude.head : empty list in Foo.hs, line 4711
since programs generally contain many, many calls to functions like
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe